Skip to content

Commit ad06e01

Browse files
authored
Fix shortcodes not resolving inside math expressions (#14279)
* fix: resolve shortcodes inside math expressions Shortcodes inside inline and display math (e.g., `$5 + {{< meta five >}}$`) were not being resolved, producing hex-encoded UUID placeholders in output. Two gaps in the pipeline both lacked Math node handlers: the UUID restoration walker in readqmd.lua and the shortcode resolution filter in shortcodes.lua. Fixes #14255 * docs: add changelog entry for #14255
1 parent 94ebb7f commit ad06e01

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

news/changelog-1.10.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ All changes included in 1.10:
1919
## Other fixes and improvements
2020

2121
- ([#6651](https://github.com/quarto-dev/quarto-cli/issues/6651)): Fix dart-sass compilation failing in enterprise environments where `.bat` files are blocked by group policy.
22+
- ([#14255](https://github.com/quarto-dev/quarto-cli/issues/14255)): Fix shortcodes inside inline and display math expressions not being resolved.
2223

src/resources/filters/customnodes/shortcodes.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@ function shortcodes_filter()
325325
doc = _quarto.ast.walk(doc, {
326326
Shortcode = inline_handler,
327327
RawInline = code_handler,
328+
Math = function(el)
329+
el.text = apply_code_shortcode(el.text)
330+
return el
331+
end,
328332
Image = function(el)
329333
el = attr_handler(el)
330334
el.src = apply_code_shortcode(el.src)

src/resources/pandoc/datadir/readqmd.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ local function readqmd(txt, opts)
192192
Code = unshortcode_text,
193193
RawInline = unshortcode_text,
194194
RawBlock = unshortcode_text,
195+
Math = unshortcode_text,
195196
Header = filter_attrs,
196197
Span = filter_attrs,
197198
Div = filter_attrs,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Shortcode in Math
3+
format: html
4+
five: 5
5+
_quarto:
6+
tests:
7+
html:
8+
ensureFileRegexMatches:
9+
- ['5 \+ 5']
10+
- ['b58fc729|7B7B3C']
11+
---
12+
13+
Inline: $5 + {{< meta five >}}$
14+
15+
Display: $$5 + {{< meta five >}}$$
16+
17+
Plain: {{< meta five >}}

0 commit comments

Comments
 (0)