Repository navigation
Conversation
With latexMath on, only $...$ and $$...$$ became math. Models usually
write \(...\) and \[...\], and the backslash escape turned those into
literal parentheses and brackets, so a formula like
\[A=\begin{pmatrix}1&1\\0&1\end{pmatrix}\] rendered as raw TeX.
md_collect_marks now looks for these delimiters before the escape. The
formula is read as TeX tokens, so \\] does not close it, and resolves
like a code span, keeping its backslashes. To match the remark-math
tokenizer T3 uses on web, a backtick before the closer, or \[...\]
holding only digits, commas and spaces (a citation such as \[1\]), is
not math. A scan that fails records where it stopped, so unclosed
openers in a long paragraph stay linear.
The web WASM bundle still needs a rebuild (yarn build:wasm).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The \(...\) and \[...\] scan runs while marks are collected, before links resolve. An opener inside an inline link's destination or title could find its closer after the link and take it over, so See [docs](https://example.com/\(a) then \(x\). lost the link and rendered "a) then \(x" as math. At a ']' directly followed by '(', with an open '[' earlier in the block, md_collect_marks now reads the inline link spec and starts no math before its end. The link stays a link, as on web, and math after it is still found. The lookahead runs only with latexMath on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
The docs build at A repository administrator needs to approve run 41539041587. The parser follow-up is still under local review, so this PR also has a source update pending. |
|
Thanks for this, and for the careful edge cases. We're closing it in favor of upstream's software-mansion#1043 (with software-mansion-labs/md4c#4), which adds the same delimiters. The fork now carries software-mansion#1043's parser change line for line, so when upstream merges it the next sync has nothing to reconcile. It ships in T3 Code's Your guards for numeric citations ( |
The parser keeps `<br>` in a cell as literal text; a line ending only reaches a cell from a decoded ` `, `
` or ` `. Writing it back as `<br>` changed the cell's content on paste, and `\r` still broke the row. Line endings now go back to ` ` and ` `, so a copied cell matches its source. A backslash run right before one is doubled so it stays literal; a lookbehind keeps long runs linear. The iOS test parses real tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs pingdotgg/t3code#29599.
What's fixed: With
latexMathenabled,\(...\)and\[...\]now produce inline and display math nodes, as dollar delimiters already do. The parser preserves link destinations and titles, code, escaped delimiters, numeric citations, and math disabled. The committed WASM bundle includes the same parser.Evidence: The reported matrix and determinant formulas now produce display math nodes. The native fixture suite passes 35 flag combinations and the rebuilt WASM matches 21 combinations. Regression fixtures also cover formulas after link destinations and titles, including brackets within destinations. Not shown: iOS/iPad and Android typesetting, which will be verified in the consuming T3 Code change before it is marked ready.
Implemented with Claude Opus 5.5 in T3 Code, tested and reviewed with GPT-6.1 Sol in the Codex harness.
Note
Add
\(...\)and\[...\]LaTeX math delimiter parsing to core parsermd_is_latex_delimited_mathin enrmrkd.c that finds the closing delimiter while skipping escaped backslashes and rejecting code-marked or citation-like candidatesmd_collect_marksrecognizes the new delimiter pairs when LaTeX math spans are enabled, andmd_process_inlinesselects inline or display spans via new delimiter mark flags; dollar-delimited forms keep their existing length-based selectionmd4c.jsbinary artifact changed and needs to stay in sync with the C sourcesMacroscope summarized 75316db.