Skip to content

Fix shortcodes not resolving inside math expressions#14279

Merged
cscheid merged 2 commits intomainfrom
fix/issue-14255
Mar 30, 2026
Merged

Fix shortcodes not resolving inside math expressions#14279
cscheid merged 2 commits intomainfrom
fix/issue-14255

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Mar 28, 2026

When using shortcodes inside inline or display math (e.g., $5 + {{< meta five >}}$), the output contains hex-encoded UUID placeholders instead of the resolved shortcode value.

Root Cause

The two-stage shortcode encoding (introduced for Pandoc 3.7+ compatibility) converts shortcodes to UUID-guarded hex strings before pandoc.read(), then restores them afterward. The restoration walker in readqmd.lua and the shortcode resolution filter in shortcodes.lua both handle Code, RawInline, RawBlock, and Str nodes — but neither handles Math nodes. Since Pandoc parses $5 + UUID;HEX;$ into a Math node with the placeholder in its .text field, the shortcode is never restored or resolved.

Fix

Add Math node handlers to both pipeline stages:

  1. readqmd.lua: restore hex-encoded shortcode text back to {{< ... >}} syntax (reuses existing unshortcode_text)
  2. shortcodes.lua: resolve shortcodes to their values inside math text (reuses existing apply_code_shortcode)

Both inline ($...$) and display ($$...$$) math are covered by the single Math handler, since Pandoc uses one node type with a mathtype discriminator.

Fixes #14255

cderv added 2 commits March 28, 2026 14:23
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
@cscheid cscheid merged commit ad06e01 into main Mar 30, 2026
51 checks passed
@cscheid cscheid deleted the fix/issue-14255 branch March 30, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shortcode in Latex inline math doesn't get rendered

2 participants