Fix equation labels, Pandoc ref attributes, and image caption artifacts#2
Conversation
- Strip \label{} commands from display math blocks (both before closing $$
and after opening $$), fixing ~366 occurrences of raw LaTeX labels in
MathJax equations. Use targeted pattern matching instead of fragile
$$...$$ block matching to avoid false matches from adjacent inline math.
- Strip Pandoc {reference-type="ref" reference="..."} attribute spans
(~476 occurrences) and unescape bracket notation in ref link text.
- Clean empty [] bracket artifacts in image alt text (~11 occurrences).
https://claude.ai/code/session_01AxQpFdDAmHAXuZcjgjjGiC
Replace the single-pass regex-based bracket macro expansion with a
recursive stack-based approach that properly handles arbitrary brace
nesting depth. The old regex could only match one level of nested
braces, leaving macros like \PB{\frac{\dot{m}_{a}}{\dot{m}_{b}}}
unexpanded (21 occurrences across 8 files). The new implementation
uses a brace-counting parser that recursively expands inner macros
first, eliminating all remaining instances.
https://claude.ai/code/session_01AxQpFdDAmHAXuZcjgjjGiC
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5272e10bb0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| text = re.sub(r"(\$\$)\\label\{[^}]+\}\s*", r"\1", text) | ||
| # Strip <a id="..."></a> anchors inside equation blocks | ||
| # These appear on a line between $$ markers | ||
| text = re.sub(r'(<a id="[^"]+"></a>)\s*\n\n\$\$', "\n$$", text) |
There was a problem hiding this comment.
Preserve equation anchors before display-math blocks
clean_equation_labels now removes any <a id="..."></a> followed by \n\n$$, but RawBlock in scripts/pandoc_filters/energyplus.lua intentionally emits labeled equations/align blocks in exactly that form (<a id="label"></a>\n\n$$...). This strips the only in-page anchor for equation labels, so references that end up as (#label) (including the links normalized by clean_pandoc_ref_attributes) become dead links for labeled equations.
Useful? React with 👍 / 👎.
and after opening $$), fixing ~366 occurrences of raw LaTeX labels in
MathJax equations. Use targeted pattern matching instead of fragile
(~476 occurrences) and unescape bracket notation in ref link text.
https://claude.ai/code/session_01AxQpFdDAmHAXuZcjgjjGiC