diff --git a/AUTHORS.txt b/AUTHORS.txt index 1432d17ca0..68d7233d31 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -309,3 +309,4 @@ Contributors: - Patrick Scheibe - Kyle Brown - Marcus Ortiz +- Guillaume Grossetie diff --git a/CHANGES.md b/CHANGES.md index d742756157..e5197e6b04 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -23,6 +23,7 @@ New Languages: Language Improvements: +- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][] - enh(autodetect) Over 30+ improvements to auto-detect (#2745) [Josh Goebel][] - 4-5% improvement in auto-detect against large sample set - properties, angelscript, lsl, javascript, n1ql, ocaml, ruby @@ -67,6 +68,7 @@ New themes: - *StackOverflow Dark* by [Jan Pilzer][] - *StackOverflow Light* by [Jan Pilzer][] +[Guillaume Grossetie]: https://github.com/mogztter [Brad Chamberlain]: https://github.com/bradcray [Marat Nagayev]: https://github.com/nagayev [Fredrik Ekre]: https://github.com/fredrikekre diff --git a/src/languages/shell.js b/src/languages/shell.js index 3a1bc033ad..7e833ee768 100644 --- a/src/languages/shell.js +++ b/src/languages/shell.js @@ -3,8 +3,10 @@ Language: Shell Session Requires: bash.js Author: TSUYUSATO Kitsune Category: common +Audit: 2020 */ +/** @type LanguageFn */ export default function(hljs) { return { name: 'Shell Session', @@ -12,9 +14,10 @@ export default function(hljs) { contains: [ { className: 'meta', - begin: '^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]', + begin: /^\s{0,3}[/\w\d[\]()@-]*[>%$#]/, starts: { - end: '$', subLanguage: 'bash' + end: /[^\\](?=\s*$)/, + subLanguage: 'bash' } } ] diff --git a/test/markup/shell/command-continuation.expect.txt b/test/markup/shell/command-continuation.expect.txt new file mode 100644 index 0000000000..83a2637b16 --- /dev/null +++ b/test/markup/shell/command-continuation.expect.txt @@ -0,0 +1,14 @@ +$ 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 \ + neo4j:3.4 +> /bin/cat \.travis.yml\ + -b | head -n1 + 1 language: node_js +> echo 'hello' +hello diff --git a/test/markup/shell/command-continuation.txt b/test/markup/shell/command-continuation.txt new file mode 100644 index 0000000000..1c3a443c2e --- /dev/null +++ b/test/markup/shell/command-continuation.txt @@ -0,0 +1,14 @@ +$ 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 \ + neo4j:3.4 +> /bin/cat \.travis.yml\ + -b | head -n1 + 1 language: node_js +> echo 'hello' +hello diff --git a/test/markup/shell/simple.expect.txt b/test/markup/shell/simple.expect.txt new file mode 100644 index 0000000000..8aa9c49e6f --- /dev/null +++ b/test/markup/shell/simple.expect.txt @@ -0,0 +1 @@ +> /bin/sh diff --git a/test/markup/shell/simple.txt b/test/markup/shell/simple.txt new file mode 100644 index 0000000000..8297a69a5c --- /dev/null +++ b/test/markup/shell/simple.txt @@ -0,0 +1 @@ +> /bin/sh diff --git a/test/markup/shell/single.expect.txt b/test/markup/shell/single.expect.txt new file mode 100644 index 0000000000..093bdaa908 --- /dev/null +++ b/test/markup/shell/single.expect.txt @@ -0,0 +1 @@ +$ echo "$HOME" -n diff --git a/test/markup/shell/single.txt b/test/markup/shell/single.txt new file mode 100644 index 0000000000..b05aae75fd --- /dev/null +++ b/test/markup/shell/single.txt @@ -0,0 +1 @@ +$ echo "$HOME" -n