Repository navigation
Fix BibTeX citation decoding HTML entities in the HTML appendix - #15212
Merged
Merged
Conversation
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
The BibTeX block in the HTML appendix holds the plain-text output of `pandoc -t biblatex`, but createCodeBlock assigned it to innerHTML. The HTML parser then decoded any `&` sequence forming an entity: Pandoc's `R\¬ebook` displayed as `R\¬ebook` (legacy `¬` without semicolon), `a\<b` as `a\<b`, `x\&nbsp;y` as `x\ y`. The copy button copied the same decoded text. A raw `<` never reaches the parser because the biblatex writer emits `\textless`, so `&` is the only trigger. innerHTML dates from the original appendix DIV; the BibTeX string has never carried markup, and the appendix block is createCodeBlock's only caller, so the helper now sets textContent. The existing entity-literals fixture now asserts the R\¬ebook case. Its `&nbsp;` case only passed because title-casing turns it into the non-entity `&Nbsp;`, so a new fixture covers `<` and `&nbsp;` in words title-casing leaves alone.
Pandoc writes its biblatex output with CRLF on Windows. innerHTML went through the HTML parser, which normalizes CRLF to LF; textContent keeps the carriage returns, so the rendered page had CRLF lines inside the BibTeX block and LF everywhere else. Browsers normalize again on load, so display and copy were unaffected, but the output file bytes changed. normalizeNewlines splits on the same `\r\n?|\n` set as the HTML parser, so the block's text is now byte-identical to the innerHTML result for any BibTeX without `&` entity sequences: rendering the 19 citation smoke-all fixtures with and without the change differs only in the two entity-literal titles.
cderv
force-pushed
the
fix-bibtex-entity-encoding
branch
from
October 27, 2026 15:34
cd94f7a to
04e8bac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a document title contains text that looks like an HTML entity, the BibTeX citation in the HTML appendix does not show the BibTeX Pandoc produced.
R\¬ebookdisplays asR\¬ebook,a\<basa\<b, and the copy button copies this altered text.Root cause
The BibTeX is the plain text output of
pandoc -t biblatex, butcreateCodeBlockinserted it withinnerHTML, so the HTML parser decoded any&sequence forming an entity, including legacy ones without semicolon like¬.innerHTMLcomes from the original appendix block and the BibTeX string never carried markup. A<in the title is not affected as Pandoc writes it\textless.Fix
createCodeBlocknow sets the text content of the code block. The appendix BibTeX block is its only caller.Setting text skips the HTML parser's newline normalization too, and Pandoc writes CRLF on Windows, so the text goes through
normalizeNewlinesto keep the LF line endings the block had. Rendering the 19 citation smoke-all documents with and without the change gives identical HTML, apart from the two titles with entity-like text.createCodeBlockis also modified by #15209, which may need a small rebase depending on merge order.Fixes #15210
Checklist
I have (if applicable):
AI-assisted PR
Note: autonomous AI agents submitting PRs without human oversight are not permitted — see the Code of Conduct.