diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index ac69eb616..c17e09665 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -196,7 +196,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, diff --git a/tests/suite/model/ref.typ b/tests/suite/model/ref.typ index 2f8e2fa25..279637754 100644 --- a/tests/suite/model/ref.typ +++ b/tests/suite/model/ref.typ @@ -85,3 +85,12 @@ Text seen on #ref(, form: "page", supplement: "Page"). // Test reference with non-whitespace before it. #figure[] <1> #test([(#ref(<1>))], [(@1)]) + +--- ref-to-empty-label-not-possible --- +// @ without any following label should just produce the symbol in the output +// and not produce a reference to a label with an empty name. +@ \<- this should show up +// using ref() should also not be possible +// Error: 6-7 unexpected less-than operator +// Error: 7-8 unexpected greater-than operator +#ref(<>)