diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index 92e78b2d0..721225c6e 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -503,7 +503,10 @@ impl Lexer<'_> { } fn space_or_end(&self) -> bool { - self.s.done() || self.s.at(char::is_whitespace) + self.s.done() + || self.s.at(char::is_whitespace) + || self.s.at("//") + || self.s.at("/*") } } diff --git a/tests/suite/syntax/comment.typ b/tests/suite/syntax/comment.typ index 5e7e0ee69..88802fe97 100644 --- a/tests/suite/syntax/comment.typ +++ b/tests/suite/syntax/comment.typ @@ -34,6 +34,41 @@ Second part First part // Second part +--- issue-4632-sth-followed-by-comment --- +// Test heading markers followed by comments. +#test([ + =// Comment + =/* Comment */ +], [ + = + = +]) + +// Test list markers followed by comments. +#test([ + -// Comment + -/* Comment */ +], [ + - + - +]) + +// Test enum markers followed by comments. +#test([ + +// Comment + +/* Comment */ + + 1.// Comment + 2./* Comment */ +], [ + + + + + + 1. + 2. +]) + + --- comment-block-unclosed --- // End should not appear without start. // Error: 7-9 unexpected end of block comment