Describe the issue
# This is a comment with a TODO item in it
should have the TODO highlighted as scope doctag, and used to, but no longer does as of d78749a (#3918).
Which language seems to have the issue?
bash
Are you using highlight or highlightAuto?
highlight
Sample Code to Reproduce
# This is a comment with a TODO item in it
Expected behavior
TODO is highlighted as doctag scope.
Additional context
I upgraded highlight.js and this stopped working. I bisected the problem to d78749a (#3918); in particular the relevant problem seems to be somewhere in this code:
|
const COMMENT = hljs.inherit( |
|
hljs.COMMENT(), |
|
{ |
|
match: [ |
|
/(^|\s)/, |
|
/#.*$/ |
|
], |
|
scope: { |
|
2: 'comment' |
|
} |
|
} |
|
); |
As far as I can tell, the scope: {2: 'comment'} is somehow screwing up the mode.contains.push({scope: 'doctag', ...}) detection in modes.js, but I don’t have a good enough grasp on highlight.js internals to really understand what's going on or how to fix it.
Test case which I expect to pass:
diff --git a/test/markup/bash/not-comments.txt b/test/markup/bash/not-comments.txt
--- a/test/markup/bash/not-comments.txt
+++ b/test/markup/bash/not-comments.txt
@@ -1,3 +1,5 @@
echo asdf#qwert yuiop
echo asdf #qwert yuiop
+
+# TODO: this *is* a comment
diff --git a/test/markup/bash/not-comments.expect.txt b/test/markup/bash/not-comments.expect.txt
index ab128642..0f57ee8b 100644
--- a/test/markup/bash/not-comments.expect.txt
+++ b/test/markup/bash/not-comments.expect.txt
@@ -1,3 +1,5 @@
<span class="hljs-built_in">echo</span> asdf#qwert yuiop
<span class="hljs-built_in">echo</span> asdf <span class="hljs-comment">#qwert yuiop</span>
+
+<span class="hljs-comment"># <span class="hljs-docstring">TODO:</span> this *is* a comment</span>
Describe the issue
# This is a comment with a TODO item in itshould have the
TODOhighlighted as scopedoctag, and used to, but no longer does as of d78749a (#3918).Which language seems to have the issue?
bash
Are you using
highlightorhighlightAuto?highlight
Sample Code to Reproduce
# This is a comment with a TODO item in itExpected behavior
TODO is highlighted as
doctagscope.Additional context
I upgraded highlight.js and this stopped working. I bisected the problem to d78749a (#3918); in particular the relevant problem seems to be somewhere in this code:
highlight.js/src/languages/bash.js
Lines 41 to 52 in 85b2042
As far as I can tell, the
scope: {2: 'comment'}is somehow screwing up themode.contains.push({scope: 'doctag', ...})detection inmodes.js, but I don’t have a good enough grasp on highlight.js internals to really understand what's going on or how to fix it.Test case which I expect to pass: