fix(parse): keep GAP recovery for unclosed bold

Hard-erroring code-shaped `` **… `` broke tests/structure/gap-star-json-body.mq.md; unclosed bold stays Comment so later statements still run.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-14 14:41:51 +08:00
1 parent 6f303ff957
commit c8f41164c5
5 files changed
+2 -52

No files matched your search

+2 -2
View File
@@ -53,8 +53,8 @@
- [x] else 臂 `N. *` 与返回斜体消歧
- [x] 一行多 `**…**` 按序执行
- [x] 金样例:`---` / `*None*` / 整行 `**` / 兼容 `****`;叙述死绑定不升参
- [x] 诊断:必选缺失、未知 callee(已有 errors 金样);未闭合代码形粗体;死变量不报错
- [ ] (可选)死变量 hint lint;空返回其它歧义边角
- [x] 诊断:必选缺失、未知 callee(已有 errors 金样);死变量不报错
- [ ] 残缺粗体:与 GAP-06/07「未闭合后恢复」冲突,保持 Comment 跳过恢复,不硬报错
**出门:** `tests/markup-v03/*` 覆盖设计 §9 示例。
-21
View File
@@ -74,16 +74,6 @@ pub fn looks_like_bold_code(inner: &str) -> bool {
false
}
/// `` **code-shaped… `` without a closing `**` (should diagnose, not skip as comment).
fn looks_like_unclosed_bold_code(trimmed: &str) -> bool {
let t = trimmed.trim();
if !t.starts_with("**") || matching_bold_close(t).is_some() {
return false;
}
// Whole-line empty markers are handled by is_marqdo_star_line.
looks_like_bold_code(&t[2..])
}
/// Whole-line backtick bind `` `name` = … `` (empty RHS / fence / table OK).
///
/// Narrative decls are **not** binds:
@@ -294,7 +284,6 @@ pub fn classify_line(text: &str) -> LineKind {
let first = trimmed.chars().find(|c| !c.is_whitespace());
match first {
None => LineKind::Blank,
Some('*') if looks_like_unclosed_bold_code(trimmed) => LineKind::Code,
Some('*') if !is_marqdo_star_line(trimmed) => LineKind::Comment,
Some('`') if looks_like_backtick_assign(trimmed) => LineKind::Code,
Some('`') => LineKind::Comment,
@@ -475,16 +464,6 @@ mod tests {
LineKind::Code,
"spaced = is backtick assign"
);
assert_eq!(
classify_line("**x = 1"),
LineKind::Code,
"unclosed code-shaped bold → Code for diagnosis"
);
assert_eq!(
classify_line("**说明"),
LineKind::Comment,
"unclosed soft emphasis stays comment"
);
}
#[test]
-13
View File
@@ -363,19 +363,6 @@ impl<'a> Cursor<'a> {
});
}
// Unclosed code-shaped bold (classified Code so we can diagnose).
if trimmed.starts_with("**")
&& !(trimmed.ends_with("**") && trimmed.len() >= 4)
&& crate::lex::looks_like_bold_code(&trimmed[2..])
{
return Err(Diagnostic::new(
None,
span,
"unclosed bold code: expected closing `**`".to_string(),
)
.into());
}
// v0.3: **…** = code segment (assign / call / expr)
if trimmed.starts_with("**") && trimmed.ends_with("**") && trimmed.len() >= 4 {
let inner = &trimmed[2..trimmed.len() - 2];
-8
View File
@@ -1,8 +0,0 @@
---
title: unclosed bold code
description: code-shaped `**…` without closing `**` must diagnose
---
# main
**x = 1
-8
View File
@@ -610,14 +610,6 @@ fn error_syntax_bad_line() {
);
}
#[test]
fn error_unclosed_bold() {
assert_err(
"tests/errors/unclosed-bold.mq.md",
"8:1",
"unclosed bold code",
);
}
#[test]
fn error_div_zero() {