Conversation
WalkthroughThe pull request updates the Arithmatex plugin to detect and ignore escaped bracket sequences ( 📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🔇 Additional comments (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Fix all issues with AI Agents 🤖
In @mdformat_mkdocs/mdit_plugins/_pymd_arithmatex.py:
- Around line 75-97: The rule-wrapping loop that modifies
md.block.ruler.__rules__ is fragile; add runtime validation to ensure the
intended texmath rules were actually wrapped. In the loop that iterates over
md.block.ruler.__rules__ (the block that references found_first_math_block,
rule.name == "math_block", rule.name == "math_block_eqno", and uses
make_wrapper(rule.fn)), increment a wrapped_count each time you replace a
rule.fn with make_wrapper and after the loop assert wrapped_count == 2 (or raise
a RuntimeError with a clear message if less), so that
make_wrapper/_is_escaped_bracket logic only proceeds when both the second
"math_block" and "math_block_eqno" have been found and wrapped.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
mdformat_mkdocs/mdit_plugins/_pymd_arithmatex.py
🔇 Additional comments (4)
mdformat_mkdocs/mdit_plugins/_pymd_arithmatex.py (4)
20-20: LGTM: Imports are necessary and correctly placed.The
remodule andStateBlocktype are both used appropriately in the new code.Also applies to: 29-29
47-57: LGTM: Function logic is sound.The early return for non-
\[lines is an efficient optimization. The function inherits any limitations from_ESCAPED_BRACKET_RE(see previous comment).
65-65: LGTM: Documentation update is clear and appropriate.
41-44: Pattern is intentionally restrictive and working as designed.The regex correctly identifies escaped bracket notation (like
\[label\]: value) that should NOT be processed as math blocks. Cases like\[content\]at line end or followed by whitespace properly fall through to the texmath parser, which is the intended behavior. The(\S)requirement after\]specifically catches the escaped bracket pattern to fix issue #72.
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #72 by adding logic to differentiate between LaTeX math expressions using \[...\] syntax and escaped bracket patterns like \[test\]: value that should not be treated as math.
Key changes:
- Adds a regex pattern and helper function to detect escaped bracket syntax on a single line with non-whitespace content immediately following the closing bracket
- Wraps the texmath plugin's block rules to filter out escaped bracket patterns before processing math blocks
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.