Skip to content

Commit 1bb3e44

Browse files
authored
Enable extending syntaxes to override indentation constrints (#224)
This commit introduces `no_indent` variable, inspired by Bash, to enable extending syntaxes to override indentation constraints. Use cases: - embed powershell in indented fenced code blocks in Markdown - embed powershell in YAML files, such as GitHub Action workflows
1 parent cf1caf9 commit 1bb3e44

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

PowerShell.sublime-syntax

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ contexts:
10821082
- match: (?={{csharp_indicator}})
10831083
set: scope:source.cs.embedded.powershell
10841084
with_prototype:
1085-
- match: (?=^{{single_quote}}@)
1085+
- match: (?={{no_indent}}{{single_quote}}@)
10861086
pop: 1
10871087
- match: '{{single_quote}}{2}'
10881088
scope: constant.character.escape.powershell
@@ -1091,8 +1091,9 @@ contexts:
10911091
inside-single-quoted-heredoc-string:
10921092
- meta_include_prototype: false
10931093
- meta_scope: meta.string.powershell string.quoted.single.heredoc.powershell
1094-
- match: ^{{single_quote}}@
1095-
scope: punctuation.definition.string.end.powershell
1094+
- match: '{{no_indent}}({{single_quote}}@)'
1095+
captures:
1096+
1: punctuation.definition.string.end.powershell
10961097
pop: 1
10971098
- match: '{{single_quote}}{2}'
10981099
scope: constant.character.escape.powershell
@@ -1108,8 +1109,9 @@ contexts:
11081109
inside-double-quoted-heredoc-string:
11091110
- meta_include_prototype: false
11101111
- meta_scope: meta.string.interpolated.powershell string.quoted.double.heredoc.powershell
1111-
- match: ^{{double_quote}}@
1112-
scope: punctuation.definition.string.end.powershell
1112+
- match: '{{no_indent}}({{double_quote}}@)'
1113+
captures:
1114+
1: punctuation.definition.string.end.powershell
11131115
pop: 1
11141116
- include: escape-sequences
11151117
- include: string-interpolations
@@ -1120,7 +1122,7 @@ contexts:
11201122
- match: (?={{csharp_indicator}})
11211123
set: scope:source.cs.embedded.powershell
11221124
with_prototype:
1123-
- match: (?=^{{double_quote}}@)
1125+
- match: (?={{no_indent}}{{double_quote}}@)
11241126
pop: 1
11251127
- include: escape-sequences
11261128
- include: else-pop
@@ -1425,6 +1427,9 @@ variables:
14251427
)\b
14261428
shebang_language: \b(?:pwsh|powershell)\b
14271429

1430+
# Indentation and whitespace patterns
1431+
no_indent: ^
1432+
14281433
# Attributes
14291434
attributes: |-
14301435
\b(?xi:

0 commit comments

Comments
 (0)