diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index b064da88..4abf51d9 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -581,7 +581,14 @@ impl Raw { /// An optional identifier specifying the language to syntax-highlight in. pub fn lang(&self) -> Option<&str> { - let inner = self.0.text().trim_start_matches('`'); + let text = self.0.text(); + + // Only blocky literals are supposed to contain a language. + if !text.starts_with("```") { + return Option::None; + } + + let inner = text.trim_start_matches('`'); let mut s = Scanner::new(inner); s.eat_if(is_id_start).then(|| { s.eat_while(is_id_continue); diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png index 7a38e1a5..845f6c21 100644 Binary files a/tests/ref/text/raw.png and b/tests/ref/text/raw.png differ diff --git a/tests/typ/text/raw.typ b/tests/typ/text/raw.typ index ecc81154..1040151c 100644 --- a/tests/typ/text/raw.typ +++ b/tests/typ/text/raw.typ @@ -37,6 +37,10 @@ The keyword ```rust let```. (``` trimmed ```) \ (``` trimmed```) \ +--- +// Single ticks should not have a language. +`rust let` + --- // First line is not dedented and leading space is still possible. ``` A