Skip to content

Commit

Permalink
Powershell: Add support for two levels of nested brackets inside name…
Browse files Browse the repository at this point in the history
…space pattern. Fixes #1317
  • Loading branch information
Golmote committed Mar 1, 2018
1 parent 8c3fa00 commit 3bc3e9c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/prism-powershell.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Prism.languages.powershell = {
}
],
// Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices
'namespace': /\[[a-z][\s\S]*?\]/i,
// Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`)
'namespace': /\[[a-z](?:\[(?:\[[^\]]*]|[^\[\]])*]|[^\[\]])*]/i,
'boolean': /\$(?:true|false)\b/i,
'variable': /\$\w+\b/i,
// Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example
Expand Down
2 changes: 1 addition & 1 deletion components/prism-powershell.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion tests/languages/powershell/namespace_feature.test
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[System.String]::Empty;
[Foo.Bar+Baz]::Abc;
[int] 42;
[string[]]
[OutputType([System.Collections.Generic.List[int]])]

----------------------------------------------------

[
["namespace", "[System.String]"],"::Empty",["punctuation", ";"],
["namespace", "[Foo.Bar+Baz]"],"::Abc",["punctuation", ";"],
["namespace", "[int]"]," 42",["punctuation", ";"]
["namespace", "[int]"]," 42",["punctuation", ";"],
["namespace", "[string[]]"],
["namespace", "[OutputType([System.Collections.Generic.List[int]])]"]
]
----------------------------------------------------

Expand Down

0 comments on commit 3bc3e9c

Please sign in to comment.