add support for GFM inline math delimiters

This commit is contained in:
alam00000
2026-10-31 16:16:23 +05:30
parent d03594a09d
commit 2a8ce12b6e
2 changed files with 9 additions and 1 deletions
+1
View File
@@ -84,6 +84,7 @@ const ESCAPED_MATH: ReadonlyArray<[string, string, boolean]> = [
['\\\\[', '\\\\]', true],
['\\\\(', '\\\\)', false],
['\\[', '\\]', true],
['$`', '`$', false],
];
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```',
'',
'GitHub $`\\sqrt{3}`$ inline.',
'',
'Price $5 and $10, escaped \\$3, code `$q$`.',
].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.querySelector('em')).toBeNull();
expect(root.textContent).toContain('Price $5 and $10, escaped $3');