mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Fix parsing of language in single-tick raw literals (#401)
This commit is contained in:
parent
d1ff94a3b5
commit
e13fc04c3e
@ -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);
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 33 KiB |
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user