Skip to content

Commit 2c7a05f

Browse files
committed
Syntax: Improve shell line continuation
Try to continue commands' contexts after line continuation operators
1 parent e1f5d4e commit 2c7a05f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

syntaxes/Shell (for Markdown).sublime-syntax

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ contexts:
1414
- match: ^\s*(>)\s
1515
captures:
1616
1: comment.other.shell
17-
scope: comment.other.shell
1817

1918
main:
2019
- match: ^(?=\s*\$\s)
@@ -27,3 +26,12 @@ contexts:
2726
1: comment.other.shell
2827
embed: statements
2928
escape: (?<![^\\]\\)(?<![\\]{3})\n
29+
30+
line-continuation-body:
31+
- meta_prepend: true
32+
- meta_include_prototype: false
33+
# continuation lines begin with `> `
34+
- match: ^\s*(>)\s
35+
captures:
36+
1: comment.other.shell
37+
pop: 1

tests/syntax_test_markdown.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ foo
17901790
# test
17911791
| ^^^^^ source.shell comment.line.number-sign
17921792
echo hello, \
1793-
| ^^ punctuation.separator.continuation.line
1793+
| ^ punctuation.separator.continuation.line
17941794
echo This is a smiley :-\) \(I have to escape the parentheses, though!\)
17951795
| ^^ constant.character.escape
17961796
```
@@ -2045,7 +2045,7 @@ unclosed_paren = (
20452045
function foo () {
20462046
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell keyword.declaration.function.shell
20472047
}
2048-
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell meta.compound.shell punctuation.section.compound.end.shell
2048+
| <- markup.raw.code-fence.shell.markdown-gfm meta.function.shell punctuation.section
20492049

20502050
$ ls ~
20512051
| <- markup.raw.code-fence.shell.markdown-gfm source.shell.interactive comment.other.shell

0 commit comments

Comments
 (0)