Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Kotlin nested comment #2104

Merged
merged 1 commit into from Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 */