add support for GFM inline math delimiters

This commit is contained in:
alam00000 committed 2026-10-31 16:16:23 +05:30
1 parent d03594a09d
commit 2a8ce12b6e
2 files changed
+9 -1

No files matched your search

+1
View File
@@ -84,6 +84,7 @@ const ESCAPED_MATH: ReadonlyArray<[string, string, boolean]> = [
['\\\\[', '\\\\]', true], ['\\\\[', '\\\\]', true],
['\\\\(', '\\\\)', false], ['\\\\(', '\\\\)', false],
['\\[', '\\]', true], ['\\[', '\\]', true],
['$`', '`$', false],
]; ];
function escapedMath(state: StateInline, silent: boolean): boolean { function escapedMath(state: StateInline, silent: boolean): boolean {
+8 -1
View File
@@ -58,10 +58,17 @@ describe('Markdown to PDF rendering', () => {
'', '',
'```math\n\\int x\n```', '```math\n\\int x\n```',
'', '',
'GitHub $`\\sqrt{3}`$ inline.',
'',
'Price $5 and $10, escaped \\$3, code `$q$`.', 'Price $5 and $10, escaped \\$3, code `$q$`.',
].join('\n') ].join('\n')
); );
expect(root.querySelectorAll('.katex').length).toBe(8); expect(root.querySelectorAll('.katex').length).toBe(9);
const github = [...root.querySelectorAll('p')].find((p) =>
p.textContent?.startsWith('GitHub')
);
expect(github?.querySelector('.katex')).not.toBeNull();
expect(github?.textContent).not.toMatch(/[$`‘’]/);
expect(root.querySelectorAll('.katex-display').length).toBe(5); expect(root.querySelectorAll('.katex-display').length).toBe(5);
expect(root.querySelector('em')).toBeNull(); expect(root.querySelector('em')).toBeNull();
expect(root.textContent).toContain('Price $5 and $10, escaped $3'); expect(root.textContent).toContain('Price $5 and $10, escaped $3');