Skip to content

Commit a671c6f

Browse files
committed
Make straight and curly quotes equivalent
I think this language was written by trolls.
1 parent 1347a55 commit a671c6f

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

PowerShell.sublime-syntax

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -762,39 +762,39 @@ contexts:
762762
- include: single-quoted-heredoc-strings
763763

764764
single-quoted-strings:
765-
- match: \'
765+
- match: '{{single_quote}}'
766766
scope: punctuation.definition.string.begin.powershell
767767
push: inside-single-quoted-string
768768

769769
inside-single-quoted-string:
770770
- meta_include_prototype: false
771771
- meta_scope: meta.string.powershell string.quoted.single.powershell
772-
- match: "''"
772+
- match: '{{single_quote}}{2}'
773773
scope: constant.character.escape.powershell
774-
- match: \'
774+
- match: '{{single_quote}}'
775775
scope: punctuation.definition.string.end.powershell
776776
pop: 1
777777
- include: string-placeholders
778778

779779
double-quoted-strings:
780-
- match: '"'
780+
- match: '{{double_quote}}'
781781
scope: punctuation.definition.string.begin.powershell
782782
push: inside-double-quoted-string
783783

784784
inside-double-quoted-string:
785785
- meta_include_prototype: false
786786
- meta_scope: meta.string.interpolated.powershell string.quoted.double.powershell
787-
- match: '""'
787+
- match: '{{double_quote}}{2}'
788788
scope: constant.character.escape.powershell
789789
- include: escape-sequences
790-
- match: '"'
790+
- match: '{{double_quote}}'
791791
scope: punctuation.definition.string.end.powershell
792792
pop: 1
793793
- include: string-interpolations
794794
- include: string-placeholders
795795

796796
single-quoted-heredoc-strings:
797-
- match: \@'(?=$)
797+
- match: \@{{single_quote}}(?=$)
798798
scope: punctuation.definition.string.begin.powershell
799799
push:
800800
- inside-single-quoted-heredoc-string
@@ -805,24 +805,24 @@ contexts:
805805
- match: (?={{csharp_indicator}})
806806
set: scope:source.cs
807807
with_prototype:
808-
- match: (?=^'@)
808+
- match: (?=^{{single_quote}}@)
809809
pop: 1
810-
- match: "''"
810+
- match: '{{single_quote}}{2}'
811811
scope: constant.character.escape.powershell
812812
- include: else-pop
813813

814814
inside-single-quoted-heredoc-string:
815815
- meta_include_prototype: false
816816
- meta_scope: meta.string.powershell string.quoted.single.heredoc.powershell
817-
- match: ^'@
817+
- match: ^{{single_quote}}@
818818
scope: punctuation.definition.string.end.powershell
819819
pop: 1
820-
- match: "''"
820+
- match: '{{single_quote}}{2}'
821821
scope: constant.character.escape.powershell
822822
- include: string-placeholders
823823

824824
double-quoted-heredoc-strings:
825-
- match: \@"(?=$)
825+
- match: \@{{double_quote}}(?=$)
826826
scope: punctuation.definition.string.begin.powershell
827827
push:
828828
- inside-double-quoted-heredoc-string
@@ -831,7 +831,7 @@ contexts:
831831
inside-double-quoted-heredoc-string:
832832
- meta_include_prototype: false
833833
- meta_scope: meta.string.interpolated.powershell string.quoted.double.heredoc.powershell
834-
- match: ^"@
834+
- match: ^{{double_quote}}@
835835
scope: punctuation.definition.string.end.powershell
836836
pop: 1
837837
- include: escape-sequences
@@ -843,7 +843,7 @@ contexts:
843843
- match: (?={{csharp_indicator}})
844844
set: scope:source.cs
845845
with_prototype:
846-
- match: (?=^"@)
846+
- match: (?=^{{double_quote}}@)
847847
pop: 1
848848
- include: escape-sequences
849849
- include: else-pop
@@ -879,7 +879,7 @@ contexts:
879879
- match: \}
880880
scope: punctuation.definition.placeholder.end.powershell
881881
pop: 1
882-
- match: (?=['"])
882+
- match: (?={{single_quote}}|{{double_quote}})
883883
pop: 1
884884
- match: '[:,;]'
885885
scope: punctuation.separator.powershell
@@ -1021,7 +1021,7 @@ contexts:
10211021
scope: punctuation.separator.sequence.powershell
10221022

10231023
escape-sequences:
1024-
- match: '`[0abenfrvt"''$`]'
1024+
- match: '`(?:[0abenfrvt$`]|{{single_quote}}|{{double_quote}})'
10251025
scope: constant.character.escape.powershell
10261026
- match: '`u\{\h+\}'
10271027
scope: constant.character.escape.powershell
@@ -1162,6 +1162,8 @@ variables:
11621162
)
11631163
11641164
# Strings
1165+
single_quote: "['‘’]"
1166+
double_quote: '["“”]'
11651167
csharp_indicator: |-
11661168
(?x: \s* (?:
11671169
using\s+System[.;]

Tests/syntax_test_strings.ps1

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
# ^ punctuation.definition.string.begin.powershell
4242
# ^ punctuation.definition.string.end.powershell
4343

44+
curly ‘‘quotes'’ are equivalent to straight ones'
45+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell
46+
# ^ punctuation.definition.string.begin.powershell
47+
# ^^ constant.character.escape.powershell
48+
# ^^ constant.character.escape.powershell
49+
# ^ punctuation.definition.string.end.powershell
50+
4451
@'
4552
# ^^ meta.string.powershell string.quoted.single.heredoc.powershell punctuation.definition.string.begin.powershell - meta.string.interpolated
4653
A 'single quoted' "heredoc"
@@ -167,6 +174,13 @@
167174
# ^ punctuation.section.interpolation.end
168175
# @@@@@@@@@@@@@@@@ reference
169176

177+
curly ““quotes"” are equivalent to straight ones"
178+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell
179+
# ^ punctuation.definition.string.begin.powershell
180+
# ^^ constant.character.escape.powershell
181+
# ^^ constant.character.escape.powershell
182+
# ^ punctuation.definition.string.end.powershell
183+
170184
# Double quoted here-string
171185
@"
172186
# ^^ meta.string.interpolated.powershell string.quoted.double.heredoc.powershell punctuation.definition.string.begin.powershell

0 commit comments

Comments
 (0)