Skip to content

Commit b77ed69

Browse files
committed
Keep LF line endings in the appendix BibTeX block
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.
1 parent 6f5dd9c commit b77ed69

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/format/html/format-html-shared.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Document, Element } from "../../core/deno-dom.ts";
3030
import { normalizePath } from "../../core/path.ts";
3131
import { formatHasBootstrap } from "./format-html-info.ts";
3232
import { HtmlFormatFeatureDefaults } from "./format-html-types.ts";
33+
import { normalizeNewlines } from "../../core/text.ts";
3334

3435
// features that are enabled by default for 'html'. setting
3536
// all of these to false will yield the minimal html output
@@ -527,7 +528,7 @@ export function createCodeBlock(
527528
if (language) {
528529
codeEl.classList.add(language);
529530
}
530-
codeEl.textContent = text;
531+
codeEl.textContent = normalizeNewlines(text);
531532
preEl.appendChild(codeEl);
532533
return preEl;
533534
}

‎tests/docs/smoke-all/2026/10/16/citation-title/bibtex-entity-literals.qmd‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ _quarto:
1010
html:
1111
ensureFileRegexMatches:
1212
- ['title = \{Tags a\\<b and x\\ y\}']
13+
# Pandoc writes CRLF on Windows; the block must keep LF line endings
14+
- ['\r']
1315
---
1416

1517
The BibTeX appendix block shows the Pandoc biblatex output as text. The title text `a&lt;b` becomes `a\&lt;b` in BibTeX and must not display as `a\<b`; `x&amp;nbsp;y` becomes `x\&amp;nbsp;y` and must not display as `x\&nbsp;y`. These words are not title-cased, so the entity-like sequences stay intact.
18+
19+
Pandoc writes the BibTeX with CRLF line endings on Windows; the block keeps LF line endings like the rest of the page.

0 commit comments

Comments
 (0)