4 BibTeX Bibliographies
| (require scriblib/bibtex) | package: scribble-lib |
This library supports parsing BibTeX .bib files.
We support the 14 standard BibTeX entry types documented in Oren Patashnik’s BIBTEXing (February 8, 1988), §3.1 "Entry Types" — the definitive reference for classic BibTeX, which updates Appendix B.2 of Leslie Lamport’s LaTeX: A Document Preparation System (1986): article, book, booklet, conference, inbook, incollection, inproceedings, manual, mastersthesis, misc, phdthesis, proceedings, techreport, and unpublished.
Human-readable BibTeX fields are converted from a subset of LaTeX syntax into Scribble content. This includes grouping braces, common accent and special-letter commands, \emph, \texttt, \textit, \textbf, \textsc and \url.
Grouping braces are preserved internally where relevant to BibTeX name parsing. Unknown LaTeX commands and their attached arguments are retained rather than discarded. Inline and display mathematics are preserved in LaTeX syntax; other backends do not translate them into native mathematical expressions.
Blank lines in note fields separate paragraphs.
The url and doi fields are interpreted as scalar strings rather than general LaTeX content. Enclosing brace groups are removed and conventional LaTeX escapes for special URL characters, such as \_, \% and \&, are unescaped. Other LaTeX commands are not interpreted in these fields.
We fail to process month.
We only support pages fields that have decimal numbers separated by one or more dashes.
We fail to process the type optional field of incollection.
We do not at this time support the non-standard but often seen fields isbn, issn, nor any other non-standard field except those described below.
article: author, title, journal, year.
book: author or editor, title, publisher, year.
booklet: title.
conference: same as inproceedings.
inbook: author or editor, title, chapter and/or pages, publisher, year.
incollection: author, title, booktitle, publisher, year.
inproceedings: author, title, booktitle, year.
manual: title.
mastersthesis: author, title, school, year.
misc: none.
phdthesis: author, title, school, year.
proceedings: title, year.
techreport: author, title, institution, year.
unpublished: author, title, note (no year).
Note that this is stricter than classic BibTeX itself: per BIBTEXing, "required" is a property of the standard bibliography styles, not a constraint on the .bib file format itself — a real BibTeX run only warns about a missing required field and still processes the entry, however poorly formatted the result. We chose to make it a hard error here instead, on the theory that a citation silently missing its journal or its year is worse than one that fails to build at all.
In addition to the 14 standard entries, we support the often seen online and webpage entry types, for which we support the fields url, title, author. Additionally online has field urldate for the day the site was visited, whereas webpage instead has field lastchecked. Neither is among BIBTEXing’s standard entry types, so there is no spec to draw a required-fields list from; but by our own choice, title and url are required for both (a webpage citation with neither isn’t a citation), while author stays optional, since most web pages don’t have a clean byline.
Also, for every entry type, we support the extra fields note, url, doi — all optional, except that url is required (see above) for online and webpage, the two entry types it’s actually about. But mind that the doi field currently overrides the url in scriblib/autobib.
We do support the @string feature defined in the format of BibTeX.
Changed in version 1.61 of package scribble-lib: Support all standard entry types plus online and webpage, all fields but month (or type for incollection), and support note, url, doi on all entry types.
Changed in version 1.68 of package scribble-lib: Added structured LaTeX content parsing, improved author-name handling, URL and DOI unescaping, and support for multi-paragraph notes. Started enforcing, as hard parse-time errors, the fields BIBTEXing marks required for each standard entry type (see above), including its author-or-editor and chapter-and/or-pages disjunctions; also require title and url on online and webpage entries, by our own choice rather than any spec. Fixed a latent bug where an editor-only book or inbook entry (valid, since author is not required when editor is given) would silently render a bogus "#f" in place of the missing author’s name.
syntax
(define-bibtex-cite bib-pth ~cite-id citet-id generate-bibliography-id option ...)
(begin (define-cite autobib-cite autobib-citet generate-bibliography-id option ...) (define-bibtex-cite* bib-pth autobib-cite autobib-citet ~cite-id citet-id))
syntax
(define-bibtex-cite* bib-pth autobib-cite autobib-citet ~cite-id citet-id)
Each string is broken along spaces into citations keys that are looked up in the BibTeX database and turned into bib? structures.
procedure
(path->bibdb path) → bibdb?
path : path-string?
procedure
(bibtex-parse ip) → bibdb?
ip : input-port?