@devries-cameron20 / t3code-1 / commits / ece8fd8e8c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(markdown): an escaped backslash before \( no longer crashes dev builds (#22893)

Co-authored-by: maria-rcks <maria@kuuro.net>

Nikita Maximilian Grimm committed Oct 30, 2026 at 21:43 UTC ece8fd8e8c6f58eabcbf91d4f550f787e22284ff
3 files changed +22 -3
packages/shared/src/markdownMath.test.ts
+9
@@ -193,6 +193,15 @@ describe("chat math parsing", () => {
193 expect(formulas("Pay \\$$x$ now.")).toEqual([["inline", "x"]]);
194 });
195
196 + it("starts a formula right after an escaped backslash", () => {
197 + const markdown = "Path \\\\\\(x^2\\) and \\\\\\[y\\].";
198 + expect(formulas(markdown)).toEqual([
199 + ["inline", "x^2"],
200 + ["display", "y"],
201 + ]);
202 + expect(text(markdown)).toBe("Path \\ and \\.");
203 + });
204 +
205 it.each([
206 ["$a`$HOME`", "$HOME"],
207 ["\\(a`\\)`", "\\)"],
patches/micromark-extension-llm-math@3.1.0.patch
+10
@@ -232,6 +232,16 @@ diff --git a/dev/lib/math-tex-text.js b/dev/lib/math-tex-text.js
232 effects.consume(code)
233 effects.exit('mathTextSequence')
234 effects.exit('mathText')
235 +@@ -180,5 +184,8 @@
236 + */
237 + function previous(code) {
238 + // If there is a previous code, there will always be a tail.
239 +- return code !== codes.backslash
240 ++ return (
241 ++ code !== codes.backslash ||
242 ++ this.events[this.events.length - 1][1].type === types.characterEscape
243 ++ )
244 + }
245 diff --git a/dev/lib/math-text.js b/dev/lib/math-text.js
246 --- a/dev/lib/math-text.js
247 +++ b/dev/lib/math-text.js
pnpm-lock.yaml
+3 -3
@@ -383,7 +383,7 @@ patchedDependencies:
383 mdast-util-math@3.0.0: afe6b2c89e1eaddfd3c90cf2723f12c9a17d513e65beff51653781486013251c
384 mdast-util-to-hast@13.2.1: 57ea46c73aea3c876ab8d351fe0482ddd081dcb4a0610576e399dbe5eb59d2b1
385 micromark-extension-gfm-table@2.1.1: 9ad23a530e45d9f83cba1da8654fe16d5af8b59d5c73d5c7a7c91fd25b9be1d8
386 - micromark-extension-llm-math@3.1.0: 7beb6ac4ba52166286593a494531aace81547e55fdddecf892824c25bd84d15a
386 + micromark-extension-llm-math@3.1.0: 4eeb9d9e27ebc75e98795e21c0719005483dad7d233055698257f7d10e91603b
387 micromark@4.0.2: cb79edde7eca83bbcaaafb6ceb7b044b81b987314cde4910823b15257ecada67
388 node-pty@1.2.0-beta.15: f1e680afec85f650699ea756f91f469844ec4c976f4f168492a45c6b3f67d651
389 react-native-gesture-handler@3.3.0: abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626
@@ -20161,7 +20161,7 @@ snapshots:
20161 micromark-util-combine-extensions: 2.0.1
20162 micromark-util-types: 2.0.2
20163
20164 - micromark-extension-llm-math@3.1.0(patch_hash=7beb6ac4ba52166286593a494531aace81547e55fdddecf892824c25bd84d15a):
20164 + micromark-extension-llm-math@3.1.0(patch_hash=4eeb9d9e27ebc75e98795e21c0719005483dad7d233055698257f7d10e91603b):
20165 dependencies:
20166 '@types/katex': 0.16.8
20167 devlop: 1.1.0
@@ -21453,7 +21453,7 @@ snapshots:
21453 dependencies:
21454 '@types/mdast': 4.0.4
21455 mdast-util-math: 3.0.0(patch_hash=afe6b2c89e1eaddfd3c90cf2723f12c9a17d513e65beff51653781486013251c)(supports-color@8.1.1)
21456 - micromark-extension-math: micromark-extension-llm-math@3.1.0(patch_hash=7beb6ac4ba52166286593a494531aace81547e55fdddecf892824c25bd84d15a)
21456 + micromark-extension-math: micromark-extension-llm-math@3.1.0(patch_hash=4eeb9d9e27ebc75e98795e21c0719005483dad7d233055698257f7d10e91603b)
21457 unified: 11.0.5
21458 transitivePeerDependencies:
21459 - supports-color