Skip to content

Commit b323e90

Browse files
committed
enh(shell) allow period in prompt match (#4244)
Allow a "." to match in the prompt section of shell/console examples.
1 parent 9a70b83 commit b323e90

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Core Grammars:
1313
- fix(ex) adds support for `?'` char literal and missing `defguardp` keyword [Kevin Bloch][]
1414
- fix(diff) fix unified diff hunk header regex to allow unpaired numbers [Chris Wilson][]
1515
- enh(php) support single line and hash comments in attributes, constructor and functions [Antoine Musso][]
16+
- enh(shell) match period (.) as part of shell prompt [Ian Wienand][]
1617

1718
CONTRIBUTORS
1819

@@ -23,6 +24,7 @@ CONTRIBUTORS
2324
[Chris Wilson]: https://github.com/sushicw
2425
[Antoine Musso]: https://github.com/hashar
2526
[Chester Moses]: https://github.com/Chester-Moses-HCL
27+
[Ian Wienand]: https://github.com/ianw
2628

2729

2830
## Version 11.11.1

src/languages/shell.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default function(hljs) {
2020
// We cannot add \s (spaces) in the regular expression otherwise it will be too broad and produce unexpected result.
2121
// For instance, in the following example, it would match "echo /path/to/home >" as a prompt:
2222
// echo /path/to/home > t.exe
23-
begin: /^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,
23+
begin: /^\s{0,3}[./~\w\d[\]()@-]*[>%$#][ ]?/,
2424
starts: {
2525
end: /[^\\](?=\s*$)/,
2626
subLanguage: 'bash'

test/markup/shell/prompt-with-slash.expect.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<span class="hljs-meta prompt_">pao-sw-a04-40(config)# </span><span class="language-bash">interface range ethernet 1/1/1-1/1/9</span>
2-
<span class="hljs-meta prompt_">pao-sw-a04-42(conf-range-eth1/1/1-1/1/9)# </span><span class="language-bash">switchport trunk allowed vlan 1102</span>
3-
<span class="hljs-meta prompt_">pao-sw-a04-42(conf-range-eth1/1/1-1/1/9)# </span><span class="language-bash">show configuration</span>
1+
<span class="hljs-meta prompt_">pao.sw.a04-40(config)# </span><span class="language-bash">interface range ethernet 1/1/1-1/1/9</span>
2+
<span class="hljs-meta prompt_">pao.sw.a04-42(conf-range-eth1/1/1-1/1/9)# </span><span class="language-bash">switchport trunk allowed vlan 1102</span>
3+
<span class="hljs-meta prompt_">pao.sw.a04-42(conf-range-eth1/1/1-1/1/9)# </span><span class="language-bash">show configuration</span>
44
!
55
interface ethernet1/1/1
66
description pao-sw-a03-09_port56

test/markup/shell/prompt-with-slash.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pao-sw-a04-40(config)# interface range ethernet 1/1/1-1/1/9
2-
pao-sw-a04-42(conf-range-eth1/1/1-1/1/9)# switchport trunk allowed vlan 1102
3-
pao-sw-a04-42(conf-range-eth1/1/1-1/1/9)# show configuration
1+
pao.sw.a04-40(config)# interface range ethernet 1/1/1-1/1/9
2+
pao.sw.a04-42(conf-range-eth1/1/1-1/1/9)# switchport trunk allowed vlan 1102
3+
pao.sw.a04-42(conf-range-eth1/1/1-1/1/9)# show configuration
44
!
55
interface ethernet1/1/1
66
description pao-sw-a03-09_port56

0 commit comments

Comments
 (0)