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:
1 parent
6f303ff957
commit
c8f41164c5
5 files changed
+2
-52
No files matched your search
@@ -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]
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in new issue
Block a user