diff options
| author | frozolotl <44589151+frozolotl@users.noreply.github.com> | 2023-03-28 17:04:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-28 17:04:27 +0200 |
| commit | e13fc04c3e973da60d5f4e9cc6fc38105cd2ddf9 (patch) | |
| tree | d554639e2747f790608c64c14f206e996e550c73 /src | |
| parent | d1ff94a3b59b5642c549b1141853e0ffbe842185 (diff) | |
Fix parsing of language in single-tick raw literals (#401)
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax/ast.rs | 9 |
1 files changed, 8 insertions, 1 deletions
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); |
