From 28b23b18a2d67685a490a85975341fbed520b35b Mon Sep 17 00:00:00 2001 From: KJyang-0114 Date: Tue, 10 Mar 2026 13:04:04 +0800 Subject: [PATCH 1/2] fix(bash): highlight command line options (--option) Add highlighting for long options (--option) in bash to address issue #4288. Previously, command line options like --project, --env were not highlighted consistently across lines. This change adds an OPTION pattern that highlights long options when they appear after whitespace, making them visually distinct in CLI examples. --- src/languages/bash.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/languages/bash.js b/src/languages/bash.js index 44f9beba97..f79cbc6a22 100644 --- a/src/languages/bash.js +++ b/src/languages/bash.js @@ -145,6 +145,13 @@ export default function(hljs) { // to consume paths to prevent keyword matches inside them const PATH_MODE = { match: /(\/[a-z._-]+)+/ }; + // Command long options (--option) - only match long options to avoid conflicts + const OPTION = { + className: 'attribute', + begin: /\s--[\w-]+/, + relevance: 0 + }; + // http://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html const SHELL_BUILT_INS = [ "break", @@ -397,6 +404,7 @@ export default function(hljs) { COMMENT, HERE_DOC, PATH_MODE, + OPTION, QUOTE_STRING, ESCAPED_QUOTE, APOS_STRING, From d760bd80499deab23560b51d2798eb8800595f43 Mon Sep 17 00:00:00 2001 From: KJyang-0114 Date: Wed, 18 Mar 2026 11:59:10 +0800 Subject: [PATCH 2/2] test: update expected output for CLI option highlighting Updates test expectations to match the new behavior from PR #4376 which adds highlighting for long CLI options (--option) in bash. --- .../bash/token-containing-keyword.expect.txt | 2 +- test/markup/shell/command-continuation.expect.txt | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/markup/bash/token-containing-keyword.expect.txt b/test/markup/bash/token-containing-keyword.expect.txt index 90f9d8df2f..380431914a 100644 --- a/test/markup/bash/token-containing-keyword.expect.txt +++ b/test/markup/bash/token-containing-keyword.expect.txt @@ -1,5 +1,5 @@ # a keyword as part of an option -mycmd --disable-foo +mycmd --disable-foo # a keyword as part of a parameter some-cmd set-some-setting diff --git a/test/markup/shell/command-continuation.expect.txt b/test/markup/shell/command-continuation.expect.txt index 056b9eb520..b71d22d66f 100644 --- a/test/markup/shell/command-continuation.expect.txt +++ b/test/markup/shell/command-continuation.expect.txt @@ -1,11 +1,11 @@ $ docker run \ - --publish=7474:7474 --publish=7687:7687 \ - --volume=/neo4j/data:/data \ - --volume=/neo4j/plugins:/plugins \ - --volume=/neo4j/conf:/conf \ - --volume=/logs/neo4j:/logs \ - --user="$(id -u neo4j):$(id -g neo4j)" \ - --group-add=$groups \ + --publish=7474:7474 --publish=7687:7687 \ + --volume=/neo4j/data:/data \ + --volume=/neo4j/plugins:/plugins \ + --volume=/neo4j/conf:/conf \ + --volume=/logs/neo4j:/logs \ + --user="$(id -u neo4j):$(id -g neo4j)" \ + --group-add=$groups \ neo4j:3.4 > /bin/cat \.travis.yml\ -b | head -n1