Repository navigation
Improve BibTeX parsing and bibliography rendering - #573
Conversation
|
PS: I'm tempted to have a clanker improve the parsing of bibtex to support (a) emphasis, in notes, (b) {} in titles to prevent lowercasification when using LaTeX. Also, maybe to improve autobib so multi-paragraph notes are a thing, and maybe crossing page boundaries within a bibliography entry. These two would also much improve LtUO. PPS: I'm still thinking about (a), but at least the basics of (b) was apparently done by #571. PPPS: The clankers did it! |
|
Weird: the CI failed on Racket 9.3.0.8, but at home it just worked on v9.3.0.8-2026-09-14-06fd59e02c [cs]. PS: I had forgotten to update a test. |
|
The change to add |
|
Yes, adding a "." only if there's a note makes a lot sense, especially for backwards compatibility. Thanks for the suggestion. PS: also rebasing to the latest master. |
Much improves the bibliography for my book LtUO.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 1 file in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 2 files in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 3 files in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 3 files in this pull request and found no issues.
Use CSS and LaTeX environments for autobib number-style. Much nicer output in HTML and PDF. In number-style, text output won't align as a table anymore, but will have a space after the [number].
There was a problem hiding this comment.
Resyntax analyzed 4 files in this pull request and found no issues.
|
The ability to return Returning content instead of element also seemed more practical to me, considering that the output has a loose structure and is meant to be further aggregated into bigger lists. It seemed to me that at that point, if we really wanted an element, we could better add one in the caller when the content is not #f. But I'm not sure I understand the invariants of Scribble with respect to element vs content vs decoded-content vs blocks vs passes, etc., so I admit I don't really know. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and found no issues.
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and has added suggestions.
I can appreciate why
There shouldn't be a difference between content |
mflatt wants the *-location functions to keep returning elements rather than generic content, for backward compatibility. Wrap each non-#f result in (elem ...); the split between functions that may return #f (booklet-location, manual-location, misc-location, book-location, and now also proceedings-location, since bibtex may call it with nothing at all) and those that always return a non-#f element? (journal-location, techrpt-location, dissertation-location, book-chapter-location, since each has a genuinely required argument) now matches origin/master exactly, confirmed by diffing against it. Drop the stray docs claiming location helpers "now return Scribble content, potentially #f" -- that phase never shipped outside this branch, so there's nothing to document as a change. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Enforce, as hard parse-time errors, the fields Patashnik's BIBTEXing §3.1 marks required for each of the 14 standard entry types, including the author-or-editor and chapter-and/or-pages disjunctions (new require-one-of helper). Also require title and url on online/webpage, by our own choice since neither is a standard type. This is intentionally stricter than real BibTeX, which only warns on a missing required field; document why. Fix a latent bug found along the way: author-attr silently turned a genuinely missing field into the literal author name "#f" instead of most entry types, author on booklet/manual/misc/online/webpage). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
bibtex.rkt always calls the functions, even when all the arguments are missing. I suppose I could make it avoid to do so, but I think it's better to have the function itself deal with it. booklet-location, manual-location, misc-location, and proceedings-location can be legitimately contentless (based on BIBTEXing as a spec). I am now allowing #f only from those functions. Then again, a lot of bibliography databases do NOT fill the mandatory fields from that "specification", and bibtex is quite lenient in practice, so I'm not sure tightening the screw is the right thing (though tightening did lead me to fix a few entries in my own database). If you want bibtex.rkt to instead avoid calling the location functions when it has no data for them, I can do that. I added back Docs updated. |
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and has added suggestions.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and has added suggestions.
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and found no issues.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and found no issues.
Ok, that seems reasonable. Maybe the most useful thing would be to improve the specification to say more specifically when the result is
Thanks! |
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and found no issues.
|
Clarified the documentation, made the code more systematic about what is optional or required and normalizing content, fixed a few edge cases. |
There was a problem hiding this comment.
Resyntax analyzed 7 files in this pull request and found no issues.
|
This seems ready to me. I would adjust the history notes slightly as in mflatt@785dbcc, but I can make those adjustments after. Ok to merge? |
|
Eager to merge! Thanks a lot for your gracious time and welcome. |
|
I suggest a squash with the PR description—I don't think the sausage of intermediate commits is worth preserving. |
Improve bibliography rendering and BibTeX support
Improve Scribble's support for rich bibliographies, particularly annotated bibliographies with long, formatted, multi-paragraph notes. The immediate motivation is the bibliography of my book Lambda: the Ultimate Object, but the improvements apply to ordinary academic papers as well.
Bibliography rendering
\parboxlayout, which prevented page breaks within bibliography entries, withneedspace, allowing long annotations to span pages.needspacewhen available instead of\parboxto still try to keep short entries together.\AutobibEntrySetupfor e.g. line-breaking settings.#:accessedfield tomake-bib, displayedimmediately after the URL, when one is displayed.
BibTeX
onlineandwebpageentries now use this fieldinstead of putting access dates in their location.
This places access dates after publication dates and
next to the URLs they qualify, without changing the
generic ordering of bibliography fields.
The
webpage-locationAPI from 1.61 is removed.The improvements primarily target HTML and LaTeX. Typst receives minimal compatibility support rather than a new rendering implementation.
BibTeX parsing
The reader deliberately supports a useful subset of LaTeX rather than attempting to implement a complete TeX interpreter. Unknown commands are preserved rather than silently discarded.
API, documentation and tests
#:accessedtomake-bib; access dates are displayed only when the corresponding URL is displayed. DOI still takes precedence over URL.#fwhen they contain no information. This lets callers omit empty components entirely rather than retaining opaque empty elements that can cause stray separators and punctuation.scribble-libto version 1.68.The changes have been exercised against my book's heavily annotated bibliography and reviewed through several rounds of automated and manual testing.
Compatibility notes
webpage-locationis removed. It was a recent addition from 1.61, I'm not sure anyone uses it directly (as opposed to through bibtex.rkt), but if they do they will have to migrate to#:accessedinstead.bibtex-parsenow keeps inner braces in raw field values(e.g. "The {ACM} Paper") so that protected groups survive until
rendering; rendered output is unchanged, but code that reads
bibdb-rawdirectly will now see the braces.they go through the same reader as other fields. Math and unknown
commands are still emitted verbatim in LaTeX output.
--becomesan en dash and straight quotes become curly quotes.
#:chapternow renders as "chapter N".the five-line minimum), and numbered bibliographies use hanging
indentation instead of a table.
The implementation was substantially assisted by GPT-5.6 Sol and Claude Sonnet 5, with additional review by Claude Opus 5.5.