-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
问题描述
当内联数学公式($...$)的内容长度超过 30 个字符时,LaTeXPreprocessor 会在 <LaTex> 标签前后添加换行符,这会破坏 Markdown 无序列表的嵌套结构,导致渲染异常。
复现步骤
使用以下 Markdown 内容:
* **完全平方公式**:
* $(a + b)^2 = a^2 + 2ab + b^2$
* $(a - b)^2 = a^2 - 2ab + b^2$
* **立方和/差公式**:
* $a^3 + b^3 = (a + b)(a^2 - ab + b^2)$
* $a^3 - b^3 = (a - b)(a^2 + ab + b^2)$预处理后的结果对比:
# 正常(≤30 字符)
* <LaTex>$(a + b)^2 = a^2 + 2ab + b^2$</LaTex>
# 异常(>30 字符)- 换行破坏了列表缩进
*
<LaTex>$a^3 + b^3 = (a + b)(a^2 - ab + b^2)$</LaTex>
问题原因
在 GMarkPreprocessor.swift 的 LaTeXPreprocessor 类中:
private func wrapLaTeX(_ content: String) -> String {
let lines = content.components(separatedBy: .newlines)
if lines.count > 1 || content.count > 30 { // ⚠️ 问题在这里
// Multi-line or long expressions get newlines for better formatting
return "\n <LaTex>\(content)</LaTex> \n"
} else {
// Inline expressions
return "<LaTex>\(content)</LaTex>"
}
}content.count > 30 条件会对超过 30 字符的单行内联公式添加换行符,但这会破坏 Markdown 列表的缩进结构。
环境信息
- GMarkdown 版本:main 分支
- 文件:
GMarkPreprocessor.swift - 类:
LaTeXPreprocessor
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels