Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Core Grammars:
- fix(css) fix overly greedy pseudo class matching [Bradley Mackey][]
- enh(arcade) updated to ArcGIS Arcade version 1.24 [Kristian Ekenes][]
- fix(yaml) fix for yaml with keys having brackets highlighted incorrectly [Aneesh Kulkarni][]
- fix(bash) fix # within token being detected as the start of a comment [Felix Uhl][]

Developer Tool:

Expand All @@ -14,6 +15,7 @@ Developer Tool:
[Kristian Ekenes]: https://github.com/ekenes
[Aneesh Kulkarni]: https://github.com/aneesh98
[Bruno Meneguele]: https://github.com/bmeneg
[Felix Uhl]: https://github.com/iFreilicht


## Version 11.9.0
Expand Down
14 changes: 13 additions & 1 deletion src/languages/bash.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ export default function(hljs) {
end: /\)/,
contains: [ hljs.BACKSLASH_ESCAPE ]
};
const COMMENT = hljs.inherit(
hljs.COMMENT(),
{
match: [
/(^|\s)/,
/#.*$/
],
scope: {
2: 'comment'
}
}
);
const HERE_DOC = {
begin: /<<-?\s*(?=\w+)/,
starts: { contains: [
Expand Down Expand Up @@ -376,7 +388,7 @@ export default function(hljs) {
hljs.SHEBANG(), // to catch unknown shells but still highlight the shebang
FUNCTION,
ARITHMETIC,
hljs.HASH_COMMENT_MODE,
COMMENT,
HERE_DOC,
PATH_MODE,
QUOTE_STRING,
Expand Down
3 changes: 3 additions & 0 deletions test/markup/bash/not-comments.expect.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<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>
3 changes: 3 additions & 0 deletions test/markup/bash/not-comments.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
echo asdf#qwert yuiop

echo asdf #qwert yuiop