Fix shortcodes not resolving inside math expressions#14279
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 inreadqmd.luaand the shortcode resolution filter inshortcodes.luaboth handleCode,RawInline,RawBlock, andStrnodes — but neither handlesMathnodes. Since Pandoc parses$5 + UUID;HEX;$into aMathnode with the placeholder in its.textfield, the shortcode is never restored or resolved.Fix
Add
Mathnode handlers to both pipeline stages:readqmd.lua: restore hex-encoded shortcode text back to{{< ... >}}syntax (reuses existingunshortcode_text)shortcodes.lua: resolve shortcodes to their values inside math text (reuses existingapply_code_shortcode)Both inline (
$...$) and display ($$...$$) math are covered by the singleMathhandler, since Pandoc uses one node type with amathtypediscriminator.Fixes #14255