Skip to content

Commit

Permalink
Support ? in PowerShell lexer (#1559)
Browse files Browse the repository at this point in the history
The `?` symbol is an alias for the `Where-Object` in PowerShell. This
commit adds support for it to Rouge.
  • Loading branch information
pyrmont authored Jul 14, 2020
1 parent 1863a89 commit 43846d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/powershell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Powershell < RegexLexer
push :parameters unless m[3].nil?
end

rule %r/\?/, Name::Function, :parameters
rule %r/[-+*\/%=!.&|]/, Operator
rule %r/@\{/, Punctuation, :hasht
rule %r/@\(/, Punctuation, :array
Expand Down
3 changes: 3 additions & 0 deletions spec/visual/samples/powershell
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,6 @@ $gitExeString = "$gitExeFolder\git.exe" &("$gitExeString") config --add --global
Get-ChildItem -Include *.txt `
-Recurse
Write-Output `$hello

# Where-Object alias
Get-process | ? {$_.workingset -gt 25000*1024}

0 comments on commit 43846d2

Please sign in to comment.