LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
fix: auto-wrap bare \begin{} blocks with $$ for KaTeX rendering
nash_su7a7f3aa2a161
diff --git a/src/components/chat/chat-message.tsx b/src/components/chat/chat-message.tsxindex daf296e9..28d6df7f 100644--- a/src/components/chat/chat-message.tsx+++ b/src/components/chat/chat-message.tsx@@ -585,8 +585,21 @@ function ThinkingBlock({ content }: { content: string }) {function processContent(text: string): string {let result = text- // Clean up LaTeX notation → readable Unicode- result = convertLatexToUnicode(result)+ // Wrap bare \begin{...}...\end{...} blocks with $$ for remark-math+ result = result.replace(+ /(?<!\$\$\s*)(\\begin\{[^}]+\}[\s\S]*?\\end\{[^}]+\})(?!\s*\$\$)/g,+ (_match, block: string) => `$$\n${block}\n$$`,+ )++ // Only apply Unicode conversion to text outside of math delimiters+ // Split on $$...$$ and $...$ blocks, only convert non-math parts+ const parts = result.split(/(\$\$[\s\S]*?\$\$|\$[^$\n]+?\$)/g)+ result = parts+ .map((part) => {+ if (part.startsWith("$")) return part // preserve math+ return convertLatexToUnicode(part)+ })+ .join("")// Fix malformed wikilinks like [[name] (missing closing bracket)result = result.replace(/\[\[([^\]]+)\](?!\])/g, "[[$1]]")diff --git a/src/components/editor/wiki-editor.tsx b/src/components/editor/wiki-editor.tsxindex f3159acd..6df456c1 100644--- a/src/components/editor/wiki-editor.tsx+++ b/src/components/editor/wiki-editor.tsx@@ -44,8 +44,15 @@ interface WikiEditorProps {onSave: (markdown: string) => void}+function wrapBareMathBlocks(text: string): string {+ return text.replace(+ /(?<!\$\$\s*)(\\begin\{[^}]+\}[\s\S]*?\\end\{[^}]+\})(?!\s*\$\$)/g,+ (_match, block: string) => `$$\n${block}\n$$`,+ )+}+export function WikiEditor({ content, onSave }: WikiEditorProps) {- const processedContent = useMemo(() => convertLatexToUnicode(content), [content])+ const processedContent = useMemo(() => wrapBareMathBlocks(content), [content])return (<MilkdownProvider>