%% This is part of the OpTeX project, see http://petr.olsak.net/optex \_codedecl \readbibs {Reading bib databases <2024-02-18>} % loaded on demand by \usebib \_doc ----------------------------- First, we implement the scanner of `.bib` files. Unfortunately, the format of these files isn't \TeX/ friendly, so we must to do more work. \`\readbibs` `{}` reads files (i.e. the Bib\TeX/ format). \_cod ----------------------------- \_newcount\_aunum \_newcount\_NameCount \_def\_eaddto#1#2{\_ea\_addto\_ea#1\_ea{#2}} \_def\_readbibs #1{% \_ifcsname _be:\_bibp*\_endcsname \_def\_citelist{}\_fi % \_citelist will be created \_begingroup \_everyeof{@{}}\_foreach#1,\_do##1,{% \_isfile{##1.bib}\_iftrue \_ea\_nextat\_input{##1.bib} \_else \_opwarning{\_string\usebib: Missing ##1.bib file} \_fi}% \_endgroup } \_public \readbibs ; \_doc ----------------------------- The \`\_nextat` macro skips the text in the `.bib` file to the next `@`, and starts the \`\_bibentry` macro which reads `@{}` from the `.bib` file. Each reference entry is converted to the \`\_entrydata` macro and then `\_glet \_be:/