@devries-cameron20 / t3code Mirror · read-only / commits / 7fc9aa6ed9
Fork 0

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

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 21:00 UTC

fix(shared): typing after a skill chip no longer reparses the prompt as math (#34816)

Julius Marminge committed Nov 11, 2026 at 23:19 UTC 7fc9aa6ed9417e4eff606cf6d1320a8ea2e25b60
1 file changed +20 -1
packages/shared/src/markdownMath.ts
+20 -1
@@ -53,13 +53,32 @@ export function markdownMathRanges(source: string, tree?: Root) {
53 /** Messages without these characters skip math parsing entirely. */
54 function mayContainMath(text: string): boolean {
55 return (
56 - text.includes("$") ||
56 + mayContainDollarMath(text) ||
57 text.includes("\\(") ||
58 text.includes("\\[") ||
59 /(?:`{3,}|~{3,})[ \t]*math\b/.test(text)
60 );
61 }
62
63 +/**
64 + * A `$` formula needs a closing `$` (or the second `$` of `$$`) after another `$` on its line and
65 + * not right after a space (micromark reads a tab as virtual spaces, which still close). So `$skill`
66 + * chips and prices skip the parser.
67 + */
68 +function mayContainDollarMath(text: string): boolean {
69 + let opened = false;
70 + for (let index = 0; index < text.length; index += 1) {
71 + const char = text[index];
72 + if (char === "\n" || char === "\r") {
73 + opened = false;
74 + } else if (char === "$") {
75 + if (opened && text[index - 1] !== " ") return true;
76 + opened = true;
77 + }
78 + }
79 + return false;
80 +}
81 +
82 export function mathKind(className: string | undefined): "inline" | "display" | null {
83 if (!className?.includes("language-math")) return null;
84 if (className.includes("math-display")) return "display";