summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-syntax/src/lexer.rs5
-rw-r--r--tests/suite/syntax/comment.typ35
2 files changed, 39 insertions, 1 deletions
diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs
index 92e78b2d..721225c6 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 5e7e0ee6..88802fe9 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