-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(bash): Comments false positives #3918
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
Conversation
We'd prefer to do this with a multi-matcher rather than nesting, see an example: https://github.com/highlightjs/highlight.js/blob/main/src/languages/ruby.js#L247 And you could just use inherit to update the existing rule... hljs.inherit(HASH_COMMENT_MODE,
// the changes you want to merge in
{
match: // ...
} |
9609244
to
2a3c7e1
Compare
Okay, done! I had to set begin and end to |
2a3c7e1
to
15674e2
Compare
Build Size ReportChanges to minified artifacts in 2 files changedTotal change +75 B View Changes
|
In POSIX shells, the `#` needs to be after a whitespace or start-of-line to delimit a comment. Compare: ```sh $ echo asdf#qwert asdf#qwert $ echo asdf #qwert asdf ``` I checked a few other languages as well that use #-delimited comments, but it seems this behaviour is unique to bash and other POSIX shells. Fixes highlightjs#3917
15674e2
to
be838a1
Compare
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +69 B View Changes
|
This reverts commit d78749a.
In POSIX shells, the
#
needs to be after a whitespace or start-of-line to delimit a comment. Compare:This is fixed with this PR.
I checked a few other languages as well that use #-delimited comments, but it seems this behaviour is unique to bash and other POSIX shells.
Fixes #3917
Changes
Inside the bash mode,
HASH_COMMENT_MODE
was wrapped in another mode that prevents a match if the#
is not after the start of the line or a whitespace character.Checklist
CHANGES.md