diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index dd05e73f2..993af0806 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -474,7 +474,7 @@ impl Lexer<'_> { Some('-') if !s.at(['-', '?']) => {} Some('.') if !s.at("..") => {} Some('h') if !s.at("ttp://") && !s.at("ttps://") => {} - Some('@') if !s.at(is_id_start) => {} + Some('@') if !s.at(is_valid_in_label_literal) => {} _ => break, } diff --git a/tests/suite/model/ref.typ b/tests/suite/model/ref.typ index 200f40aaa..d0881202c 100644 --- a/tests/suite/model/ref.typ +++ b/tests/suite/model/ref.typ @@ -54,3 +54,8 @@ $ A = 1 $ // Error: 1-7 label occurs in the document and its bibliography @arrgh #bibliography("/assets/bib/works.bib") + +--- issue-4536-non-whitespace-before-ref --- +// Test reference with non-whitespace before it. +#figure[] <1> +#test([(#ref(<1>))], [(@1)])