and bare autolink https://autolink.example.com literal.',
'',
'[spaces encoded](https://example.com/a b)',
].join('\n'),
'images': [
'',
'',
'',
'',
' and inline ) end.',
'',
'',
].join('\n'),
'reference-links-and-images': [
'A [full][ref] reference, a [collapsed][] one, and a [shortcut] one.',
'',
'[missing full][nope], [missing collapsed][], ![missing image][gone].',
'',
'![ref image][imgref]',
'',
'[ref]: https://example.com/ref "ref title"',
'[collapsed]: https://example.com/collapsed',
'[shortcut]: https://example.com/shortcut',
'[imgref]: https://example.com/ref.png',
].join('\n'),
'footnotes': [
'First use[^a] and reuse[^a] and another[^b].',
'',
'[^a]: Footnote a body with [link](https://example.com).',
'',
'[^b]: Footnote b first paragraph.',
'',
' Second paragraph of b.',
].join('\n'),
'raw-html-dropped': [
'',
'',
'Paragraph with inline
html and bold tag kept literal?',
'',
'',
'html block content',
'
',
'',
'after',
].join('\n'),
'entities-and-escapes': 'AT&T, 3 < 4, \\*not em\\*, backslash \\\\ literal, © entity.',
'math-inline-and-display': [
'Einstein wrote $E = mc^2$ inline.',
'',
'$$',
'\\frac{\\partial \\mathbf{u}}{\\partial t} + (\\mathbf{u} \\cdot \\nabla)\\mathbf{u} = -\\frac{1}{\\rho}\\nabla p',
'$$',
'',
'Backslash inline \\(\\frac{1}{5}\\) and display:',
'',
'\\[\\frac{\\pi}{4} < \\theta < \\frac{\\pi}{2}\\]',
].join('\n'),
'math-edge-cases': [
'Trusted commands stay off: $\\href{javascript:alert(1)}{unsafe}$.',
'',
'Unbalanced errors render the error arm: $\\frac{$',
'',
'| Symbol | Value |',
'| --- | --- |',
'| $\\theta$ | \\(\\frac{1}{5}\\) |',
'',
'```math',
'\\sqrt{2}',
'```',
].join('\n'),
'gfm-strikethrough-and-literals': 'Mixed ~~gone~~ text with www.example.com literal and user@example.com email.',
'definition-only': '[unused]: https://example.com/unused',
'streaming-typical-partial': '## Streaming\n\n- first\n- **unfinished',
}
describe('MarkdownText DOM parity fixtures', () => {
for (const [name, text] of Object.entries(CORPUS)) {
it(`settled: ${name}`, async () => {
await expect(renderCase(text, false)).toMatchFileSnapshot(`./fixtures/markdown-dom/${name}.settled.txt`)
})
it(`streaming: ${name}`, async () => {
await expect(renderCase(text, true)).toMatchFileSnapshot(`./fixtures/markdown-dom/${name}.streaming.txt`)
})
}
})