mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-13 09:54:19 +01:00
add support for GFM inline math delimiters
This commit is contained in:
1 parent
d03594a09d
commit
2a8ce12b6e
2 files changed
+9
-1
No files matched your search
@@ -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 {
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
Reference in new issue
Block a user