From a820863e8bdaafe336213d00529d9295bbf1f1d3 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Tue, 26 Aug 2025 23:33:56 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=B2=20fix:=20Prevent=20Single-dollar?= =?UTF-8?q?=20LaTeX=20for=20abbrev.=20Currency=20(K,=20M,=20B)=20(#9293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/utils/latex.spec.ts | 12 ++++++++++++ client/src/utils/latex.ts | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/client/src/utils/latex.spec.ts b/client/src/utils/latex.spec.ts index d223edbd8e..f044f4de53 100644 --- a/client/src/utils/latex.spec.ts +++ b/client/src/utils/latex.spec.ts @@ -239,4 +239,16 @@ y$ which spans lines`; const expected = 'Bitcoin: \\$0.00001234, Gas: \\$3.999, Rate: \\$1.234567890'; expect(preprocessLaTeX(content)).toBe(expected); }); + + test('escapes abbreviated currency notation', () => { + const content = '$250k is 25% of $1M'; + const expected = '\\$250k is 25% of \\$1M'; + expect(preprocessLaTeX(content)).toBe(expected); + }); + + test('handles various abbreviated currency formats', () => { + const content = 'Revenue: $5M to $10M, funding: $1.5B, price: $5K'; + const expected = 'Revenue: \\$5M to \\$10M, funding: \\$1.5B, price: \\$5K'; + expect(preprocessLaTeX(content)).toBe(expected); + }); }); diff --git a/client/src/utils/latex.ts b/client/src/utils/latex.ts index 11438245c1..4467c2a5e3 100644 --- a/client/src/utils/latex.ts +++ b/client/src/utils/latex.ts @@ -3,7 +3,8 @@ const MHCHEM_CE_REGEX = /\$\\ce\{/g; const MHCHEM_PU_REGEX = /\$\\pu\{/g; const MHCHEM_CE_ESCAPED_REGEX = /\$\\\\ce\{[^}]*\}\$/g; const MHCHEM_PU_ESCAPED_REGEX = /\$\\\\pu\{[^}]*\}\$/g; -const CURRENCY_REGEX = /(?