feat(渲染): 支持 LaTeX 数学公式,KaTeX 本地化
聊天消息与 md 文件预览都支持 $...$ 行内与 $$...$$ 块级。
实现:占位符往返,不用 marked 扩展
- 解析前把公式抠成 @@MATHn@@(跳过围栏代码与行内代码)
- marked 正常解析后把占位换回 KaTeX 输出
- 这样公式里的 * _ \ { } 不会被 marked 当成强调/转义
行内 $ 的边界判断:前后紧邻字母/数字时不识别,避免「花了 $5 和 $6」被当公式。
KaTeX 0.16.11 本地 vendor(592KB,含 20 个 woff2 字体),不走 CDN。
md 预览的新窗口用根绝对路径引入 CSS,blob 文档的相对路径找不到字体。
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user