diff --git a/docs/src/general/changelog.md b/docs/src/general/changelog.md index 0fec3112f..5b275ef51 100644 --- a/docs/src/general/changelog.md +++ b/docs/src/general/changelog.md @@ -19,6 +19,7 @@ description: | - The [`link`]($func/link) function now accepts [labels]($func/label) - The [`bibliography`]($func/bibliography) now also accepts multiple bibliography paths (as an array) +- Labels and references can now include `:` and `.` if not at the end - Added basic i18n for a few more languages (IT, RU, ZH, FR, PT) - Added numbering support for Hebrew - Added support for [integers]($type/integer) with base 2, 8, and 16 diff --git a/src/syntax/lexer.rs b/src/syntax/lexer.rs index b67a009c2..43417046f 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"); }