Skip to content

Commit 2c89bd9

Browse files
authored
Fix inline code in dashboard card titles being moved out of position (#14647)
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.
1 parent 534242e commit 2c89bd9

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

‎news/changelog-1.10.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ All changes included in 1.10:
4444
- ([#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)
4545
- ([#14585](https://github.com/quarto-dev/quarto-cli/issues/14585)): Fix empty blockquote (`> `) crashing render for revealjs format.
4646

47+
### `dashboard`
48+
49+
- ([#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).
50+
4751
## Projects
4852

4953
### Manuscripts

‎src/format/dashboard/format-dashboard-card.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) {
159159
const isText = (node: Node) => node.nodeType === Node.TEXT_NODE;
160160
const isEmphasis = (node: Node) => node.nodeName === "EM";
161161
const isBold = (node: Node) => node.nodeName === "STRONG";
162+
const isCode = (node: Node) => node.nodeName === "CODE";
162163
const isMath = (node: Node) =>
163164
node.nodeName === "SPAN" &&
164165
(node as Element).classList.contains("math") &&
@@ -169,6 +170,7 @@ export function processCards(doc: Document, dashboardMeta: DashboardMeta) {
169170
(isText(headerChildNode) ||
170171
isEmphasis(headerChildNode) ||
171172
isBold(headerChildNode) ||
173+
isCode(headerChildNode) ||
172174
isMath(headerChildNode)) &&
173175
headerChildNode.textContent.trim() !== ""
174176
) {
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: "Card titles with inline code (issue #14646)"
3+
format: dashboard
4+
_quarto:
5+
tests:
6+
dashboard:
7+
ensureHtmlElements:
8+
-
9+
- ".test-attr-code .card-title code"
10+
- ".cell .card-title code"
11+
- ".test-combined .card-title code"
12+
-
13+
- ".test-attr-code .card-header > code"
14+
- ".cell .card-header > code"
15+
- ".test-combined .card-header > code"
16+
- ".test-combined .card-header > span.math.inline"
17+
- ".test-combined .card-header > em"
18+
- ".test-combined .card-header > strong"
19+
---
20+
21+
Regression test for #14646. Inline verbatim code (backtick) formatting in
22+
dashboard card titles was extracted from its original position and appended
23+
after the rest of the title text, instead of staying inline where it was
24+
written — the same bug previously fixed for math, emphasis and bold in
25+
#10340. The card `title` attribute and the executable cell `title` option
26+
both build the card header through the same code path, so both forms are
27+
covered here. Each card carries its own scoping class (or relies on the
28+
executable cell's implicit `.cell` class) so a failure in one card cannot
29+
be masked by another card's passing assertion.
30+
31+
## card title attribute
32+
33+
::: {.card .test-attr-code title="Inline `code` between words"}
34+
35+
:::
36+
37+
## executable cell title option
38+
39+
```{python}
40+
#| title: "Inline `code` between words"
41+
1 + 1
42+
```
43+
44+
## combined formatting
45+
46+
Code alongside math, emphasis and bold in the same title exercises the
47+
same loose-text extraction loop that #10340 covers without code.
48+
49+
::: {.card .test-combined title="`code`, $math$, *em*, and **bold** together"}
50+
51+
:::

0 commit comments

Comments
 (0)