mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-05 11:52:48 +01:00
add support for GFM inline math delimiters
This commit is contained in:
@@ -84,6 +84,7 @@ const ESCAPED_MATH: ReadonlyArray<[string, string, boolean]> = [
|
||||
['\\\\[', '\\\\]', true],
|
||||
['\\\\(', '\\\\)', false],
|
||||
['\\[', '\\]', true],
|
||||
['$`', '`$', false],
|
||||
];
|
||||
|
||||
function escapedMath(state: StateInline, silent: boolean): boolean {
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user