From 90e6dbc4dbf7cd737de7c3096fbf7b0dd1facf9f Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 3 Jul 2026 11:23:47 +0200 Subject: [PATCH] Fix inline code in dashboard card titles being moved out of position (#14646) The card-header loose-text extraction only recognized TEXT_NODE, EM, STRONG and math SPAN as title content to move into the title wrapper (added in #10800 for #10340). A CODE node was never added to that list, so backtick-formatted text stayed behind in card-header while everything else was extracted, landing at the far end of the flex header instead of inline. --- news/changelog-1.10.md | 4 ++ src/format/dashboard/format-dashboard-card.ts | 2 + .../docs/smoke-all/2026/07/03/issue-14646.qmd | 51 +++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 tests/docs/smoke-all/2026/07/03/issue-14646.qmd diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index c26356127d1..7e945c91fba 100644 --- a/news/changelog-1.10.md +++ b/news/changelog-1.10.md @@ -44,6 +44,10 @@ All changes included in 1.10: - ([#14354](https://github.com/quarto-dev/quarto-cli/pull/14354)): Fix trailing whitespace after author name on title slide when ORCID is not set. (author: @jnkatz) - ([#14585](https://github.com/quarto-dev/quarto-cli/issues/14585)): Fix empty blockquote (`> `) crashing render for revealjs format. +### `dashboard` + +- ([#14646](https://github.com/quarto-dev/quarto-cli/issues/14646)): Fix inline code formatting in a dashboard card title being extracted from its original position and appended elsewhere in the header instead of staying inline, the same issue previously fixed for math, emphasis and bold in [#10340](https://github.com/quarto-dev/quarto-cli/issues/10340). + ## Projects ### Manuscripts diff --git a/src/format/dashboard/format-dashboard-card.ts b/src/format/dashboard/format-dashboard-card.ts index 8bcfa228ddc..e7cc8729871 100644 --- a/src/format/dashboard/format-dashboard-card.ts +++ b/src/format/dashboard/format-dashboard-card.ts @@ -159,6 +159,7 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) { const isText = (node: Node) => node.nodeType === Node.TEXT_NODE; const isEmphasis = (node: Node) => node.nodeName === "EM"; const isBold = (node: Node) => node.nodeName === "STRONG"; + const isCode = (node: Node) => node.nodeName === "CODE"; const isMath = (node: Node) => node.nodeName === "SPAN" && (node as Element).classList.contains("math") && @@ -169,6 +170,7 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) { (isText(headerChildNode) || isEmphasis(headerChildNode) || isBold(headerChildNode) || + isCode(headerChildNode) || isMath(headerChildNode)) && headerChildNode.textContent.trim() !== "" ) { diff --git a/tests/docs/smoke-all/2026/07/03/issue-14646.qmd b/tests/docs/smoke-all/2026/07/03/issue-14646.qmd new file mode 100644 index 00000000000..80ba0dffa6c --- /dev/null +++ b/tests/docs/smoke-all/2026/07/03/issue-14646.qmd @@ -0,0 +1,51 @@ +--- +title: "Card titles with inline code (issue #14646)" +format: dashboard +_quarto: + tests: + dashboard: + ensureHtmlElements: + - + - ".test-attr-code .card-title code" + - ".cell .card-title code" + - ".test-combined .card-title code" + - + - ".test-attr-code .card-header > code" + - ".cell .card-header > code" + - ".test-combined .card-header > code" + - ".test-combined .card-header > span.math.inline" + - ".test-combined .card-header > em" + - ".test-combined .card-header > strong" +--- + +Regression test for #14646. Inline verbatim code (backtick) formatting in +dashboard card titles was extracted from its original position and appended +after the rest of the title text, instead of staying inline where it was +written — the same bug previously fixed for math, emphasis and bold in +#10340. The card `title` attribute and the executable cell `title` option +both build the card header through the same code path, so both forms are +covered here. Each card carries its own scoping class (or relies on the +executable cell's implicit `.cell` class) so a failure in one card cannot +be masked by another card's passing assertion. + +## card title attribute + +::: {.card .test-attr-code title="Inline `code` between words"} + +::: + +## executable cell title option + +```{python} +#| title: "Inline `code` between words" +1 + 1 +``` + +## combined formatting + +Code alongside math, emphasis and bold in the same title exercises the +same loose-text extraction loop that #10340 covers without code. + +::: {.card .test-combined title="`code`, $math$, *em*, and **bold** together"} + +:::