diff --git a/news/changelog-1.10.md b/news/changelog-1.10.md index 86270480531..c9abec11908 100644 --- a/news/changelog-1.10.md +++ b/news/changelog-1.10.md @@ -19,4 +19,5 @@ All changes included in 1.10: ## Other fixes and improvements - ([#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. +- ([#14255](https://github.com/quarto-dev/quarto-cli/issues/14255)): Fix shortcodes inside inline and display math expressions not being resolved. diff --git a/src/resources/filters/customnodes/shortcodes.lua b/src/resources/filters/customnodes/shortcodes.lua index 32ad1128e69..9e3ee4c933a 100644 --- a/src/resources/filters/customnodes/shortcodes.lua +++ b/src/resources/filters/customnodes/shortcodes.lua @@ -325,6 +325,10 @@ function shortcodes_filter() doc = _quarto.ast.walk(doc, { Shortcode = inline_handler, RawInline = code_handler, + Math = function(el) + el.text = apply_code_shortcode(el.text) + return el + end, Image = function(el) el = attr_handler(el) el.src = apply_code_shortcode(el.src) diff --git a/src/resources/pandoc/datadir/readqmd.lua b/src/resources/pandoc/datadir/readqmd.lua index 2099edb4b33..30b4cc13dd4 100644 --- a/src/resources/pandoc/datadir/readqmd.lua +++ b/src/resources/pandoc/datadir/readqmd.lua @@ -192,6 +192,7 @@ local function readqmd(txt, opts) Code = unshortcode_text, RawInline = unshortcode_text, RawBlock = unshortcode_text, + Math = unshortcode_text, Header = filter_attrs, Span = filter_attrs, Div = filter_attrs, diff --git a/tests/docs/smoke-all/shortcodes/shortcode-math.qmd b/tests/docs/smoke-all/shortcodes/shortcode-math.qmd new file mode 100644 index 00000000000..b60516ac5f8 --- /dev/null +++ b/tests/docs/smoke-all/shortcodes/shortcode-math.qmd @@ -0,0 +1,17 @@ +--- +title: Shortcode in Math +format: html +five: 5 +_quarto: + tests: + html: + ensureFileRegexMatches: + - ['5 \+ 5'] + - ['b58fc729|7B7B3C'] +--- + +Inline: $5 + {{< meta five >}}$ + +Display: $$5 + {{< meta five >}}$$ + +Plain: {{< meta five >}}