From d3e8b3ce35ea469413e979c4d9619363ef6bf7bd Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Thu, 24 Apr 2025 11:52:23 +1000 Subject: [PATCH] enh(shell) allow period in prompt match (#4244) Allow a "." to match in the prompt section of shell/console examples. --- CHANGES.md | 1 + src/languages/shell.js | 2 +- test/markup/shell/prompt-with-period.expect.txt | 1 + test/markup/shell/prompt-with-period.txt | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 test/markup/shell/prompt-with-period.expect.txt create mode 100644 test/markup/shell/prompt-with-period.txt diff --git a/CHANGES.md b/CHANGES.md index b1413c29a5..08af8f3062 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,6 +26,7 @@ Core Grammars: - enh(json) add json5 support [Kerry Shetline][] - fix(css) `unicode-range` parsing, issue #4253 [Kerry Shetline][] - fix(csharp) Support digit separators [te-ing][] +- enh(shell) match period (.) as part of shell prompt [Ian Wienand][] Documentation: diff --git a/src/languages/shell.js b/src/languages/shell.js index 2fd6337409..0d3a38825c 100644 --- a/src/languages/shell.js +++ b/src/languages/shell.js @@ -20,7 +20,7 @@ export default function(hljs) { // We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result. // For instance, in the following example, it would match "echo /path/to/home >" as a prompt: // echo /path/to/home > t.exe - begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/, + begin: /^\s{0,3}[./~\w\d[\]()@-]*[>%$#][ ]?/, starts: { end: /[^\\](?=\s*$)/, subLanguage: 'bash' diff --git a/test/markup/shell/prompt-with-period.expect.txt b/test/markup/shell/prompt-with-period.expect.txt new file mode 100644 index 0000000000..99cb77098b --- /dev/null +++ b/test/markup/shell/prompt-with-period.expect.txt @@ -0,0 +1 @@ +~/git-repo[branch-1.0]$ ls a.file diff --git a/test/markup/shell/prompt-with-period.txt b/test/markup/shell/prompt-with-period.txt new file mode 100644 index 0000000000..5cf46f72b2 --- /dev/null +++ b/test/markup/shell/prompt-with-period.txt @@ -0,0 +1 @@ +~/git-repo[branch-1.0]$ ls a.file