Repository navigation
feat: support bracket LaTeX math delimiters - #4
Open
Yash-Singh1 wants to merge 1 commit into
Open
Yash-Singh1 wants to merge 1 commit into
Yash-Singh1 wants to merge 1 commit into
Conversation
6 tasks done
This was referenced Nov 9, 2026
shivamhwp
pushed a commit
to shivamhwp/enriched-markdown
that referenced
this pull request
Nov 9, 2026
Copied line for line from software-mansion#1043 (parser change also in software-mansion-labs/md4c#4) for T3's bracket math; the web WASM bundle is rebuilt in a separate commit. (cherry picked from commit c37b5d3)
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.
What and why
Recognize bracket math delimiters through the existing
ENRMRKD_FLAG_LATEXMATHSPANSextension:\(...\)emits the existing inline math span.\[...\]emits the existing display math span.The parser passes the formula contents verbatim to the existing math callbacks. For example,
Answer: \(x_1 + 1\).can render as inline math instead of ordinary parentheses and underscores.Consumer dependency
software-mansion/enriched-markdown#1043 depends on this parser PR. This needs to merge first; the consumer can then fetch the merged parser through
scripts/fetch-md4c.shand keep its vendored C/H files byte-identical to this fork.This is submitted to Software Mansion's maintained MD4C fork, which supplies Enriched Markdown's prefixed
ENRMRKD_/enrmrkd_parser sources. The consumer PR contains the native/web integration, WASM rebuild, documentation and Android/iOS before/after evidence.Parsing behavior
Bracket math stays within the current Markdown block and preserves block precedence. Doubled backslashes escape delimiters. Unmatched or incomplete delimiters retain ordinary Markdown escape behavior. Failed closer searches are cached per delimiter kind to avoid repeated scans of incomplete input.
This extends the existing math flag. With math enabled, matching escaped parentheses and brackets become math delimiters; with math disabled, ordinary Markdown escaping is unchanged. Existing dollar-delimited math remains supported.
Validation
cdf931f8d2ce4673829eaa69cc2fa90c1bcead09: 1,012 spec examples and 31 pathological cases.76c5fb301d4c952e93c8f9a2be8919d6888555ba, 13 feature regressions fail and 12 controls pass.test/spec-latex-math.txtworkflow.git diff --checkpasses.Generated by GPT-6.1 Sol using the Codex harness.