Skip to content

Commit

Permalink
Fix(Kotlin): nested comment (#2104)
Browse files Browse the repository at this point in the history
  • Loading branch information
egor-rogov authored and Marcos Cáceres committed Aug 16, 2019
1 parent 0b6c4ba commit 9a7e3e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/languages/kotlin.js
Expand Up @@ -103,6 +103,10 @@ function(hljs) {
begin: KOTLIN_NUMBER_RE,
relevance: 0
};
var KOTLIN_NESTED_COMMENT = hljs.COMMENT(
'/\\*', '\\*/',
{ contains: [ hljs.C_BLOCK_COMMENT_MODE ] }
);

return {
aliases: ['kt'],
Expand All @@ -120,7 +124,7 @@ function(hljs) {
}
),
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
KOTLIN_NESTED_COMMENT,
KEYWORDS_WITH_LABEL,
LABEL,
ANNOTATION_USE_SITE,
Expand Down Expand Up @@ -156,19 +160,19 @@ function(hljs) {
contains: [
{className: 'type', begin: hljs.UNDERSCORE_IDENT_RE},
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE
KOTLIN_NESTED_COMMENT
],
relevance: 0
},
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
KOTLIN_NESTED_COMMENT,
ANNOTATION_USE_SITE,
ANNOTATION,
STRING,
hljs.C_NUMBER_MODE
]
},
hljs.C_BLOCK_COMMENT_MODE
KOTLIN_NESTED_COMMENT
]
},
{
Expand Down
9 changes: 9 additions & 0 deletions test/markup/kotlin/nested_comment.expect.txt
@@ -0,0 +1,9 @@
<span class="hljs-comment">/* begin comment at LEVEL 0
<span class="hljs-comment">/*
multiline nested comment LEVEL 1
*/</span>
println("on kotlin this is a commented code in comment LEVEL 0")
<span class="hljs-comment">/*
another multiline nested comment LEVEL 1
*/</span>
end comment at LEVEL 0 */</span>
9 changes: 9 additions & 0 deletions test/markup/kotlin/nested_comment.txt
@@ -0,0 +1,9 @@
/* begin comment at LEVEL 0
/*
multiline nested comment LEVEL 1
*/
println("on kotlin this is a commented code in comment LEVEL 0")
/*
another multiline nested comment LEVEL 1
*/
end comment at LEVEL 0 */

0 comments on commit 9a7e3e6

Please sign in to comment.