fix let-prefix prose misclassification as Cordial
This commit is contained in:
parent
50dc72395e
commit
80017cf84f
|
|
@ -37,10 +37,16 @@ pub fn classify_line(index: usize, raw: &str) -> ClassifiedLine {
|
|||
|
||||
fn is_cordial(line: &str) -> bool {
|
||||
if line.starts_with("let ") {
|
||||
return true;
|
||||
let rest = &line[4..];
|
||||
if let Some(eq_pos) = rest.find('=') {
|
||||
let name = rest[..eq_pos].trim();
|
||||
if is_ident(name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// variable assignment: identifier = expr (but not ==)
|
||||
if let Some(eq_pos) = line.find('=') {
|
||||
if eq_pos > 0 {
|
||||
let before = &line[..eq_pos];
|
||||
|
|
@ -158,6 +164,18 @@ mod tests {
|
|||
assert_eq!(c.kind, LineKind::Markdown);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn let_prose_not_cordial() {
|
||||
let c = classify_line(0, "let us consider something");
|
||||
assert_eq!(c.kind, LineKind::Markdown);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn let_without_equals_not_cordial() {
|
||||
let c = classify_line(0, "let me explain");
|
||||
assert_eq!(c.kind, LineKind::Markdown);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn single_line_block_comment() {
|
||||
let lines = classify_document("/* hello */");
|
||||
|
|
|
|||
Loading…
Reference in New Issue