Skip to content

Commit febf812

Browse files
maria-rcksUmais-Adeed
authored andcommitted
fix(shared): preserve tab-adjacent math delimiters
1 parent 1fd47e7 commit febf812

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎packages/shared/src/markdownMath.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe("chat math parsing", () => {
8383
["$skill budget $20", []],
8484
["$skill formula $x$", ["x"]],
8585
["$skill display $$ x $$", ["x"]],
86+
["$x @README.md\t$", ["x @README.md\t"]],
8687
["$x$ prompt", ["x"]],
8788
["$$x$$", ["x"]],
8889
["\\(x\\)", ["x"]],

‎packages/shared/src/markdownMath.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ export function markdownMathRanges(source: string, tree?: Root) {
5252

5353
/** Messages without these characters skip math parsing entirely. */
5454
function mayContainMath(text: string): boolean {
55-
// Single-dollar math cannot close after whitespace, where serialized skill tokens begin.
55+
// Single-dollar math cannot close after a space or line ending; tabs must reach the parser.
5656
return (
57-
(text.indexOf("$") !== text.lastIndexOf("$") && /\$\$|[^ \t\r\n]\$/.test(text)) ||
57+
(text.indexOf("$") !== text.lastIndexOf("$") && /\$\$|[^ \r\n]\$/.test(text)) ||
5858
text.includes("\\(") ||
5959
text.includes("\\[") ||
6060
/(?:`{3,}|~{3,})[ \t]*math\b/.test(text)

0 commit comments

Comments
 (0)