pygments.rb 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +40 -0
- data/README.md +3 -0
- data/lexers +0 -0
- data/lib/pygments/popen.rb +3 -2
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -1
- data/vendor/pygments-main/AUTHORS +20 -1
- data/vendor/pygments-main/CHANGES +55 -3
- data/vendor/pygments-main/LICENSE +1 -1
- data/vendor/pygments-main/MANIFEST.in +1 -1
- data/vendor/pygments-main/Makefile +5 -8
- data/vendor/pygments-main/REVISION +1 -1
- data/vendor/pygments-main/doc/Makefile +153 -0
- data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
- data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
- data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
- data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
- data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
- data/vendor/pygments-main/doc/conf.py +249 -0
- data/vendor/pygments-main/doc/docs/api.rst +316 -0
- data/vendor/pygments-main/doc/docs/authors.rst +4 -0
- data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
- data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
- data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
- data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
- data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
- data/vendor/pygments-main/doc/docs/index.rst +66 -0
- data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
- data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
- data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
- data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
- data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
- data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
- data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
- data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
- data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
- data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
- data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
- data/vendor/pygments-main/doc/download.rst +41 -0
- data/vendor/pygments-main/doc/faq.rst +143 -0
- data/vendor/pygments-main/doc/index.rst +53 -0
- data/vendor/pygments-main/doc/languages.rst +151 -0
- data/vendor/pygments-main/doc/make.bat +190 -0
- data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
- data/vendor/pygments-main/external/autopygmentize +65 -48
- data/vendor/pygments-main/external/markdown-processor.py +15 -15
- data/vendor/pygments-main/external/moin-parser.py +1 -1
- data/vendor/pygments-main/external/rst-directive.py +2 -3
- data/vendor/pygments-main/ez_setup.py +340 -234
- data/vendor/pygments-main/pygments/__init__.py +4 -4
- data/vendor/pygments-main/pygments/cmdline.py +81 -68
- 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 +11 -9
- data/vendor/pygments-main/pygments/formatter.py +3 -3
- data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
- data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +44 -26
- data/vendor/pygments-main/pygments/formatters/img.py +21 -14
- data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
- data/vendor/pygments-main/pygments/formatters/other.py +53 -6
- data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
- data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
- data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
- data/vendor/pygments-main/pygments/lexer.py +59 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
- data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
- data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
- data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
- data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
- data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
- data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
- data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
- data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
- data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
- data/vendor/pygments-main/pygments/lexers/math.py +438 -70
- data/vendor/pygments-main/pygments/lexers/other.py +885 -171
- data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
- data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
- data/vendor/pygments-main/pygments/lexers/special.py +7 -8
- data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
- data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
- data/vendor/pygments-main/pygments/lexers/text.py +208 -46
- data/vendor/pygments-main/pygments/lexers/web.py +729 -264
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +1 -1
- data/vendor/pygments-main/pygments/sphinxext.py +153 -0
- data/vendor/pygments-main/pygments/style.py +3 -2
- data/vendor/pygments-main/pygments/styles/__init__.py +5 -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/igor.py +29 -0
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- 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/paraiso_dark.py +125 -0
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
- 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/styles/xcode.py +51 -0
- data/vendor/pygments-main/pygments/token.py +4 -1
- data/vendor/pygments-main/pygments/unistring.py +6 -5
- data/vendor/pygments-main/pygments/util.py +35 -21
- data/vendor/pygments-main/scripts/check_sources.py +28 -44
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
- data/vendor/pygments-main/scripts/find_codetags.py +27 -19
- data/vendor/pygments-main/scripts/find_error.py +16 -13
- data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
- data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
- data/vendor/pygments-main/setup.py +19 -19
- data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
- data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
- data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
- data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
- data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
- data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
- data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
- data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
- data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
- data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
- data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
- data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
- data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
- data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
- data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
- data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
- data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
- data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
- data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
- data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
- data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
- data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
- data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
- data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
- data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
- data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
- data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
- data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
- data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
- data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
- data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
- data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
- data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
- data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
- data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
- data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
- data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
- data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
- data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
- data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
- data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
- data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
- data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
- data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
- data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
- data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
- data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
- data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
- data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
- data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
- data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
- data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
- data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
- data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
- data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
- data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
- data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
- data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
- data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
- data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
- data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
- data/vendor/pygments-main/tests/run.py +14 -19
- data/vendor/pygments-main/tests/string_asserts.py +22 -0
- data/vendor/pygments-main/tests/test_basic_api.py +28 -14
- data/vendor/pygments-main/tests/test_cfm.py +46 -0
- data/vendor/pygments-main/tests/test_clexer.py +208 -3
- data/vendor/pygments-main/tests/test_cmdline.py +6 -5
- data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
- data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
- data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
- data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
- data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
- data/vendor/pygments-main/tests/test_perllexer.py +1 -1
- data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
- data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
- data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
- data/vendor/pygments-main/tests/test_token.py +3 -3
- data/vendor/pygments-main/tests/test_using_api.py +1 -1
- data/vendor/pygments-main/tests/test_util.py +1 -1
- metadata +138 -51
- data/vendor/pygments-main/docs/generate.py +0 -472
- data/vendor/pygments-main/docs/src/api.txt +0 -270
- data/vendor/pygments-main/docs/src/authors.txt +0 -5
- data/vendor/pygments-main/docs/src/changelog.txt +0 -5
- data/vendor/pygments-main/docs/src/index.txt +0 -69
- data/vendor/pygments-main/docs/src/installation.txt +0 -71
- data/vendor/pygments-main/external/rst-directive-old.py +0 -77
- data/vendor/pygments-main/scripts/reindent.py +0 -291
- data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
- data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -22,11 +22,11 @@
|
|
22
22
|
.. _Pygments tip:
|
23
23
|
http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev
|
24
24
|
|
25
|
-
:copyright: Copyright 2006-
|
25
|
+
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
|
26
26
|
:license: BSD, see LICENSE for details.
|
27
27
|
"""
|
28
28
|
|
29
|
-
__version__ = '
|
29
|
+
__version__ = '2.0pre'
|
30
30
|
__docformat__ = 'restructuredtext'
|
31
31
|
|
32
32
|
__all__ = ['lex', 'format', 'highlight']
|
@@ -43,7 +43,7 @@ def lex(code, lexer):
|
|
43
43
|
"""
|
44
44
|
try:
|
45
45
|
return lexer.get_tokens(code)
|
46
|
-
except TypeError
|
46
|
+
except TypeError as err:
|
47
47
|
if isinstance(err.args[0], str) and \
|
48
48
|
'unbound method get_tokens' in err.args[0]:
|
49
49
|
raise TypeError('lex() argument must be a lexer instance, '
|
@@ -67,7 +67,7 @@ def format(tokens, formatter, outfile=None):
|
|
67
67
|
return realoutfile.getvalue()
|
68
68
|
else:
|
69
69
|
formatter.format(tokens, outfile)
|
70
|
-
except TypeError
|
70
|
+
except TypeError as err:
|
71
71
|
if isinstance(err.args[0], str) and \
|
72
72
|
'unbound method format' in err.args[0]:
|
73
73
|
raise TypeError('format() argument must be a formatter instance, '
|
@@ -5,9 +5,12 @@
|
|
5
5
|
|
6
6
|
Command line interface.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
|
+
|
12
|
+
from __future__ import print_function
|
13
|
+
|
11
14
|
import sys
|
12
15
|
import getopt
|
13
16
|
from textwrap import dedent
|
@@ -16,6 +19,7 @@ from pygments import __version__, highlight
|
|
16
19
|
from pygments.util import ClassNotFound, OptionError, docstring_headline
|
17
20
|
from pygments.lexers import get_all_lexers, get_lexer_by_name, get_lexer_for_filename, \
|
18
21
|
find_lexer_class, guess_lexer, TextLexer
|
22
|
+
from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
|
19
23
|
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
|
20
24
|
get_formatter_for_filename, find_formatter_class, \
|
21
25
|
TerminalFormatter # pylint:disable-msg=E0611
|
@@ -92,7 +96,7 @@ def _parse_options(o_strs):
|
|
92
96
|
for o_arg in o_args:
|
93
97
|
o_arg = o_arg.strip()
|
94
98
|
try:
|
95
|
-
o_key, o_val = o_arg.split('=')
|
99
|
+
o_key, o_val = o_arg.split('=', 1)
|
96
100
|
o_key = o_key.strip()
|
97
101
|
o_val = o_val.strip()
|
98
102
|
except ValueError:
|
@@ -119,25 +123,25 @@ def _print_help(what, name):
|
|
119
123
|
try:
|
120
124
|
if what == 'lexer':
|
121
125
|
cls = find_lexer_class(name)
|
122
|
-
print
|
123
|
-
print
|
126
|
+
print("Help on the %s lexer:" % cls.name)
|
127
|
+
print(dedent(cls.__doc__))
|
124
128
|
elif what == 'formatter':
|
125
129
|
cls = find_formatter_class(name)
|
126
|
-
print
|
127
|
-
print
|
130
|
+
print("Help on the %s formatter:" % cls.name)
|
131
|
+
print(dedent(cls.__doc__))
|
128
132
|
elif what == 'filter':
|
129
133
|
cls = find_filter_class(name)
|
130
|
-
print
|
131
|
-
print
|
134
|
+
print("Help on the %s filter:" % name)
|
135
|
+
print(dedent(cls.__doc__))
|
132
136
|
except AttributeError:
|
133
|
-
print
|
137
|
+
print("%s not found!" % what, file=sys.stderr)
|
134
138
|
|
135
139
|
|
136
140
|
def _print_list(what):
|
137
141
|
if what == 'lexer':
|
138
|
-
print
|
139
|
-
print
|
140
|
-
print
|
142
|
+
print()
|
143
|
+
print("Lexers:")
|
144
|
+
print("~~~~~~~")
|
141
145
|
|
142
146
|
info = []
|
143
147
|
for fullname, names, exts, _ in get_all_lexers():
|
@@ -146,12 +150,12 @@ def _print_list(what):
|
|
146
150
|
info.append(tup)
|
147
151
|
info.sort()
|
148
152
|
for i in info:
|
149
|
-
print
|
153
|
+
print(('* %s\n %s %s') % i)
|
150
154
|
|
151
155
|
elif what == 'formatter':
|
152
|
-
print
|
153
|
-
print
|
154
|
-
print
|
156
|
+
print()
|
157
|
+
print("Formatters:")
|
158
|
+
print("~~~~~~~~~~~")
|
155
159
|
|
156
160
|
info = []
|
157
161
|
for cls in get_all_formatters():
|
@@ -161,27 +165,27 @@ def _print_list(what):
|
|
161
165
|
info.append(tup)
|
162
166
|
info.sort()
|
163
167
|
for i in info:
|
164
|
-
print
|
168
|
+
print(('* %s\n %s %s') % i)
|
165
169
|
|
166
170
|
elif what == 'filter':
|
167
|
-
print
|
168
|
-
print
|
169
|
-
print
|
171
|
+
print()
|
172
|
+
print("Filters:")
|
173
|
+
print("~~~~~~~~")
|
170
174
|
|
171
175
|
for name in get_all_filters():
|
172
176
|
cls = find_filter_class(name)
|
173
|
-
print
|
174
|
-
print
|
177
|
+
print("* " + name + ':')
|
178
|
+
print(" %s" % docstring_headline(cls))
|
175
179
|
|
176
180
|
elif what == 'style':
|
177
|
-
print
|
178
|
-
print
|
179
|
-
print
|
181
|
+
print()
|
182
|
+
print("Styles:")
|
183
|
+
print("~~~~~~~")
|
180
184
|
|
181
185
|
for name in get_all_styles():
|
182
186
|
cls = get_style_by_name(name)
|
183
|
-
print
|
184
|
-
print
|
187
|
+
print("* " + name + ':')
|
188
|
+
print(" %s" % docstring_headline(cls))
|
185
189
|
|
186
190
|
|
187
191
|
def main(args=sys.argv):
|
@@ -202,8 +206,8 @@ def main(args=sys.argv):
|
|
202
206
|
|
203
207
|
try:
|
204
208
|
popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:hVHg")
|
205
|
-
except getopt.GetoptError
|
206
|
-
print
|
209
|
+
except getopt.GetoptError:
|
210
|
+
print(usage, file=sys.stderr)
|
207
211
|
return 2
|
208
212
|
opts = {}
|
209
213
|
O_opts = []
|
@@ -219,22 +223,22 @@ def main(args=sys.argv):
|
|
219
223
|
opts[opt] = arg
|
220
224
|
|
221
225
|
if not opts and not args:
|
222
|
-
print
|
226
|
+
print(usage)
|
223
227
|
return 0
|
224
228
|
|
225
229
|
if opts.pop('-h', None) is not None:
|
226
|
-
print
|
230
|
+
print(usage)
|
227
231
|
return 0
|
228
232
|
|
229
233
|
if opts.pop('-V', None) is not None:
|
230
|
-
print
|
234
|
+
print('Pygments version %s, (c) 2006-2014 by Georg Brandl.' % __version__)
|
231
235
|
return 0
|
232
236
|
|
233
237
|
# handle ``pygmentize -L``
|
234
238
|
L_opt = opts.pop('-L', None)
|
235
239
|
if L_opt is not None:
|
236
240
|
if opts:
|
237
|
-
print
|
241
|
+
print(usage, file=sys.stderr)
|
238
242
|
return 2
|
239
243
|
|
240
244
|
# print version
|
@@ -249,12 +253,12 @@ def main(args=sys.argv):
|
|
249
253
|
H_opt = opts.pop('-H', None)
|
250
254
|
if H_opt is not None:
|
251
255
|
if opts or len(args) != 2:
|
252
|
-
print
|
256
|
+
print(usage, file=sys.stderr)
|
253
257
|
return 2
|
254
258
|
|
255
259
|
what, name = args
|
256
260
|
if what not in ('lexer', 'formatter', 'filter'):
|
257
|
-
print
|
261
|
+
print(usage, file=sys.stderr)
|
258
262
|
return 2
|
259
263
|
|
260
264
|
_print_help(what, name)
|
@@ -279,13 +283,13 @@ def main(args=sys.argv):
|
|
279
283
|
if infn is not None:
|
280
284
|
try:
|
281
285
|
lexer = get_lexer_for_filename(infn, **parsed_opts)
|
282
|
-
except ClassNotFound
|
286
|
+
except ClassNotFound as err:
|
283
287
|
lexer = TextLexer()
|
284
|
-
except OptionError
|
285
|
-
print
|
288
|
+
except OptionError as err:
|
289
|
+
print('Error:', err, file=sys.stderr)
|
286
290
|
return 1
|
287
291
|
|
288
|
-
print
|
292
|
+
print(lexer.aliases[0])
|
289
293
|
return 0
|
290
294
|
|
291
295
|
# handle ``pygmentize -S``
|
@@ -294,30 +298,30 @@ def main(args=sys.argv):
|
|
294
298
|
if S_opt is not None:
|
295
299
|
f_opt = opts.pop('-f', None)
|
296
300
|
if not f_opt:
|
297
|
-
print
|
301
|
+
print(usage, file=sys.stderr)
|
298
302
|
return 2
|
299
303
|
if opts or args:
|
300
|
-
print
|
304
|
+
print(usage, file=sys.stderr)
|
301
305
|
return 2
|
302
306
|
|
303
307
|
try:
|
304
308
|
parsed_opts['style'] = S_opt
|
305
309
|
fmter = get_formatter_by_name(f_opt, **parsed_opts)
|
306
|
-
except ClassNotFound
|
307
|
-
print
|
310
|
+
except ClassNotFound as err:
|
311
|
+
print(err, file=sys.stderr)
|
308
312
|
return 1
|
309
313
|
|
310
314
|
arg = a_opt or ''
|
311
315
|
try:
|
312
|
-
print
|
313
|
-
except Exception
|
314
|
-
print
|
316
|
+
print(fmter.get_style_defs(arg))
|
317
|
+
except Exception as err:
|
318
|
+
print('Error:', err, file=sys.stderr)
|
315
319
|
return 1
|
316
320
|
return 0
|
317
321
|
|
318
322
|
# if no -S is given, -a is not allowed
|
319
323
|
if a_opt is not None:
|
320
|
-
print
|
324
|
+
print(usage, file=sys.stderr)
|
321
325
|
return 2
|
322
326
|
|
323
327
|
# parse -F options
|
@@ -330,21 +334,21 @@ def main(args=sys.argv):
|
|
330
334
|
if fmter:
|
331
335
|
try:
|
332
336
|
fmter = get_formatter_by_name(fmter, **parsed_opts)
|
333
|
-
except (OptionError, ClassNotFound)
|
334
|
-
print
|
337
|
+
except (OptionError, ClassNotFound) as err:
|
338
|
+
print('Error:', err, file=sys.stderr)
|
335
339
|
return 1
|
336
340
|
|
337
341
|
if outfn:
|
338
342
|
if not fmter:
|
339
343
|
try:
|
340
344
|
fmter = get_formatter_for_filename(outfn, **parsed_opts)
|
341
|
-
except (OptionError, ClassNotFound)
|
342
|
-
print
|
345
|
+
except (OptionError, ClassNotFound) as err:
|
346
|
+
print('Error:', err, file=sys.stderr)
|
343
347
|
return 1
|
344
348
|
try:
|
345
349
|
outfile = open(outfn, 'wb')
|
346
|
-
except Exception
|
347
|
-
print
|
350
|
+
except Exception as err:
|
351
|
+
print('Error: cannot open outfile:', err, file=sys.stderr)
|
348
352
|
return 1
|
349
353
|
else:
|
350
354
|
if not fmter:
|
@@ -356,36 +360,36 @@ def main(args=sys.argv):
|
|
356
360
|
if lexer:
|
357
361
|
try:
|
358
362
|
lexer = get_lexer_by_name(lexer, **parsed_opts)
|
359
|
-
except (OptionError, ClassNotFound)
|
360
|
-
print
|
363
|
+
except (OptionError, ClassNotFound) as err:
|
364
|
+
print('Error:', err, file=sys.stderr)
|
361
365
|
return 1
|
362
366
|
|
363
367
|
if args:
|
364
368
|
if len(args) > 1:
|
365
|
-
print
|
369
|
+
print(usage, file=sys.stderr)
|
366
370
|
return 2
|
367
371
|
|
368
372
|
infn = args[0]
|
369
373
|
try:
|
370
374
|
code = open(infn, 'rb').read()
|
371
|
-
except Exception
|
372
|
-
print
|
375
|
+
except Exception as err:
|
376
|
+
print('Error: cannot read infile:', err, file=sys.stderr)
|
373
377
|
return 1
|
374
378
|
|
375
379
|
if not lexer:
|
376
380
|
try:
|
377
381
|
lexer = get_lexer_for_filename(infn, code, **parsed_opts)
|
378
|
-
except ClassNotFound
|
382
|
+
except ClassNotFound as err:
|
379
383
|
if '-g' in opts:
|
380
384
|
try:
|
381
385
|
lexer = guess_lexer(code, **parsed_opts)
|
382
386
|
except ClassNotFound:
|
383
387
|
lexer = TextLexer(**parsed_opts)
|
384
388
|
else:
|
385
|
-
print
|
389
|
+
print('Error:', err, file=sys.stderr)
|
386
390
|
return 1
|
387
|
-
except OptionError
|
388
|
-
print
|
391
|
+
except OptionError as err:
|
392
|
+
print('Error:', err, file=sys.stderr)
|
389
393
|
return 1
|
390
394
|
|
391
395
|
else:
|
@@ -396,12 +400,21 @@ def main(args=sys.argv):
|
|
396
400
|
except ClassNotFound:
|
397
401
|
lexer = TextLexer(**parsed_opts)
|
398
402
|
elif not lexer:
|
399
|
-
print
|
400
|
-
'from stdin (try using -g or -l <lexer>)'
|
403
|
+
print('Error: no lexer name given and reading ' + \
|
404
|
+
'from stdin (try using -g or -l <lexer>)', file=sys.stderr)
|
401
405
|
return 2
|
402
406
|
else:
|
403
407
|
code = sys.stdin.read()
|
404
408
|
|
409
|
+
# When using the LaTeX formatter and the option `escapeinside` is
|
410
|
+
# specified, we need a special lexer which collects escaped text
|
411
|
+
# before running the chosen language lexer.
|
412
|
+
escapeinside = parsed_opts.get('escapeinside', '')
|
413
|
+
if len(escapeinside) == 2 and isinstance(fmter, LatexFormatter):
|
414
|
+
left = escapeinside[0]
|
415
|
+
right = escapeinside[1]
|
416
|
+
lexer = LatexEmbeddedLexer(left, right, lexer)
|
417
|
+
|
405
418
|
# No encoding given? Use latin1 if output file given,
|
406
419
|
# stdin/stdout encoding otherwise.
|
407
420
|
# (This is a compromise, I'm not too happy with it...)
|
@@ -426,16 +439,16 @@ def main(args=sys.argv):
|
|
426
439
|
for fname, fopts in F_opts:
|
427
440
|
lexer.add_filter(fname, **fopts)
|
428
441
|
highlight(code, lexer, fmter, outfile)
|
429
|
-
except Exception
|
442
|
+
except Exception:
|
430
443
|
import traceback
|
431
444
|
info = traceback.format_exception(*sys.exc_info())
|
432
445
|
msg = info[-1].strip()
|
433
446
|
if len(info) >= 3:
|
434
447
|
# extract relevant file and position info
|
435
448
|
msg += '\n (f%s)' % info[-2].split('\n')[0].strip()[1:]
|
436
|
-
print
|
437
|
-
print
|
438
|
-
print
|
449
|
+
print(file=sys.stderr)
|
450
|
+
print('*** Error while highlighting:', file=sys.stderr)
|
451
|
+
print(msg, file=sys.stderr)
|
439
452
|
return 1
|
440
453
|
|
441
454
|
return 0
|
@@ -6,7 +6,7 @@
|
|
6
6
|
Module containing filter lookup functions and default
|
7
7
|
filters.
|
8
8
|
|
9
|
-
:copyright: Copyright 2006-
|
9
|
+
:copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
|
10
10
|
:license: BSD, see LICENSE for details.
|
11
11
|
"""
|
12
12
|
|
@@ -16,7 +16,7 @@ from pygments.token import String, Comment, Keyword, Name, Error, Whitespace, \
|
|
16
16
|
string_to_tokentype
|
17
17
|
from pygments.filter import Filter
|
18
18
|
from pygments.util import get_list_opt, get_int_opt, get_bool_opt, \
|
19
|
-
get_choice_opt, ClassNotFound, OptionError
|
19
|
+
get_choice_opt, ClassNotFound, OptionError, text_type, string_types
|
20
20
|
from pygments.plugin import find_plugin_filters
|
21
21
|
|
22
22
|
|
@@ -117,7 +117,7 @@ class KeywordCaseFilter(Filter):
|
|
117
117
|
def __init__(self, **options):
|
118
118
|
Filter.__init__(self, **options)
|
119
119
|
case = get_choice_opt(options, 'case', ['lower', 'upper', 'capitalize'], 'lower')
|
120
|
-
self.convert = getattr(
|
120
|
+
self.convert = getattr(text_type, case)
|
121
121
|
|
122
122
|
def filter(self, lexer, stream):
|
123
123
|
for ttype, value in stream:
|
@@ -182,7 +182,7 @@ class RaiseOnErrorTokenFilter(Filter):
|
|
182
182
|
The exception class to raise.
|
183
183
|
The default is `pygments.filters.ErrorToken`.
|
184
184
|
|
185
|
-
|
185
|
+
.. versionadded:: 0.8
|
186
186
|
"""
|
187
187
|
|
188
188
|
def __init__(self, **options):
|
@@ -230,14 +230,16 @@ class VisibleWhitespaceFilter(Filter):
|
|
230
230
|
styling the visible whitespace differently (e.g. greyed out), but it can
|
231
231
|
disrupt background colors. The default is ``True``.
|
232
232
|
|
233
|
-
|
233
|
+
.. versionadded:: 0.8
|
234
234
|
"""
|
235
235
|
|
236
236
|
def __init__(self, **options):
|
237
237
|
Filter.__init__(self, **options)
|
238
|
-
for name, default in
|
238
|
+
for name, default in [('spaces', u'·'),
|
239
|
+
('tabs', u'»'),
|
240
|
+
('newlines', u'¶')]:
|
239
241
|
opt = options.get(name, False)
|
240
|
-
if isinstance(opt,
|
242
|
+
if isinstance(opt, string_types) and len(opt) == 1:
|
241
243
|
setattr(self, name, opt)
|
242
244
|
else:
|
243
245
|
setattr(self, name, (opt and default or ''))
|
@@ -293,7 +295,7 @@ class GobbleFilter(Filter):
|
|
293
295
|
`n` : int
|
294
296
|
The number of characters to gobble.
|
295
297
|
|
296
|
-
|
298
|
+
.. versionadded:: 1.2
|
297
299
|
"""
|
298
300
|
def __init__(self, **options):
|
299
301
|
Filter.__init__(self, **options)
|
@@ -325,7 +327,7 @@ class TokenMergeFilter(Filter):
|
|
325
327
|
Merges consecutive tokens with the same token type in the output stream of a
|
326
328
|
lexer.
|
327
329
|
|
328
|
-
|
330
|
+
.. versionadded:: 1.2
|
329
331
|
"""
|
330
332
|
def __init__(self, **options):
|
331
333
|
Filter.__init__(self, **options)
|