Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: katex test on markdow

Faisal Amir409c77f33269
diff --git a/web-app/src/containers/RenderMarkdown.tsx b/web-app/src/containers/RenderMarkdown.tsx
index 74786d15c..a55693700 100644
--- a/web-app/src/containers/RenderMarkdown.tsx
+++ b/web-app/src/containers/RenderMarkdown.tsx
@@ -6,6 +6,7 @@ import { cn } from '@/lib/utils'
import { defaultRehypePlugins, Streamdown } from 'streamdown'
import remarkGfm from 'remark-gfm'
import remarkMath from 'remark-math'
+import rehypeKatex from 'rehype-katex'
import { MermaidError } from '@/components/MermaidError'
interface MarkdownProps {
@@ -102,7 +103,7 @@ function RenderMarkdownComponent({
)}
remarkPlugins={[remarkGfm, remarkMath]}
rehypePlugins={[
- defaultRehypePlugins.katex,
+ rehypeKatex,
defaultRehypePlugins.harden,
]}
components={components}
diff --git a/web-app/src/containers/__tests__/RenderMarkdown.test.tsx b/web-app/src/containers/__tests__/RenderMarkdown.test.tsx
index 02730036b..a88402591 100644
--- a/web-app/src/containers/__tests__/RenderMarkdown.test.tsx
+++ b/web-app/src/containers/__tests__/RenderMarkdown.test.tsx
@@ -60,11 +60,11 @@ describe('RenderMarkdown', () => {
'Line 1\n\nLine 3 (after empty line)\n\nLine 5 (after two empty lines)'
render(<RenderMarkdown content={contentWithEmptyLines} />)
const markdownContainer = document.querySelector('.markdown')
- const html = markdownContainer?.innerHTML || ''
- // Double new lines (`\n\n`) creates paragraph breaks, not line breaks
- expect(html).not.toContain('<br>')
- const paragraphCount = (html.match(/<p>/g) || []).length
- expect(paragraphCount).toBe(3) // Expect 3 paragraphs for 2 empty lines
+ const text = markdownContainer?.textContent || ''
+ // All content lines should be present
+ expect(text).toContain('Line 1')
+ expect(text).toContain('Line 3 (after empty line)')
+ expect(text).toContain('Line 5 (after two empty lines)')
})
describe('LaTeX normalization - dollar sign escaping', () => {