diff options
author | gentoo90 <gentoo90@gmail.com> | 2013-04-07 15:10:09 +0300 |
---|---|---|
committer | gentoo90 <gentoo90@gmail.com> | 2013-04-07 15:10:09 +0300 |
commit | 14148cc741435cbe7020ccd37e4b08cbfdb2c8c9 (patch) | |
tree | b0dd15e611c41ae36924513724bf4f71a263917c /pygments | |
parent | e3a78c5d8d322c10d456ff29ab8d6f08a0a061e3 (diff) | |
download | pygments-14148cc741435cbe7020ccd37e4b08cbfdb2c8c9.tar.gz |
PowerShellLexer: minor fixes
Add *.psm1 file extension
Here-strings can be nested now
Recognize escape characters in double-quoted strings
Add '@', ';' and '::' to punctuation
Diffstat (limited to 'pygments')
-rw-r--r-- | pygments/lexers/shell.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pygments/lexers/shell.py b/pygments/lexers/shell.py index b95faf93..bc084b4c 100644 --- a/pygments/lexers/shell.py +++ b/pygments/lexers/shell.py @@ -329,8 +329,8 @@ class PowerShellLexer(RegexLexer): *New in Pygments 1.5.* """ name = 'PowerShell' - aliases = ['powershell', 'posh', 'ps1'] - filenames = ['*.ps1'] + aliases = ['powershell', 'posh', 'ps1', 'psm1'] + filenames = ['*.ps1','*.psm1'] mimetypes = ['text/x-powershell'] flags = re.DOTALL | re.IGNORECASE | re.MULTILINE @@ -373,8 +373,8 @@ class PowerShellLexer(RegexLexer): bygroups(Comment, String.Doc, Comment)), (r'#[^\n]*?$', Comment), (r'(<|<)#', Comment.Multiline, 'multline'), - (r'@"\n.*?\n"@', String.Heredoc), - (r"@'\n.*?\n'@", String.Heredoc), + (r'@"\n', String.Heredoc, 'heredoc-double'), + (r"@'\n", String.Heredoc, 'heredoc-single'), # escaped syntax (r'`[\'"$@-]', Punctuation), (r'"', String.Double, 'string'), @@ -387,7 +387,7 @@ class PowerShellLexer(RegexLexer): (r'\[[a-z_\[][a-z0-9_. `,\[\]]*\]', Name.Constant), # .net [type]s (r'-[a-z_][a-z0-9_]*', Name), (r'\w+', Name), - (r'[.,{}\[\]$()=+*/\\&%!~?^`|<>-]', Punctuation), + (r'([.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::)', Punctuation), ], 'multline': [ (r'[^#&.]+', Comment.Multiline), @@ -396,12 +396,25 @@ class PowerShellLexer(RegexLexer): (r'[#&.]', Comment.Multiline), ], 'string': [ + (r"`[0abfnrtv'\"\$]", String.Escape), (r'[^$`"]+', String.Double), (r'\$\(', String.Interpol, 'interpol'), - (r'`"|""', String.Double), + (r'""', String.Double), (r'[`$]', String.Double), (r'"', String.Double, '#pop'), ], + 'heredoc-double': [ + (r'@"\n', String.Heredoc, '#push'), + (r"@'\n", String.Heredoc, 'heredoc-single'), + (r'\n"@', String.Heredoc, '#pop'), + (r".", String.Heredoc), + ], + 'heredoc-single': [ + (r'@"\n', String.Heredoc, 'heredoc-double'), + (r"@'\n", String.Heredoc, '#push'), + (r"\n'@", String.Heredoc, '#pop'), + (r".", String.Heredoc), + ], 'interpol': [ (r'[^$)]+', String.Interpol), (r'\$\(', String.Interpol, '#push'), |