Skip to content

Commit 4fed71d

Browse files
authored
enh(shell) recognize prompts that contain tilde(s) (#2859)
Resolves #2858.
1 parent c36d5ae commit 4fed71d

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ New Languages:
2323

2424
Language Improvements:
2525

26+
- enh(shell) Recognize prompts which contain tilde `~` (#2859) [Guillaume Grossetie][]
2627
- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][]
2728
- enh(autodetect) Over 30+ improvements to auto-detect (#2745) [Josh Goebel][]
2829
- 4-5% improvement in auto-detect against large sample set

src/languages/shell.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ export default function(hljs) {
1414
contains: [
1515
{
1616
className: 'meta',
17-
begin: /^\s{0,3}[/\w\d[\]()@-]*[>%$#]/,
17+
// We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
18+
// For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
19+
// echo /path/to/home > t.exe
20+
begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#]/,
1821
starts: {
1922
end: /[^\\](?=\s*$)/,
2023
subLanguage: 'bash'
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span class="hljs-meta">~/docs&gt;</span><span class="bash"> cat readme.adoc</span>
2+
= Highlight.js
3+
4+
Highlight.js is a syntax highlighter written in JavaScript.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
~/docs> cat readme.adoc
2+
= Highlight.js
3+
4+
Highlight.js is a syntax highlighter written in JavaScript.

0 commit comments

Comments
 (0)