diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs index e004dd37c..67d413fd0 100644 --- a/src/parse/tokens.rs +++ b/src/parse/tokens.rs @@ -591,6 +591,10 @@ impl<'s> Tokens<'s> { depth += 1; '_' } + ('/', '/') => { + self.line_comment(); + '_' + } _ => c, } } diff --git a/tests/ref/code/comment.png b/tests/ref/code/comment.png index d7b599763..b1c630a90 100644 Binary files a/tests/ref/code/comment.png and b/tests/ref/code/comment.png differ diff --git a/tests/typ/code/comment.typ b/tests/typ/code/comment.typ index 407bebd43..db0a17a49 100644 --- a/tests/typ/code/comment.typ +++ b/tests/typ/code/comment.typ @@ -5,7 +5,7 @@ A// you B -// Block comment does not act as spacing. +// Block comment does not act as spacing, nested block comments. C/* /* */ */D @@ -14,6 +14,16 @@ C/* #test(type(/*1*/ 1) // , "integer") +// End of block comment in line comment. +// Hello */ + +// Nested line comment. +/*//*/ +Still comment. +*/ + +E + --- // Line comments have a special case for URLs. https://example.com \ diff --git a/tools/support/typst.tmLanguage.json b/tools/support/typst.tmLanguage.json index 36ffade73..f493cc5ba 100644 --- a/tools/support/typst.tmLanguage.json +++ b/tools/support/typst.tmLanguage.json @@ -4,20 +4,27 @@ { "include": "#markup" } ], "repository": { - "blockcomment": { + "comments": { "patterns": [ { "name": "comment.block.typst", "begin": "/\\*", "end": "\\*/", "captures": { "0": { "name": "punctuation.definition.comment.typst" } }, - "patterns": [{ "include": "#blockcomment" }] + "patterns": [{ "include": "#comments" }] + }, + { + "name": "comment.line.double-slash.typst", + "begin": "(?