highlight.js: (bash) Language does not highlight heredocs
Describe the issue
Is is expected that the bash language do no highlight some specific characters. in the screenshot below
I would have expected the following would be highlighted
|a pipe\the continue command marker at the end of the line><Stream redirections<<and<<<, here doc, and here string$(...)subshell variable (maybe not what’s inside but at least the whole variable or just the parenthesis)
shell

bash

Which language seems to have the issue?
I believe it’s the bash language which is also used by the shell language.
Are you using highlight or highlightAuto?
I’m not sure of the question, the script uses : hljs.initHighlightingOnLoad();
…
Sample Code to Reproduce
Reproducer : https://jsfiddle.net/kcyd487f/
Expected behavior
Highlight the menetionned element above. Maybe other characters elements may be interesting.
For heredoc I’m not sure everything could be highlighted, especially the multiline text, as the EOF marker can be anything.
Additional context
I’m using asciidoctor, but the issue can be reproduced in the JSfiddle too.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 31 (18 by maintainers)
But heredoc is also a sort of piping. Bash manual describes
<<as no less than “redirection operator”. So imho the simplest (and consistent) approach is to exclude<<-?from highlighting, as I suggested earlier.(And in most detailed way we’d highlight
<<-as operator,BLAHas quote/delimiter, and everything in between as string itself.)Those are differently quoted strings:
So it’s not just another variant, it’s rather variants of BRACED_VAR, QUOTE_STRING, APOS_STRING and maybe some other modes.
I think we shouldn’t do anything about highlighting
<<<specially. E. g. in<<<wordword can be a quoted string. We should highlight<<< '$foo'and<<< "$foo"differently. Now it just works, because we actually don’t pay attention to<<<. Making<<<part of a string complicates things (imho unnecessary).And if so, we also shouldn’t color here-doc’s
<<for the sake of consistency (: