Skip to content

fix(bash): highlight command-line options#4369

Open
KJyang-0114 wants to merge 2 commits intohighlightjs:mainfrom
KJyang-0114:fix/bash-options-highlighting
Open

fix(bash): highlight command-line options#4369
KJyang-0114 wants to merge 2 commits intohighlightjs:mainfrom
KJyang-0114:fix/bash-options-highlighting

Conversation

@KJyang-0114
Copy link

Description

Add OPTIONS pattern to highlight command-line options like --project, --deployment-package, -f, etc. This fixes inconsistent highlighting where some options were highlighted as built_in while others had no highlighting at all.

Fixes

Fixes #4288

Testing

The fix adds proper highlighting for:

  • Long options: --project, --deployment-package, --use-maintainance-page, etc.
  • Short options: -f, -v, etc. (but not in assignment context like -f=value)

Screenshots

Before: Some options had no highlighting
After: All options are highlighted with the 'attribute' class

When highlightElement is called on already-highlighted code (e.g., consecutive
hljs.highlightAll() calls), the existing <span class="hljs-*"> tags from the
previous highlighting are incorrectly flagged as "unescaped HTML" - a false
positive security warning.

This fix checks for the data-highlighted attribute early and silently skips
re-highlighting, matching the proposed solution in issue highlightjs#3761.
Add OPTIONS pattern to highlight command-line options like --project,
--deployment-package, -f, etc. This fixes inconsistent highlighting
where some options were highlighted as built_in while others had no
highlighting at all.

Fixes: highlightjs#4288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(Bash) Highlighted colors doesn't look correct

1 participant