Skip to content

Commit c36d5ae

Browse files
authored
enh(shell) Support multiline commands (#2861)
1 parent 3375ec6 commit c36d5ae

File tree

9 files changed

+40
-2
lines changed

9 files changed

+40
-2
lines changed

AUTHORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,3 +309,4 @@ Contributors:
309309
- Patrick Scheibe <patrick@halirutan.de>
310310
- Kyle Brown <kylebrown9@github>
311311
- Marcus Ortiz <mportiz08@gmail.com>
312+
- Guillaume Grossetie <ggrossetie@yuzutech.fr>

CHANGES.md

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

2424
Language Improvements:
2525

26+
- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][]
2627
- enh(autodetect) Over 30+ improvements to auto-detect (#2745) [Josh Goebel][]
2728
- 4-5% improvement in auto-detect against large sample set
2829
- properties, angelscript, lsl, javascript, n1ql, ocaml, ruby
@@ -67,6 +68,7 @@ New themes:
6768
- *StackOverflow Dark* by [Jan Pilzer][]
6869
- *StackOverflow Light* by [Jan Pilzer][]
6970

71+
[Guillaume Grossetie]: https://github.com/mogztter
7072
[Brad Chamberlain]: https://github.com/bradcray
7173
[Marat Nagayev]: https://github.com/nagayev
7274
[Fredrik Ekre]: https://github.com/fredrikekre

src/languages/shell.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@ Language: Shell Session
33
Requires: bash.js
44
Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
55
Category: common
6+
Audit: 2020
67
*/
78

9+
/** @type LanguageFn */
810
export default function(hljs) {
911
return {
1012
name: 'Shell Session',
1113
aliases: ['console'],
1214
contains: [
1315
{
1416
className: 'meta',
15-
begin: '^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]',
17+
begin: /^\s{0,3}[/\w\d[\]()@-]*[>%$#]/,
1618
starts: {
17-
end: '$', subLanguage: 'bash'
19+
end: /[^\\](?=\s*$)/,
20+
subLanguage: 'bash'
1821
}
1922
}
2023
]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<span class="hljs-meta">$</span><span class="bash"> docker run \
2+
--publish=7474:7474 --publish=7687:7687 \
3+
--volume=/neo4j/data:/data \
4+
--volume=/neo4j/plugins:/plugins \
5+
--volume=/neo4j/conf:/conf \
6+
--volume=/logs/neo4j:/logs \
7+
--user=<span class="hljs-string">&quot;<span class="hljs-subst">$(id -u neo4j)</span>:<span class="hljs-subst">$(id -g neo4j)</span>&quot;</span> \
8+
--group-add=<span class="hljs-variable">$groups</span> \
9+
neo4j:3.4</span>
10+
<span class="hljs-meta">&gt;</span><span class="bash"> /bin/cat \.travis.yml\
11+
-b | head -n1</span>
12+
1 language: node_js
13+
<span class="hljs-meta">&gt;</span><span class="bash"> <span class="hljs-built_in">echo</span> <span class="hljs-string">&#x27;hello&#x27;</span></span>
14+
hello
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
$ docker run \
2+
--publish=7474:7474 --publish=7687:7687 \
3+
--volume=/neo4j/data:/data \
4+
--volume=/neo4j/plugins:/plugins \
5+
--volume=/neo4j/conf:/conf \
6+
--volume=/logs/neo4j:/logs \
7+
--user="$(id -u neo4j):$(id -g neo4j)" \
8+
--group-add=$groups \
9+
neo4j:3.4
10+
> /bin/cat \.travis.yml\
11+
-b | head -n1
12+
1 language: node_js
13+
> echo 'hello'
14+
hello
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span class="hljs-meta">&gt;</span><span class="bash"> /bin/sh</span>

test/markup/shell/simple.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> /bin/sh
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<span class="hljs-meta">$</span><span class="bash"> <span class="hljs-built_in">echo</span> <span class="hljs-string">&quot;<span class="hljs-variable">$HOME</span>&quot;</span> -n</span>

test/markup/shell/single.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ echo "$HOME" -n

0 commit comments

Comments
 (0)