summaryrefslogtreecommitdiff
path: root/crates/typst-syntax
diff options
context:
space:
mode:
authorSaid A. <47973576+Daaiid@users.noreply.github.com>2025-06-26 11:18:51 +0200
committerGitHub <noreply@github.com>2025-06-26 09:18:51 +0000
commit5dd5771df03a666fe17930b0b071b06266e5937f (patch)
tree68a79a843f7b813aea70733b75b7df45a938ee0d /crates/typst-syntax
parent04fd0acacab8cf2e82268da9c18ef4bcf37507dc (diff)
Disallow empty labels and references (#5776) (#6332)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-syntax')
-rw-r--r--crates/typst-syntax/src/ast.rs2
-rw-r--r--crates/typst-syntax/src/lexer.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/crates/typst-syntax/src/ast.rs b/crates/typst-syntax/src/ast.rs
index 7b211bfc..547d53cd 100644
--- a/crates/typst-syntax/src/ast.rs
+++ b/crates/typst-syntax/src/ast.rs
@@ -724,6 +724,8 @@ node! {
impl<'a> Ref<'a> {
/// Get the target.
+ ///
+ /// Will not be empty.
pub fn target(self) -> &'a str {
self.0
.children()
diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs
index 74f14cfe..82f65cd3 100644
--- a/crates/typst-syntax/src/lexer.rs
+++ b/crates/typst-syntax/src/lexer.rs
@@ -185,7 +185,7 @@ impl Lexer<'_> {
'h' if self.s.eat_if("ttp://") => self.link(),
'h' if self.s.eat_if("ttps://") => self.link(),
'<' if self.s.at(is_id_continue) => self.label(),
- '@' => self.ref_marker(),
+ '@' if self.s.at(is_id_continue) => self.ref_marker(),
'.' if self.s.eat_if("..") => SyntaxKind::Shorthand,
'-' if self.s.eat_if("--") => SyntaxKind::Shorthand,