diff --git a/news/changelog-1.11.md b/news/changelog-1.11.md index 06d62dd6e3..056cf58f4a 100644 --- a/news/changelog-1.11.md +++ b/news/changelog-1.11.md @@ -82,6 +82,7 @@ All changes included in 1.11: - ([#15128](https://github.com/quarto-dev/quarto-cli/pull/15128)): Fix Google Scholar metadata missing references with a YAML bibliography not wrapped in `---` delimiters. - ([#15131](https://github.com/quarto-dev/quarto-cli/issues/15131)): Fix the light/dark toggle appearing, with no dark styles to switch to, when the `dark` brand file holds only comments and is ignored. - ([#15207](https://github.com/quarto-dev/quarto-cli/issues/15207)): Fix the BibTeX citation in the HTML appendix showing a copy button that does nothing when `code-copy: false` is set. +- ([#15210](https://github.com/quarto-dev/quarto-cli/issues/15210)): Fix the BibTeX citation in the HTML appendix showing and copying altered text when the title contains text that looks like an HTML entity, such as `<` or `R¬ebook`. ### `pdf` diff --git a/src/format/html/format-html-shared.ts b/src/format/html/format-html-shared.ts index 30456afc92..c9a3774134 100644 --- a/src/format/html/format-html-shared.ts +++ b/src/format/html/format-html-shared.ts @@ -30,6 +30,7 @@ import { Document, Element } from "../../core/deno-dom.ts"; import { normalizePath } from "../../core/path.ts"; import { formatHasBootstrap } from "./format-html-info.ts"; import { HtmlFormatFeatureDefaults } from "./format-html-types.ts"; +import { normalizeNewlines } from "../../core/text.ts"; // features that are enabled by default for 'html'. setting // all of these to false will yield the minimal html output @@ -516,7 +517,7 @@ export function createCodeCopyButton(doc: Document, format: Format) { export function createCodeBlock( doc: Document, - htmlContents: string, + text: string, language?: string, ) { const preEl = doc.createElement("PRE"); @@ -527,7 +528,7 @@ export function createCodeBlock( if (language) { codeEl.classList.add(language); } - codeEl.innerHTML = htmlContents; + codeEl.textContent = normalizeNewlines(text); preEl.appendChild(codeEl); return preEl; } diff --git a/tests/docs/smoke-all/2026/10/16/citation-title/bibtex-entity-literals.qmd b/tests/docs/smoke-all/2026/10/16/citation-title/bibtex-entity-literals.qmd new file mode 100644 index 0000000000..a61520b147 --- /dev/null +++ b/tests/docs/smoke-all/2026/10/16/citation-title/bibtex-entity-literals.qmd @@ -0,0 +1,19 @@ +--- +title: 'Tags a&lt;b and x&amp;nbsp;y' +author: Jane Doe +date: 2025-04-30 +citation: true +appendix-cite-as: [bibtex] +format: html +_quarto: + tests: + html: + ensureFileRegexMatches: + - ['title = \{Tags a\\&lt;b and x\\&amp;nbsp;y\}'] + # Pandoc writes CRLF on Windows; the block must keep LF line endings + - ['\r'] +--- + +The BibTeX appendix block shows the Pandoc biblatex output as text. The title text `a<b` becomes `a\<b` in BibTeX and must not display as `a\