Allow labels and reference with ',' and '.'

This commit is contained in:
Laurenz 2023-04-04 18:19:17 +02:00
parent 8284db9000
commit 5637a1693c
2 changed files with 11 additions and 4 deletions

View File

@ -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

View File

@ -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");
}