Skip to content

不平衡结构被继续着色 - #8

Open
liumaker wants to merge 2 commits into
SoMarkAI:mainfrom
liumaker:fix/unbalanced-token-coloring
Open

liumaker wants to merge 2 commits into
SoMarkAI:mainfrom
liumaker:fix/unbalanced-token-coloring

Conversation

@liumaker

@liumaker liumaker commented Sep 8, 2026

Copy link
Copy Markdown

未配对 {}、环境外 &、环境外 \\ 或包含换行控制的 token 如果继续包裹颜色,会进一步破坏语法,并可能把无效输入表现为普通 CDM 零分。

@Soul-Code Soul-Code left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

提交组织问题:当前 #2 → #3 → #4 → #5 → #6 → #8 → #7 是一条累计提交链,但全部以 main 为 base,导致后一个 PR 包含前面全部修改,标题与实际审核范围不一致。请调整为独立 PR 或正确的 stacked PR;每个问题都应增加能够证明“main 失败、当前独立修改后通过”的最小回归测试。

main 已经包含“不平衡 token 或含换行 token 时跳过着色”的处理,因此本 PR 需要先说明新增行为解决了哪个尚未覆盖的真实失败。

当前 validate_formula_structure() 不具备正确的环境作用域判断:只要公式中出现任意 \begin{...},公式其他位置的 & 和 \ 都会被放过;转义判断也只检查前一个字符,没有按连续反斜杠的奇偶数判断。

建议暂不合并。请使用环境栈/作用域扫描重写校验,并提交能够证明 main 失败、修复后成功的真实输入和测试。

if depth:
raise ValueError("Unmatched opening brace")

has_environment = bool(re.search(r"\\begin\{[^}]+\}", latex))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_environment 只表示公式某处存在环境,不能证明当前 & 或 \\ 位于该环境内部。例如 x & \\begin{matrix}a\\end{matrix} 会通过这里。需要跟踪 begin/end 的真实作用域和嵌套关系。

@liumaker
liumaker force-pushed the fix/unbalanced-token-coloring branch from edbeab9 to a99458f Compare September 10, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants