Browse Source

test(ui): keep TeX delimiters out of code fences

fz 2 months ago
parent
commit
3b86568577
1 changed files with 9 additions and 0 deletions
  1. 9 0
      packages/client/ui-primitives/tests/markdown.spec.tsx

+ 9 - 0
packages/client/ui-primitives/tests/markdown.spec.tsx

@@ -251,6 +251,15 @@ describe('MarkdownText', () => {
     }
   })
 
+  it('leaves TeX-looking fenced code literal', () => {
+    const source = '```tex\n\\[\\frac{1}{5}\\]\n$$x \\tag{1}$$\n```'
+    const { container } = render(<MarkdownText text={source} />)
+
+    expect(container.querySelector('.katex')).toBeNull()
+    expect(container.querySelector('pre code')?.textContent).toContain('\\[\\frac{1}{5}\\]')
+    expect(container.querySelector('pre code')?.textContent).toContain('$$x \\tag{1}$$')
+  })
+
   it('registers the compatibility extension on a bare remark processor', () => {
     const data: { micromarkExtensions?: Extension[] } = {}
     remarkMathCompatibility.call({ data: () => data })