gitlab-pygments.rb 0.3.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +1 -1
- data/LICENSE +17 -0
- data/README.md +28 -1
- data/Rakefile +2 -5
- data/lexers +0 -0
- data/lib/pygments/mentos.py +19 -12
- data/lib/pygments/popen.rb +21 -4
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -0
- data/test/test_pygments.rb +13 -2
- data/vendor/custom_lexers/github.py +206 -3
- data/vendor/pygments-main/AUTHORS +41 -3
- data/vendor/pygments-main/CHANGES +132 -5
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/Makefile +1 -1
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/docs/generate.py +1 -1
- data/vendor/pygments-main/docs/src/api.txt +1 -1
- data/vendor/pygments-main/docs/src/index.txt +1 -1
- data/vendor/pygments-main/docs/src/integrate.txt +5 -0
- data/vendor/pygments-main/docs/src/java.txt +70 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +52 -0
- data/vendor/pygments-main/external/autopygmentize +64 -0
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
- data/vendor/pygments-main/external/markdown-processor.py +2 -2
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive-old.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +1 -1
- data/vendor/pygments-main/pygmentize +1 -1
- data/vendor/pygments-main/pygments/__init__.py +2 -2
- data/vendor/pygments-main/pygments/cmdline.py +14 -6
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +3 -4
- data/vendor/pygments-main/pygments/formatter.py +4 -1
- data/vendor/pygments-main/pygments/formatters/__init__.py +1 -1
- data/vendor/pygments-main/pygments/formatters/_mapping.py +3 -3
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +73 -2
- data/vendor/pygments-main/pygments/formatters/img.py +2 -2
- data/vendor/pygments-main/pygments/formatters/latex.py +9 -9
- data/vendor/pygments-main/pygments/formatters/other.py +1 -3
- data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
- data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
- data/vendor/pygments-main/pygments/lexer.py +78 -10
- data/vendor/pygments-main/pygments/lexers/__init__.py +13 -2
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_mapping.py +92 -36
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +4 -3
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +11 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -3
- data/vendor/pygments-main/pygments/lexers/agile.py +525 -38
- data/vendor/pygments-main/pygments/lexers/asm.py +45 -7
- data/vendor/pygments-main/pygments/lexers/compiled.py +1257 -425
- data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +97 -62
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +931 -32
- data/vendor/pygments-main/pygments/lexers/github.py +206 -3
- data/vendor/pygments-main/pygments/lexers/hdl.py +3 -3
- data/vendor/pygments-main/pygments/lexers/jvm.py +309 -44
- data/vendor/pygments-main/pygments/lexers/math.py +876 -30
- data/vendor/pygments-main/pygments/lexers/other.py +956 -517
- data/vendor/pygments-main/pygments/lexers/parsers.py +85 -2
- data/vendor/pygments-main/pygments/lexers/shell.py +81 -18
- data/vendor/pygments-main/pygments/lexers/special.py +1 -1
- data/vendor/pygments-main/pygments/lexers/sql.py +2 -2
- data/vendor/pygments-main/pygments/lexers/templates.py +119 -8
- data/vendor/pygments-main/pygments/lexers/text.py +155 -15
- data/vendor/pygments-main/pygments/lexers/web.py +1578 -397
- data/vendor/pygments-main/pygments/modeline.py +40 -0
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/style.py +1 -1
- data/vendor/pygments-main/pygments/styles/__init__.py +1 -1
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
- data/vendor/pygments-main/pygments/styles/borland.py +1 -1
- data/vendor/pygments-main/pygments/styles/bw.py +1 -1
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
- data/vendor/pygments-main/pygments/styles/default.py +1 -1
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
- data/vendor/pygments-main/pygments/styles/native.py +1 -1
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/tango.py +1 -1
- data/vendor/pygments-main/pygments/styles/trac.py +1 -1
- data/vendor/pygments-main/pygments/styles/vim.py +1 -1
- data/vendor/pygments-main/pygments/styles/vs.py +1 -1
- data/vendor/pygments-main/pygments/token.py +1 -1
- data/vendor/pygments-main/pygments/unistring.py +36 -26
- data/vendor/pygments-main/pygments/util.py +46 -1
- data/vendor/pygments-main/scripts/check_sources.py +2 -2
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +2 -0
- data/vendor/pygments-main/scripts/find_codetags.py +1 -1
- data/vendor/pygments-main/scripts/find_error.py +5 -6
- data/vendor/pygments-main/setup.cfg +1 -0
- data/vendor/pygments-main/setup.py +6 -4
- data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
- data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
- data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
- data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
- data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
- data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +89 -4
- data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
- data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
- data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
- data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
- data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
- data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
- data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
- data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
- data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
- data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
- data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
- data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
- data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
- data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
- data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
- data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +2 -1
- data/vendor/pygments-main/tests/examplefiles/http_response_example +4 -2
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +5 -2
- data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
- data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +7 -0
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
- data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
- data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
- data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
- data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +149 -115
- data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
- data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
- data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
- data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
- data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +16 -0
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
- data/vendor/pygments-main/tests/old_run.py +1 -1
- data/vendor/pygments-main/tests/run.py +3 -2
- data/vendor/pygments-main/tests/support/tags +36 -0
- data/vendor/pygments-main/tests/test_basic_api.py +4 -3
- data/vendor/pygments-main/tests/test_clexer.py +1 -1
- data/vendor/pygments-main/tests/test_cmdline.py +1 -1
- data/vendor/pygments-main/tests/test_examplefiles.py +3 -1
- data/vendor/pygments-main/tests/test_html_formatter.py +17 -1
- data/vendor/pygments-main/tests/test_latex_formatter.py +1 -1
- data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_regexlexer.py +1 -1
- data/vendor/pygments-main/tests/test_token.py +1 -1
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +22 -3
- metadata +84 -16
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Lexers for parser generators.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
@@ -28,7 +28,8 @@ __all__ = ['RagelLexer', 'RagelEmbeddedLexer', 'RagelCLexer', 'RagelDLexer',
|
|
28
28
|
'AntlrPerlLexer', 'AntlrRubyLexer', 'AntlrCppLexer',
|
29
29
|
#'AntlrCLexer',
|
30
30
|
'AntlrCSharpLexer', 'AntlrObjectiveCLexer',
|
31
|
-
'AntlrJavaLexer', "AntlrActionScriptLexer"
|
31
|
+
'AntlrJavaLexer', "AntlrActionScriptLexer",
|
32
|
+
'TreetopLexer']
|
32
33
|
|
33
34
|
|
34
35
|
class RagelLexer(RegexLexer):
|
@@ -693,3 +694,85 @@ class AntlrActionScriptLexer(DelegatingLexer):
|
|
693
694
|
def analyse_text(text):
|
694
695
|
return AntlrLexer.analyse_text(text) and \
|
695
696
|
re.search(r'^\s*language\s*=\s*ActionScript\s*;', text, re.M)
|
697
|
+
|
698
|
+
class TreetopBaseLexer(RegexLexer):
|
699
|
+
"""
|
700
|
+
A base lexer for `Treetop <http://treetop.rubyforge.org/>`_ grammars.
|
701
|
+
Not for direct use; use TreetopLexer instead.
|
702
|
+
|
703
|
+
*New in Pygments 1.6.*
|
704
|
+
"""
|
705
|
+
|
706
|
+
tokens = {
|
707
|
+
'root': [
|
708
|
+
include('space'),
|
709
|
+
(r'require[ \t]+[^\n\r]+[\n\r]', Other),
|
710
|
+
(r'module\b', Keyword.Namespace, 'module'),
|
711
|
+
(r'grammar\b', Keyword, 'grammar'),
|
712
|
+
],
|
713
|
+
'module': [
|
714
|
+
include('space'),
|
715
|
+
include('end'),
|
716
|
+
(r'module\b', Keyword, '#push'),
|
717
|
+
(r'grammar\b', Keyword, 'grammar'),
|
718
|
+
(r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Namespace),
|
719
|
+
],
|
720
|
+
'grammar': [
|
721
|
+
include('space'),
|
722
|
+
include('end'),
|
723
|
+
(r'rule\b', Keyword, 'rule'),
|
724
|
+
(r'include\b', Keyword, 'include'),
|
725
|
+
(r'[A-Z][A-Za-z_0-9]*', Name),
|
726
|
+
],
|
727
|
+
'include': [
|
728
|
+
include('space'),
|
729
|
+
(r'[A-Z][A-Za-z_0-9]*(?:::[A-Z][A-Za-z_0-9]*)*', Name.Class, '#pop'),
|
730
|
+
],
|
731
|
+
'rule': [
|
732
|
+
include('space'),
|
733
|
+
include('end'),
|
734
|
+
(r'"(\\\\|\\"|[^"])*"', String.Double),
|
735
|
+
(r"'(\\\\|\\'|[^'])*'", String.Single),
|
736
|
+
(r'([A-Za-z_][A-Za-z_0-9]*)(:)', bygroups(Name.Label, Punctuation)),
|
737
|
+
(r'[A-Za-z_][A-Za-z_0-9]*', Name),
|
738
|
+
(r'[()]', Punctuation),
|
739
|
+
(r'[?+*/&!~]', Operator),
|
740
|
+
(r'\[(?:\\.|\[:\^?[a-z]+:\]|[^\\\]])+\]', String.Regex),
|
741
|
+
(r'([0-9]*)(\.\.)([0-9]*)',
|
742
|
+
bygroups(Number.Integer, Operator, Number.Integer)),
|
743
|
+
(r'(<)([^>]+)(>)', bygroups(Punctuation, Name.Class, Punctuation)),
|
744
|
+
(r'{', Punctuation, 'inline_module'),
|
745
|
+
(r'\.', String.Regex),
|
746
|
+
],
|
747
|
+
'inline_module': [
|
748
|
+
(r'{', Other, 'ruby'),
|
749
|
+
(r'}', Punctuation, '#pop'),
|
750
|
+
(r'[^{}]+', Other),
|
751
|
+
],
|
752
|
+
'ruby': [
|
753
|
+
(r'{', Other, '#push'),
|
754
|
+
(r'}', Other, '#pop'),
|
755
|
+
(r'[^{}]+', Other),
|
756
|
+
],
|
757
|
+
'space': [
|
758
|
+
(r'[ \t\n\r]+', Whitespace),
|
759
|
+
(r'#[^\n]*', Comment.Single),
|
760
|
+
],
|
761
|
+
'end': [
|
762
|
+
(r'end\b', Keyword, '#pop'),
|
763
|
+
],
|
764
|
+
}
|
765
|
+
|
766
|
+
class TreetopLexer(DelegatingLexer):
|
767
|
+
"""
|
768
|
+
A lexer for `Treetop <http://treetop.rubyforge.org/>`_ grammars.
|
769
|
+
|
770
|
+
*New in Pygments 1.6.*
|
771
|
+
"""
|
772
|
+
|
773
|
+
name = 'Treetop'
|
774
|
+
aliases = ['treetop']
|
775
|
+
filenames = ['*.treetop', '*.tt']
|
776
|
+
|
777
|
+
def __init__(self, **options):
|
778
|
+
super(TreetopLexer, self).__init__(RubyLexer, TreetopBaseLexer, **options)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Lexers for various shells.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
@@ -18,7 +18,7 @@ from pygments.util import shebang_matches
|
|
18
18
|
|
19
19
|
|
20
20
|
__all__ = ['BashLexer', 'BashSessionLexer', 'TcshLexer', 'BatchLexer',
|
21
|
-
'PowerShellLexer']
|
21
|
+
'PowerShellLexer', 'ShellSessionLexer']
|
22
22
|
|
23
23
|
line_re = re.compile('.*?\n')
|
24
24
|
|
@@ -31,7 +31,7 @@ class BashLexer(RegexLexer):
|
|
31
31
|
"""
|
32
32
|
|
33
33
|
name = 'Bash'
|
34
|
-
aliases = ['bash', 'sh', 'ksh'
|
34
|
+
aliases = ['bash', 'sh', 'ksh']
|
35
35
|
filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass',
|
36
36
|
'.bashrc', 'bashrc', '.bash_*', 'bash_*']
|
37
37
|
mimetypes = ['application/x-sh', 'application/x-shellscript']
|
@@ -60,15 +60,18 @@ class BashLexer(RegexLexer):
|
|
60
60
|
(r'\\[\w\W]', String.Escape),
|
61
61
|
(r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
|
62
62
|
(r'[\[\]{}()=]', Operator),
|
63
|
+
(r'<<<', Operator), # here-string
|
63
64
|
(r'<<-?\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
|
64
65
|
(r'&&|\|\|', Operator),
|
65
66
|
],
|
66
67
|
'data': [
|
67
68
|
(r'(?s)\$?"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
|
68
69
|
(r"(?s)\$?'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
|
69
|
-
(r';',
|
70
|
+
(r';', Punctuation),
|
71
|
+
(r'&', Punctuation),
|
72
|
+
(r'\|', Punctuation),
|
70
73
|
(r'\s+', Text),
|
71
|
-
(r'[^=\s\[\]{}()$"\'
|
74
|
+
(r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
|
72
75
|
(r'\d+(?= |\Z)', Number),
|
73
76
|
(r'\$#?(\w+|.)', Name.Variable),
|
74
77
|
(r'<', Text),
|
@@ -98,7 +101,10 @@ class BashLexer(RegexLexer):
|
|
98
101
|
}
|
99
102
|
|
100
103
|
def analyse_text(text):
|
101
|
-
|
104
|
+
if shebang_matches(text, r'(ba|z|)sh'):
|
105
|
+
return 1
|
106
|
+
if text.startswith('$ '):
|
107
|
+
return 0.2
|
102
108
|
|
103
109
|
|
104
110
|
class BashSessionLexer(Lexer):
|
@@ -152,6 +158,52 @@ class BashSessionLexer(Lexer):
|
|
152
158
|
yield pos+i, t, v
|
153
159
|
|
154
160
|
|
161
|
+
class ShellSessionLexer(Lexer):
|
162
|
+
"""
|
163
|
+
Lexer for shell sessions that works with different command prompts
|
164
|
+
|
165
|
+
*New in Pygments 1.6.*
|
166
|
+
"""
|
167
|
+
|
168
|
+
name = 'Shell Session'
|
169
|
+
aliases = ['shell-session']
|
170
|
+
filenames = ['*.shell-session']
|
171
|
+
mimetypes = ['application/x-sh-session']
|
172
|
+
|
173
|
+
def get_tokens_unprocessed(self, text):
|
174
|
+
bashlexer = BashLexer(**self.options)
|
175
|
+
|
176
|
+
pos = 0
|
177
|
+
curcode = ''
|
178
|
+
insertions = []
|
179
|
+
|
180
|
+
for match in line_re.finditer(text):
|
181
|
+
line = match.group()
|
182
|
+
m = re.match(r'^((?:\[?\S+@[^$#%]+)[$#%])(.*\n?)', line)
|
183
|
+
if m:
|
184
|
+
# To support output lexers (say diff output), the output
|
185
|
+
# needs to be broken by prompts whenever the output lexer
|
186
|
+
# changes.
|
187
|
+
if not insertions:
|
188
|
+
pos = match.start()
|
189
|
+
|
190
|
+
insertions.append((len(curcode),
|
191
|
+
[(0, Generic.Prompt, m.group(1))]))
|
192
|
+
curcode += m.group(2)
|
193
|
+
else:
|
194
|
+
if insertions:
|
195
|
+
toks = bashlexer.get_tokens_unprocessed(curcode)
|
196
|
+
for i, t, v in do_insertions(insertions, toks):
|
197
|
+
yield pos+i, t, v
|
198
|
+
yield match.start(), Generic.Output, line
|
199
|
+
insertions = []
|
200
|
+
curcode = ''
|
201
|
+
if insertions:
|
202
|
+
for i, t, v in do_insertions(insertions,
|
203
|
+
bashlexer.get_tokens_unprocessed(curcode)):
|
204
|
+
yield pos+i, t, v
|
205
|
+
|
206
|
+
|
155
207
|
class BatchLexer(RegexLexer):
|
156
208
|
"""
|
157
209
|
Lexer for the DOS/Windows Batch file format.
|
@@ -159,7 +211,7 @@ class BatchLexer(RegexLexer):
|
|
159
211
|
*New in Pygments 0.7.*
|
160
212
|
"""
|
161
213
|
name = 'Batchfile'
|
162
|
-
aliases = ['bat']
|
214
|
+
aliases = ['bat', 'dosbatch', 'winbatch']
|
163
215
|
filenames = ['*.bat', '*.cmd']
|
164
216
|
mimetypes = ['application/x-dos-batch']
|
165
217
|
|
@@ -282,8 +334,8 @@ class PowerShellLexer(RegexLexer):
|
|
282
334
|
*New in Pygments 1.5.*
|
283
335
|
"""
|
284
336
|
name = 'PowerShell'
|
285
|
-
aliases = ['powershell', 'posh', 'ps1']
|
286
|
-
filenames = ['*.ps1']
|
337
|
+
aliases = ['powershell', 'posh', 'ps1', 'psm1']
|
338
|
+
filenames = ['*.ps1','*.psm1']
|
287
339
|
mimetypes = ['text/x-powershell']
|
288
340
|
|
289
341
|
flags = re.DOTALL | re.IGNORECASE | re.MULTILINE
|
@@ -295,7 +347,7 @@ class PowerShellLexer(RegexLexer):
|
|
295
347
|
'dynamicparam do default continue cmdletbinding break begin alias \\? '
|
296
348
|
'% #script #private #local #global mandatory parametersetname position '
|
297
349
|
'valuefrompipeline valuefrompipelinebypropertyname '
|
298
|
-
'valuefromremainingarguments helpmessage try catch').split()
|
350
|
+
'valuefromremainingarguments helpmessage try catch throw').split()
|
299
351
|
|
300
352
|
operators = (
|
301
353
|
'and as band bnot bor bxor casesensitive ccontains ceq cge cgt cle '
|
@@ -321,13 +373,18 @@ class PowerShellLexer(RegexLexer):
|
|
321
373
|
|
322
374
|
tokens = {
|
323
375
|
'root': [
|
376
|
+
# we need to count pairs of parentheses for correct highlight
|
377
|
+
# of '$(...)' blocks in strings
|
378
|
+
(r'\(', Punctuation, 'child'),
|
324
379
|
(r'\s+', Text),
|
325
380
|
(r'^(\s*#[#\s]*)(\.(?:%s))([^\n]*$)' % '|'.join(commenthelp),
|
326
381
|
bygroups(Comment, String.Doc, Comment)),
|
327
382
|
(r'#[^\n]*?$', Comment),
|
328
383
|
(r'(<|<)#', Comment.Multiline, 'multline'),
|
329
|
-
(r'@"\n
|
384
|
+
(r'@"\n', String.Heredoc, 'heredoc-double'),
|
330
385
|
(r"@'\n.*?\n'@", String.Heredoc),
|
386
|
+
# escaped syntax
|
387
|
+
(r'`[\'"$@-]', Punctuation),
|
331
388
|
(r'"', String.Double, 'string'),
|
332
389
|
(r"'([^']|'')*'", String.Single),
|
333
390
|
(r'(\$|@@|@)((global|script|private|env):)?[a-z0-9_]+',
|
@@ -338,7 +395,11 @@ class PowerShellLexer(RegexLexer):
|
|
338
395
|
(r'\[[a-z_\[][a-z0-9_. `,\[\]]*\]', Name.Constant), # .net [type]s
|
339
396
|
(r'-[a-z_][a-z0-9_]*', Name),
|
340
397
|
(r'\w+', Name),
|
341
|
-
(r'[
|
398
|
+
(r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation),
|
399
|
+
],
|
400
|
+
'child': [
|
401
|
+
(r'\)', Punctuation, '#pop'),
|
402
|
+
include('root'),
|
342
403
|
],
|
343
404
|
'multline': [
|
344
405
|
(r'[^#&.]+', Comment.Multiline),
|
@@ -347,15 +408,17 @@ class PowerShellLexer(RegexLexer):
|
|
347
408
|
(r'[#&.]', Comment.Multiline),
|
348
409
|
],
|
349
410
|
'string': [
|
411
|
+
(r"`[0abfnrtv'\"\$]", String.Escape),
|
350
412
|
(r'[^$`"]+', String.Double),
|
351
|
-
(r'\$\(',
|
352
|
-
(r'
|
413
|
+
(r'\$\(', Punctuation, 'child'),
|
414
|
+
(r'""', String.Double),
|
353
415
|
(r'[`$]', String.Double),
|
354
416
|
(r'"', String.Double, '#pop'),
|
355
417
|
],
|
356
|
-
'
|
357
|
-
(r'
|
358
|
-
(r'\$\(',
|
359
|
-
(r'
|
418
|
+
'heredoc-double': [
|
419
|
+
(r'\n"@', String.Heredoc, '#pop'),
|
420
|
+
(r'\$\(', Punctuation, 'child'),
|
421
|
+
(r'[^@\n]+"]', String.Heredoc),
|
422
|
+
(r".", String.Heredoc),
|
360
423
|
]
|
361
424
|
}
|
@@ -34,7 +34,7 @@
|
|
34
34
|
The ``tests/examplefiles`` contains a few test files with data to be
|
35
35
|
parsed by these lexers.
|
36
36
|
|
37
|
-
:copyright: Copyright 2006-
|
37
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
38
38
|
:license: BSD, see LICENSE for details.
|
39
39
|
"""
|
40
40
|
|
@@ -375,7 +375,7 @@ class SqlLexer(RegexLexer):
|
|
375
375
|
r'DIAGNOSTICS|DICTIONARY|DISCONNECT|DISPATCH|DISTINCT|DO|'
|
376
376
|
r'DOMAIN|DROP|DYNAMIC|DYNAMIC_FUNCTION|DYNAMIC_FUNCTION_CODE|'
|
377
377
|
r'EACH|ELSE|ENCODING|ENCRYPTED|END|END-EXEC|EQUALS|ESCAPE|EVERY|'
|
378
|
-
r'EXCEPT|
|
378
|
+
r'EXCEPTION|EXCEPT|EXCLUDING|EXCLUSIVE|EXEC|EXECUTE|EXISTING|'
|
379
379
|
r'EXISTS|EXPLAIN|EXTERNAL|EXTRACT|FALSE|FETCH|FINAL|FIRST|FOR|'
|
380
380
|
r'FORCE|FOREIGN|FORTRAN|FORWARD|FOUND|FREE|FREEZE|FROM|FULL|'
|
381
381
|
r'FUNCTION|G|GENERAL|GENERATED|GET|GLOBAL|GO|GOTO|GRANT|GRANTED|'
|
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Lexers for various template engines' markup.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
12
12
|
import re
|
13
13
|
|
14
14
|
from pygments.lexers.web import \
|
15
|
-
PhpLexer, HtmlLexer, XmlLexer, JavascriptLexer, CssLexer
|
15
|
+
PhpLexer, HtmlLexer, XmlLexer, JavascriptLexer, CssLexer, LassoLexer
|
16
16
|
from pygments.lexers.agile import PythonLexer, PerlLexer
|
17
17
|
from pygments.lexers.compiled import JavaLexer
|
18
18
|
from pygments.lexers.jvm import TeaLangLexer
|
@@ -37,7 +37,8 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
|
|
37
37
|
'CheetahXmlLexer', 'CheetahJavascriptLexer', 'EvoqueLexer',
|
38
38
|
'EvoqueHtmlLexer', 'EvoqueXmlLexer', 'ColdfusionLexer',
|
39
39
|
'ColdfusionHtmlLexer', 'VelocityLexer', 'VelocityHtmlLexer',
|
40
|
-
'VelocityXmlLexer', 'SspLexer', 'TeaTemplateLexer'
|
40
|
+
'VelocityXmlLexer', 'SspLexer', 'TeaTemplateLexer', 'LassoHtmlLexer',
|
41
|
+
'LassoXmlLexer', 'LassoCssLexer', 'LassoJavascriptLexer']
|
41
42
|
|
42
43
|
|
43
44
|
class ErbLexer(Lexer):
|
@@ -223,12 +224,14 @@ class VelocityLexer(RegexLexer):
|
|
223
224
|
'variable': [
|
224
225
|
(identifier, Name.Variable),
|
225
226
|
(r'\(', Punctuation, 'funcparams'),
|
226
|
-
(r'(\.)(' + identifier + r')',
|
227
|
+
(r'(\.)(' + identifier + r')',
|
228
|
+
bygroups(Punctuation, Name.Variable), '#push'),
|
227
229
|
(r'\}', Punctuation, '#pop'),
|
228
230
|
(r'', Other, '#pop')
|
229
231
|
],
|
230
232
|
'directiveparams': [
|
231
|
-
(r'(&&|\|\||==?|!=?|[-<>+*%&\|\^/])|\b(eq|ne|gt|lt|ge|le|not|in)\b',
|
233
|
+
(r'(&&|\|\||==?|!=?|[-<>+*%&\|\^/])|\b(eq|ne|gt|lt|ge|le|not|in)\b',
|
234
|
+
Operator),
|
232
235
|
(r'\[', Operator, 'rangeoperator'),
|
233
236
|
(r'\b' + identifier + r'\b', Name.Function),
|
234
237
|
include('funcparams')
|
@@ -260,7 +263,8 @@ class VelocityLexer(RegexLexer):
|
|
260
263
|
rv += 0.15
|
261
264
|
if re.search(r'#\{?foreach\}?\(.+?\).*?#\{?end\}?', text):
|
262
265
|
rv += 0.15
|
263
|
-
if re.search(r'\$\{?[a-zA-Z_][a-zA-Z0-9_]*(\([^)]*\))?
|
266
|
+
if re.search(r'\$\{?[a-zA-Z_][a-zA-Z0-9_]*(\([^)]*\))?'
|
267
|
+
r'(\.[a-zA-Z0-9_]+(\([^)]*\))?)*\}?', text):
|
264
268
|
rv += 0.01
|
265
269
|
return rv
|
266
270
|
|
@@ -762,7 +766,7 @@ class CheetahHtmlLexer(DelegatingLexer):
|
|
762
766
|
"""
|
763
767
|
|
764
768
|
name = 'HTML+Cheetah'
|
765
|
-
aliases = ['html+cheetah', 'html+spitfire']
|
769
|
+
aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah']
|
766
770
|
mimetypes = ['text/html+cheetah', 'text/html+spitfire']
|
767
771
|
|
768
772
|
def __init__(self, **options):
|
@@ -1254,7 +1258,7 @@ class HtmlDjangoLexer(DelegatingLexer):
|
|
1254
1258
|
"""
|
1255
1259
|
|
1256
1260
|
name = 'HTML+Django/Jinja'
|
1257
|
-
aliases = ['html+django', 'html+jinja']
|
1261
|
+
aliases = ['html+django', 'html+jinja', 'htmldjango']
|
1258
1262
|
alias_filenames = ['*.html', '*.htm', '*.xhtml']
|
1259
1263
|
mimetypes = ['text/html+django', 'text/html+jinja']
|
1260
1264
|
|
@@ -1629,3 +1633,110 @@ class TeaTemplateLexer(DelegatingLexer):
|
|
1629
1633
|
if '<%' in text and '%>' in text:
|
1630
1634
|
rv += 0.1
|
1631
1635
|
return rv
|
1636
|
+
|
1637
|
+
|
1638
|
+
class LassoHtmlLexer(DelegatingLexer):
|
1639
|
+
"""
|
1640
|
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
1641
|
+
`HtmlLexer`.
|
1642
|
+
|
1643
|
+
Nested JavaScript and CSS is also highlighted.
|
1644
|
+
|
1645
|
+
*New in Pygments 1.6.*
|
1646
|
+
"""
|
1647
|
+
|
1648
|
+
name = 'HTML+Lasso'
|
1649
|
+
aliases = ['html+lasso']
|
1650
|
+
alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.lasso', '*.lasso[89]',
|
1651
|
+
'*.incl', '*.inc', '*.las']
|
1652
|
+
mimetypes = ['text/html+lasso',
|
1653
|
+
'application/x-httpd-lasso',
|
1654
|
+
'application/x-httpd-lasso[89]']
|
1655
|
+
|
1656
|
+
def __init__(self, **options):
|
1657
|
+
super(LassoHtmlLexer, self).__init__(HtmlLexer, LassoLexer, **options)
|
1658
|
+
|
1659
|
+
def analyse_text(text):
|
1660
|
+
rv = LassoLexer.analyse_text(text) - 0.01
|
1661
|
+
if re.search(r'<\w+>', text, re.I):
|
1662
|
+
rv += 0.2
|
1663
|
+
if html_doctype_matches(text):
|
1664
|
+
rv += 0.5
|
1665
|
+
return rv
|
1666
|
+
|
1667
|
+
|
1668
|
+
class LassoXmlLexer(DelegatingLexer):
|
1669
|
+
"""
|
1670
|
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
1671
|
+
`XmlLexer`.
|
1672
|
+
|
1673
|
+
*New in Pygments 1.6.*
|
1674
|
+
"""
|
1675
|
+
|
1676
|
+
name = 'XML+Lasso'
|
1677
|
+
aliases = ['xml+lasso']
|
1678
|
+
alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]',
|
1679
|
+
'*.incl', '*.inc', '*.las']
|
1680
|
+
mimetypes = ['application/xml+lasso']
|
1681
|
+
|
1682
|
+
def __init__(self, **options):
|
1683
|
+
super(LassoXmlLexer, self).__init__(XmlLexer, LassoLexer, **options)
|
1684
|
+
|
1685
|
+
def analyse_text(text):
|
1686
|
+
rv = LassoLexer.analyse_text(text) - 0.01
|
1687
|
+
if looks_like_xml(text):
|
1688
|
+
rv += 0.4
|
1689
|
+
return rv
|
1690
|
+
|
1691
|
+
|
1692
|
+
class LassoCssLexer(DelegatingLexer):
|
1693
|
+
"""
|
1694
|
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
1695
|
+
`CssLexer`.
|
1696
|
+
|
1697
|
+
*New in Pygments 1.6.*
|
1698
|
+
"""
|
1699
|
+
|
1700
|
+
name = 'CSS+Lasso'
|
1701
|
+
aliases = ['css+lasso']
|
1702
|
+
alias_filenames = ['*.css']
|
1703
|
+
mimetypes = ['text/css+lasso']
|
1704
|
+
|
1705
|
+
def __init__(self, **options):
|
1706
|
+
options['requiredelimiters'] = True
|
1707
|
+
super(LassoCssLexer, self).__init__(CssLexer, LassoLexer, **options)
|
1708
|
+
|
1709
|
+
def analyse_text(text):
|
1710
|
+
rv = LassoLexer.analyse_text(text) - 0.05
|
1711
|
+
if re.search(r'\w+:.+?;', text):
|
1712
|
+
rv += 0.1
|
1713
|
+
if 'padding:' in text:
|
1714
|
+
rv += 0.1
|
1715
|
+
return rv
|
1716
|
+
|
1717
|
+
|
1718
|
+
class LassoJavascriptLexer(DelegatingLexer):
|
1719
|
+
"""
|
1720
|
+
Subclass of the `LassoLexer` which highlights unhandled data with the
|
1721
|
+
`JavascriptLexer`.
|
1722
|
+
|
1723
|
+
*New in Pygments 1.6.*
|
1724
|
+
"""
|
1725
|
+
|
1726
|
+
name = 'JavaScript+Lasso'
|
1727
|
+
aliases = ['js+lasso', 'javascript+lasso']
|
1728
|
+
alias_filenames = ['*.js']
|
1729
|
+
mimetypes = ['application/x-javascript+lasso',
|
1730
|
+
'text/x-javascript+lasso',
|
1731
|
+
'text/javascript+lasso']
|
1732
|
+
|
1733
|
+
def __init__(self, **options):
|
1734
|
+
options['requiredelimiters'] = True
|
1735
|
+
super(LassoJavascriptLexer, self).__init__(JavascriptLexer, LassoLexer,
|
1736
|
+
**options)
|
1737
|
+
|
1738
|
+
def analyse_text(text):
|
1739
|
+
rv = LassoLexer.analyse_text(text) - 0.05
|
1740
|
+
if 'function' in text:
|
1741
|
+
rv += 0.2
|
1742
|
+
return rv
|