Skip to content

Commit 306b346

Browse files
fix: theorem/example block titles with inline code produce invalid Typst markup
Use content brackets [...] instead of string quotes "..." when passing the title argument to Typst theorem functions, so that syntax-highlighted inline code (e.g. #NormalTok(...)) is valid in that position. Fixes #14261
1 parent 2f1d73d commit 306b346

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

news/changelog-1.10.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
All changes included in 1.10:
22

3+
## Formats
4+
5+
### `typst`
6+
7+
- ([#14261](https://github.com/quarto-dev/quarto-cli/issues/14261)): Fix theorem/example block titles containing inline code producing invalid Typst markup when syntax highlighting is applied.
38

src/resources/filters/customnodes/theorem.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ end, function(thm)
259259
ensure_typst_theorems(type)
260260
local preamble = pandoc.Plain({pandoc.RawInline("typst", "#" .. theorem_type.env .. "(")})
261261
if name and #name > 0 then
262-
preamble.content:insert(pandoc.RawInline("typst", 'title: "'))
262+
preamble.content:insert(pandoc.RawInline("typst", 'title: ['))
263263
tappend(preamble.content, name)
264-
preamble.content:insert(pandoc.RawInline("typst", '"'))
264+
preamble.content:insert(pandoc.RawInline("typst", ']'))
265265
end
266266
preamble.content:insert(pandoc.RawInline("typst", ")["))
267267
local callthm = make_scaffold(pandoc.Div, preamble)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
format:
3+
typst:
4+
keep-typ: true
5+
_quarto:
6+
tests:
7+
typst:
8+
ensureTypstFileRegexMatches:
9+
-
10+
- "title: \\["
11+
-
12+
- "\\(title: \""
13+
---
14+
15+
# Theorem Test - Inline Code in Title
16+
17+
::: {#exm-devtools}
18+
19+
## `devtools`
20+
21+
A useful package for R developers.
22+
23+
```r
24+
install.packages("devtools")
25+
```
26+
27+
:::
28+
29+
::: {#thm-bayes}
30+
31+
## `P(A|B)` = Bayes' Rule
32+
33+
If $P(B) > 0$, then $P(A|B) = \frac{P(B|A)P(A)}{P(B)}$.
34+
35+
:::
36+
37+
See @exm-devtools and @thm-bayes.

0 commit comments

Comments
 (0)