summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/syntax/ast.rs9
-rw-r--r--tests/ref/text/raw.pngbin18857 -> 33809 bytes
-rw-r--r--tests/typ/text/raw.typ4
3 files changed, 12 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);
diff --git a/tests/ref/text/raw.png b/tests/ref/text/raw.png
index 7a38e1a5..845f6c21 100644
--- a/tests/ref/text/raw.png
+++ b/tests/ref/text/raw.png
Binary files 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
@@ -38,6 +38,10 @@ The keyword ```rust let```.
(``` trimmed```) \
---
+// Single ticks should not have a language.
+`rust let`
+
+---
// First line is not dedented and leading space is still possible.
``` A
B