diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-04-04 18:19:17 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-04-04 18:19:17 +0200 |
| commit | 5637a1693c7a315582e101023507049bb07edb2e (patch) | |
| tree | 993641bb1dc6c39066d632c957b55f07e4459a99 /src | |
| parent | 8284db9000e32320e3d710c6a0b55c0c5525f483 (diff) | |
Allow labels and reference with ',' and '.'
Diffstat (limited to 'src')
| -rw-r--r-- | src/syntax/lexer.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs index b67a009c..43417046 100644 --- a/src/syntax/lexer.rs +++ b/src/syntax/lexer.rs @@ -291,8 +291,8 @@ impl Lexer<'_> { return self.error_at_end("expected closing bracket in link"); } - // Don't include the trailing characters likely to be part of another expression. - if matches!(self.s.scout(-1), Some('!' | ',' | '.' | ':' | ';' | '?' | '\'')) { + // Don't include the trailing characters likely to be part of text. + while matches!(self.s.scout(-1), Some('!' | ',' | '.' | ':' | ';' | '?' | '\'')) { self.s.uneat(); } @@ -311,12 +311,18 @@ impl Lexer<'_> { } fn ref_marker(&mut self) -> SyntaxKind { - self.s.eat_while(is_id_continue); + self.s.eat_while(|c| is_id_continue(c) || matches!(c, ':' | '.')); + + // Don't include the trailing characters likely to be part of text. + while matches!(self.s.scout(-1), Some('.' | ':')) { + self.s.uneat(); + } + SyntaxKind::RefMarker } fn label(&mut self) -> SyntaxKind { - let label = self.s.eat_while(is_id_continue); + let label = self.s.eat_while(|c| is_id_continue(c) || matches!(c, ':' | '.')); if label.is_empty() { return self.error("label cannot be empty"); } |
