mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
💲 fix: Prevent Single-dollar LaTeX for abbrev. Currency (K, M, B) (#9293)
This commit is contained in:
parent
9a210971f5
commit
a820863e8b
2 changed files with 14 additions and 1 deletions
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = /(?<![\\$])\$(?!\$)(?=\d+(?:,\d{3})*(?:\.\d+)?(?:\s|$|[^a-zA-Z\d]))/g;
|
||||
const CURRENCY_REGEX =
|
||||
/(?<![\\$])\$(?!\$)(?=\d+(?:,\d{3})*(?:\.\d+)?(?:[KMBkmb])?(?:\s|$|[^a-zA-Z\d]))/g;
|
||||
const SINGLE_DOLLAR_REGEX = /(?<!\\)\$(?!\$)((?:[^$\n]|\\[$])+?)(?<!\\)(?<!`)\$(?!\$)/g;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue