[verified] feat: render latex in chat markdown

This commit is contained in:
Maxim Kirilyuk
2026-05-23 17:45:51 +03:00
committed by ekko
parent 7577cc472e
commit 981e2a1ad4
4 changed files with 82 additions and 1 deletions
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'
import { NDrawer, NDrawerContent, NSpin, useMessage } from 'naive-ui'
import type MarkdownIt from 'markdown-it'
import MarkdownItConstructor from 'markdown-it'
import markdownItKatex from '@vscode/markdown-it-katex'
import { handleCodeBlockCopyClick, renderHighlightedCodeBlock } from './highlight'
import { repairNestedMarkdownFences } from './markdownFenceRepair'
import {
@@ -41,6 +42,10 @@ const md: MarkdownIt = new MarkdownItConstructor({
},
})
md.use(markdownItKatex, {
throwOnError: false,
})
const defaultFenceRenderer = md.renderer.rules.fence?.bind(md.renderer.rules)
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
+1
View File
@@ -4,6 +4,7 @@ import router from './router'
import { i18n } from './i18n'
import App from './App.vue'
import './styles/global.scss'
import 'katex/dist/katex.min.css'
// Apply theme classes before mount to prevent FOUC (Flash of Unstyled Content)
const savedBrightness = localStorage.getItem('hermes_brightness') || 'system'