[Feature]: 内置 Markdown 查看器/编辑器支持数学公式(KaTeX)渲染
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- react, typescript
Research direction
Start with src/web-ui/src/component-library/components/Markdown/Markdown.tsx and MarkdownMathRenderer.tsx to understand the existing chat math path, then inspect MarkdownEditor.tsx and src/web-ui/src/tools/editor/meditor/extensions/. Compare the two entry points and run the Markdown viewer with the provided formulas. Done means inline and block math render in opened .md files while dollar signs inside code blocks remain unchanged.
Written by the indexing model from the issue text.
Description
Problem / opportunity
BitFun 内置的 Markdown 查看器/编辑器(打开 .md 文件时使用)不渲染数学公式,$...$ 与 $$...$$ 只显示为原始文本;而对话(chat)中的 Markdown 已经支持 KaTeX 公式渲染。两者渲染能力不一致。
对以 Markdown + LaTeX 记笔记的用户(如数学/理科笔记)影响较大:在 BitFun 内打开自己的笔记看不到公式渲染,只能借助外部编辑器,或自行编写 MiniApp 阅读器绕过。
根因(源码层面):BitFun 内部有两套独立的 Markdown 渲染路径——
- 对话渲染(已支持公式):
src/web-ui/src/component-library/components/Markdown/Markdown.tsx通过mayContainMarkdownMath()检测$$/\(/\[/ 行内$...$,命中后懒加载MarkdownMathRenderer.tsx(react-markdown + remark-gfm + remark-math + rehype-katex)。 - 文件查看器/编辑器(不支持):打开 .md 走
FileViewerScene → ContentCanvas → MarkdownEditor(src/web-ui/src/tools/editor/components/MarkdownEditor.tsx),底层是 tiptap 编辑器(src/web-ui/src/tools/editor/meditor/),其extensions/只有 Alignment / Image / Table 扩展,没有任何数学公式扩展。
Proposed behavior
文件查看器/编辑器的预览能像对话一样渲染行内($...$、\(...\))与块级($$...$$、\[...\])数学公式。
建议方案(任选其一或结合):
- 为 tiptap 编辑器(meditor)增加数学节点扩展(社区已有成熟的 tiptap + KaTeX 扩展可参考),复用现有 KaTeX 依赖;
- 或让文件预览复用 component-library 的
Markdown+MarkdownMathRenderer渲染路径,统一两套渲染的公式能力。
Product surface
Desktop app
Details, examples, or constraints
复现步骤:
- 工作区放一个含公式的 .md 文件,例如:
质能方程 $E=mc^2$,以及 $$\int_0^1 x^2 dx = \frac13$$ - 在 BitFun 内打开该文件(文件查看器)→ 公式原样显示,未渲染
- 对比:把同样内容让 AI 在对话中输出 → 公式正常渲染
验收标准:
- 打开含
$...$/$$...$$的 .md 文件,公式以排版形式渲染 - 代码块内的
$不被误判为公式
环境:Windows 11,BitFun 桌面版。
- Dominant language
- Rust
- Stars
- 2.3k
- Forks
- 236
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 619
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GCWing/OpenBitFun
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
GCWing/OpenBitFun#3213 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GCWing/OpenBitFun#2363 ·
-
question
Difficulty 1/5 Under an hour Newbie friendliness 78/100
GCWing/OpenBitFun#2340 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
GCWing/OpenBitFun#3210 ·
-
GCWing/OpenBitFun#3195 · 2 comments · 1 assignee ·
All issues in GCWing/OpenBitFun
Similar issues
-
bug CLI custom-model
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
rust-bitcoin/rust-bitcoin#6930 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
fulcrumgenomics/ferro-hgvs#2251 ·
-
A-allocators A-docs C-enhancement T-libs
Difficulty 2/5 1-3 hours Newbie friendliness 75/100