mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Allow labels and reference with ',' and '.'
This commit is contained in:
parent
8284db9000
commit
5637a1693c
@ -19,6 +19,7 @@ description: |
|
|||||||
- The [`link`]($func/link) function now accepts [labels]($func/label)
|
- The [`link`]($func/link) function now accepts [labels]($func/label)
|
||||||
- The [`bibliography`]($func/bibliography) now also accepts multiple
|
- The [`bibliography`]($func/bibliography) now also accepts multiple
|
||||||
bibliography paths (as an array)
|
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 basic i18n for a few more languages (IT, RU, ZH, FR, PT)
|
||||||
- Added numbering support for Hebrew
|
- Added numbering support for Hebrew
|
||||||
- Added support for [integers]($type/integer) with base 2, 8, and 16
|
- Added support for [integers]($type/integer) with base 2, 8, and 16
|
||||||
|
@ -291,8 +291,8 @@ impl Lexer<'_> {
|
|||||||
return self.error_at_end("expected closing bracket in link");
|
return self.error_at_end("expected closing bracket in link");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't include the trailing characters likely to be part of another expression.
|
// Don't include the trailing characters likely to be part of text.
|
||||||
if matches!(self.s.scout(-1), Some('!' | ',' | '.' | ':' | ';' | '?' | '\'')) {
|
while matches!(self.s.scout(-1), Some('!' | ',' | '.' | ':' | ';' | '?' | '\'')) {
|
||||||
self.s.uneat();
|
self.s.uneat();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,12 +311,18 @@ impl Lexer<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ref_marker(&mut self) -> SyntaxKind {
|
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
|
SyntaxKind::RefMarker
|
||||||
}
|
}
|
||||||
|
|
||||||
fn label(&mut self) -> SyntaxKind {
|
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() {
|
if label.is_empty() {
|
||||||
return self.error("label cannot be empty");
|
return self.error("label cannot be empty");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user