From 2a8ce12b6ea5ccb0d83b4cfb98533d0416273b2d Mon Sep 17 00:00:00 2001 From: alam00000 Date: Sat, 31 Oct 2026 16:16:23 +0530 Subject: [PATCH] add support for GFM inline math delimiters --- src/js/utils/markdown-editor.ts | 1 + src/tests/markdown-editor-render.test.ts | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/js/utils/markdown-editor.ts b/src/js/utils/markdown-editor.ts index 7c0805de..89006c37 100644 --- a/src/js/utils/markdown-editor.ts +++ b/src/js/utils/markdown-editor.ts @@ -84,6 +84,7 @@ const ESCAPED_MATH: ReadonlyArray<[string, string, boolean]> = [ ['\\\\[', '\\\\]', true], ['\\\\(', '\\\\)', false], ['\\[', '\\]', true], + ['$`', '`$', false], ]; function escapedMath(state: StateInline, silent: boolean): boolean { diff --git a/src/tests/markdown-editor-render.test.ts b/src/tests/markdown-editor-render.test.ts index db406963..1e91a4a5 100644 --- a/src/tests/markdown-editor-render.test.ts +++ b/src/tests/markdown-editor-render.test.ts @@ -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');