Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(shell) Support multiline commands #2861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.txt
Expand Up @@ -309,3 +309,4 @@ Contributors:
- Patrick Scheibe <patrick@halirutan.de>
- Kyle Brown <kylebrown9@github>
- Marcus Ortiz <mportiz08@gmail.com>
- Guillaume Grossetie <ggrossetie@yuzutech.fr>
2 changes: 2 additions & 0 deletions CHANGES.md
Expand Up @@ -23,6 +23,7 @@ New Languages:

Language Improvements:

- enh(shell) Add support for multiline commands with line continuation `\` (#2861) [Guillaume Grossetie][]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshgoebel I'm confused, this language improvement is not part of the 10.4.0-beta1 right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct really they heading should probably change. Betas aren’t the same as releases though they’re rolling so things just keep getting added until we have a release

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So really the header and should be 10.4 rolling or some such. I’ll give it some thought. I only updated it because we have to update the header for production releases but that’s not true for beta releases so we have more flexibility there.

- 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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/languages/shell.js
Expand Up @@ -3,18 +3,21 @@ Language: Shell Session
Requires: bash.js
Author: TSUYUSATO Kitsune <make.just.on@gmail.com>
Category: common
Audit: 2020
*/

/** @type LanguageFn */
export default function(hljs) {
return {
name: 'Shell Session',
aliases: ['console'],
contains: [
{
className: 'meta',
begin: '^\\s{0,3}[/\\w\\d\\[\\]()@-]*[>%$#]',
begin: /^\s{0,3}[/\w\d[\]()@-]*[>%$#]/,
starts: {
end: '$', subLanguage: 'bash'
end: /[^\\](?=\s*$)/,
subLanguage: 'bash'
}
}
]
Expand Down
14 changes: 14 additions & 0 deletions test/markup/shell/command-continuation.expect.txt
@@ -0,0 +1,14 @@
<span class="hljs-meta">$</span><span class="bash"> 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=<span class="hljs-string">&quot;<span class="hljs-subst">$(id -u neo4j)</span>:<span class="hljs-subst">$(id -g neo4j)</span>&quot;</span> \
--group-add=<span class="hljs-variable">$groups</span> \
neo4j:3.4</span>
<span class="hljs-meta">&gt;</span><span class="bash"> /bin/cat \.travis.yml\
-b | head -n1</span>
1 language: node_js
<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>
hello
14 changes: 14 additions & 0 deletions 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
1 change: 1 addition & 0 deletions test/markup/shell/simple.expect.txt
@@ -0,0 +1 @@
<span class="hljs-meta">&gt;</span><span class="bash"> /bin/sh</span>
1 change: 1 addition & 0 deletions test/markup/shell/simple.txt
@@ -0,0 +1 @@
> /bin/sh
1 change: 1 addition & 0 deletions test/markup/shell/single.expect.txt
@@ -0,0 +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>
1 change: 1 addition & 0 deletions test/markup/shell/single.txt
@@ -0,0 +1 @@
$ echo "$HOME" -n