Skip to content

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

feat: render Markdown tables and math in source file preview

nash_su2cbfe6b0e3f0
diff --git a/src/components/editor/file-preview.tsx b/src/components/editor/file-preview.tsx
index c996c6db..4325864a 100644
--- a/src/components/editor/file-preview.tsx
+++ b/src/components/editor/file-preview.tsx
@@ -1,5 +1,9 @@
import { convertFileSrc } from "@tauri-apps/api/core"
-import { convertLatexToUnicode } from "@/lib/latex-to-unicode"
+import ReactMarkdown from "react-markdown"
+import remarkGfm from "remark-gfm"
+import remarkMath from "remark-math"
+import rehypeKatex from "rehype-katex"
+import "katex/dist/katex.min.css"
import {
FileText,
Image as ImageIcon,
@@ -113,7 +117,30 @@ function TextPreview({ filePath, content, label }: { filePath: string; content:
<span>{filePath}</span>
<span className="rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase">{label}</span>
</div>
- <pre className="whitespace-pre-wrap font-mono text-sm">{convertLatexToUnicode(content)}</pre>
+ <div className="prose prose-sm max-w-none dark:prose-invert">
+ <ReactMarkdown
+ remarkPlugins={[remarkGfm, remarkMath]}
+ rehypePlugins={[rehypeKatex]}
+ components={{
+ table: ({ children, ...props }) => (
+ <div className="my-2 overflow-x-auto rounded border border-border">
+ <table className="w-full border-collapse text-xs" {...props}>{children}</table>
+ </div>
+ ),
+ thead: ({ children, ...props }) => (
+ <thead className="bg-muted" {...props}>{children}</thead>
+ ),
+ th: ({ children, ...props }) => (
+ <th className="border border-border/80 px-3 py-1.5 text-left font-semibold bg-muted" {...props}>{children}</th>
+ ),
+ td: ({ children, ...props }) => (
+ <td className="border border-border/60 px-3 py-1.5" {...props}>{children}</td>
+ ),
+ }}
+ >
+ {content}
+ </ReactMarkdown>
+ </div>
</div>
)
}