summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoramitkummer <49096391+amitkummer@users.noreply.github.com>2021-03-28 13:25:56 +0300
committerGitHub <noreply@github.com>2021-03-28 12:25:56 +0200
commit74be9c006bca44e2c83dc6812caf9165da3c5a06 (patch)
treea7b40d2c6abddc04b9837cb7a2ff684ee3837401
parent2095bd9f9b25821bd8e8770b165ceb9288763d29 (diff)
downloadpygments-git-74be9c006bca44e2c83dc6812caf9165da3c5a06.tar.gz
PowerShell: lex ':' (#1758)
-rw-r--r--pygments/lexers/shell.py2
-rw-r--r--tests/snippets/powershell/test_colon_punctuation.txt35
-rw-r--r--tests/snippets/powershell/test_remoting_session.txt4
-rw-r--r--tests/snippets/powershell/test_session.txt2
4 files changed, 39 insertions, 4 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py
index 6283a11a..83529d17 100644
--- a/pygments/lexers/shell.py
+++ b/pygments/lexers/shell.py
@@ -730,7 +730,7 @@ class PowerShellLexer(RegexLexer):
(r'\[[a-z_\[][\w. `,\[\]]*\]', Name.Constant), # .net [type]s
(r'-[a-z_]\w*', Name),
(r'\w+', Name),
- (r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation),
+ (r'[.,;:@{}\[\]$()=+*/\\&%!~?^`|<>-]', Punctuation),
],
'child': [
(r'\)', Punctuation, '#pop'),
diff --git a/tests/snippets/powershell/test_colon_punctuation.txt b/tests/snippets/powershell/test_colon_punctuation.txt
new file mode 100644
index 00000000..72733c3a
--- /dev/null
+++ b/tests/snippets/powershell/test_colon_punctuation.txt
@@ -0,0 +1,35 @@
+---input---
+$message = (Test-Path C:\) ? "Path exists" : "Path not found"
+[math]::pi
+
+---tokens---
+'$message' Name.Variable
+' ' Text
+'=' Punctuation
+' ' Text
+'(' Punctuation
+'Test-Path' Name.Builtin
+' ' Text
+'C' Name
+':' Punctuation
+'\\' Punctuation
+')' Punctuation
+' ' Text
+'?' Punctuation
+' ' Text
+'"' Literal.String.Double
+'Path exists' Literal.String.Double
+'"' Literal.String.Double
+' ' Text
+':' Punctuation
+' ' Text
+'"' Literal.String.Double
+'Path not found' Literal.String.Double
+'"' Literal.String.Double
+'\n' Text
+
+'[math]' Name.Constant
+':' Punctuation
+':' Punctuation
+'pi' Name
+'\n' Text
diff --git a/tests/snippets/powershell/test_remoting_session.txt b/tests/snippets/powershell/test_remoting_session.txt
index 9d9db603..23fa9c2e 100644
--- a/tests/snippets/powershell/test_remoting_session.txt
+++ b/tests/snippets/powershell/test_remoting_session.txt
@@ -7,11 +7,11 @@
'-NetBIOS' Name
'-Hostname' Name
']' Punctuation
-':' Error
+':' Punctuation
' ' Text
'PS ' Name.Builtin
'C' Name
-':' Error
+':' Punctuation
'\\' Punctuation
'>' Punctuation
' ' Text
diff --git a/tests/snippets/powershell/test_session.txt b/tests/snippets/powershell/test_session.txt
index 38212440..7fe8b42a 100644
--- a/tests/snippets/powershell/test_session.txt
+++ b/tests/snippets/powershell/test_session.txt
@@ -8,7 +8,7 @@ PS > Get-ChildItem
---tokens---
'PS ' Name.Builtin
'C' Name
-':' Error
+':' Punctuation
'\\' Punctuation
'>' Punctuation
' ' Text