pygments.rb 1.2.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +13 -0
- data/.github/workflows/ci.yml +40 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +5 -5
- data/.rubocop.yml +18 -0
- data/CHANGELOG.adoc +132 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.adoc +160 -0
- data/Rakefile +12 -21
- data/bench.rb +14 -8
- data/{cache-lexers.rb → cache_lexers.rb} +3 -2
- data/lexers +0 -0
- data/lib/pygments.rb +10 -11
- data/lib/pygments/lexer.rb +6 -6
- data/lib/pygments/mentos.py +23 -110
- data/lib/pygments/popen.rb +196 -275
- data/lib/pygments/version.rb +2 -2
- data/pygments.rb.gemspec +12 -10
- data/test/test_pygments.rb +50 -110
- data/vendor/pygments-main/{AUTHORS → Pygments-2.8.0.dist-info/AUTHORS} +26 -3
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/INSTALLER +1 -0
- data/vendor/pygments-main/{LICENSE → Pygments-2.8.0.dist-info/LICENSE} +1 -1
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/METADATA +48 -0
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/RECORD +494 -0
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/REQUESTED +0 -0
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/WHEEL +5 -0
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/entry_points.txt +3 -0
- data/vendor/pygments-main/Pygments-2.8.0.dist-info/top_level.txt +1 -0
- data/vendor/pygments-main/bin/pygmentize +8 -0
- data/vendor/pygments-main/pygments/__init__.py +6 -12
- data/vendor/pygments-main/pygments/__main__.py +17 -0
- data/vendor/pygments-main/pygments/cmdline.py +213 -184
- data/vendor/pygments-main/pygments/console.py +6 -10
- data/vendor/pygments-main/pygments/filter.py +4 -7
- data/vendor/pygments-main/pygments/filters/__init__.py +609 -22
- data/vendor/pygments-main/pygments/formatter.py +4 -5
- data/vendor/pygments-main/pygments/formatters/__init__.py +10 -10
- data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -4
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -2
- data/vendor/pygments-main/pygments/formatters/html.py +242 -139
- data/vendor/pygments-main/pygments/formatters/img.py +91 -50
- data/vendor/pygments-main/pygments/formatters/irc.py +39 -40
- data/vendor/pygments-main/pygments/formatters/latex.py +62 -33
- data/vendor/pygments-main/pygments/formatters/other.py +18 -17
- data/vendor/pygments-main/pygments/formatters/rtf.py +29 -30
- data/vendor/pygments-main/pygments/formatters/svg.py +40 -5
- data/vendor/pygments-main/pygments/formatters/terminal.py +25 -32
- data/vendor/pygments-main/pygments/formatters/terminal256.py +45 -14
- data/vendor/pygments-main/pygments/lexer.py +47 -44
- data/vendor/pygments-main/pygments/lexers/__init__.py +29 -17
- data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +5 -6
- data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +15 -16
- data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +21 -18
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1717 -1339
- data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +1 -2
- data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +2 -5
- data/vendor/pygments-main/pygments/lexers/_mapping.py +79 -31
- data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +2 -3
- data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1281 -0
- data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +439 -386
- data/vendor/pygments-main/pygments/lexers/_php_builtins.py +17 -21
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +73 -17
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +2 -3
- data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1 -4
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +151 -126
- data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +96 -58
- data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1 -2
- data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +112 -0
- data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +279 -0
- data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1 -2
- data/vendor/pygments-main/pygments/lexers/actionscript.py +14 -10
- data/vendor/pygments-main/pygments/lexers/agile.py +1 -2
- data/vendor/pygments-main/pygments/lexers/algebra.py +20 -2
- data/vendor/pygments-main/pygments/lexers/ambient.py +2 -3
- data/vendor/pygments-main/pygments/lexers/amdgpu.py +48 -0
- data/vendor/pygments-main/pygments/lexers/ampl.py +3 -4
- data/vendor/pygments-main/pygments/lexers/apl.py +15 -16
- data/vendor/pygments-main/pygments/lexers/archetype.py +4 -5
- data/vendor/pygments-main/pygments/lexers/arrow.py +116 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +440 -77
- data/vendor/pygments-main/pygments/lexers/automation.py +7 -2
- data/vendor/pygments-main/pygments/lexers/bare.py +103 -0
- data/vendor/pygments-main/pygments/lexers/basic.py +168 -7
- data/vendor/pygments-main/pygments/lexers/bibtex.py +5 -6
- data/vendor/pygments-main/pygments/lexers/boa.py +101 -0
- data/vendor/pygments-main/pygments/lexers/business.py +19 -5
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +138 -48
- data/vendor/pygments-main/pygments/lexers/c_like.py +67 -43
- data/vendor/pygments-main/pygments/lexers/capnproto.py +7 -8
- data/vendor/pygments-main/pygments/lexers/cddl.py +190 -0
- data/vendor/pygments-main/pygments/lexers/chapel.py +25 -16
- data/vendor/pygments-main/pygments/lexers/clean.py +135 -245
- data/vendor/pygments-main/pygments/lexers/compiled.py +1 -2
- data/vendor/pygments-main/pygments/lexers/configs.py +190 -38
- data/vendor/pygments-main/pygments/lexers/console.py +1 -2
- data/vendor/pygments-main/pygments/lexers/crystal.py +54 -81
- data/vendor/pygments-main/pygments/lexers/csound.py +288 -188
- data/vendor/pygments-main/pygments/lexers/css.py +28 -23
- data/vendor/pygments-main/pygments/lexers/d.py +12 -8
- data/vendor/pygments-main/pygments/lexers/dalvik.py +1 -2
- data/vendor/pygments-main/pygments/lexers/data.py +240 -98
- data/vendor/pygments-main/pygments/lexers/devicetree.py +108 -0
- data/vendor/pygments-main/pygments/lexers/diff.py +4 -5
- data/vendor/pygments-main/pygments/lexers/dotnet.py +46 -31
- data/vendor/pygments-main/pygments/lexers/dsls.py +146 -65
- data/vendor/pygments-main/pygments/lexers/dylan.py +16 -19
- data/vendor/pygments-main/pygments/lexers/ecl.py +17 -5
- data/vendor/pygments-main/pygments/lexers/eiffel.py +2 -3
- data/vendor/pygments-main/pygments/lexers/elm.py +5 -6
- data/vendor/pygments-main/pygments/lexers/email.py +150 -0
- data/vendor/pygments-main/pygments/lexers/erlang.py +29 -33
- data/vendor/pygments-main/pygments/lexers/esoteric.py +46 -20
- data/vendor/pygments-main/pygments/lexers/ezhil.py +21 -14
- data/vendor/pygments-main/pygments/lexers/factor.py +3 -4
- data/vendor/pygments-main/pygments/lexers/fantom.py +1 -2
- data/vendor/pygments-main/pygments/lexers/felix.py +1 -2
- data/vendor/pygments-main/pygments/lexers/floscript.py +82 -0
- data/vendor/pygments-main/pygments/lexers/forth.py +41 -41
- data/vendor/pygments-main/pygments/lexers/fortran.py +13 -10
- data/vendor/pygments-main/pygments/lexers/foxpro.py +2 -3
- data/vendor/pygments-main/pygments/lexers/freefem.py +897 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1 -2
- data/vendor/pygments-main/pygments/lexers/futhark.py +110 -0
- data/vendor/pygments-main/pygments/lexers/gdscript.py +345 -0
- data/vendor/pygments-main/pygments/lexers/go.py +2 -3
- data/vendor/pygments-main/pygments/lexers/grammar_notation.py +62 -6
- data/vendor/pygments-main/pygments/lexers/graph.py +14 -10
- data/vendor/pygments-main/pygments/lexers/graphics.py +274 -28
- data/vendor/pygments-main/pygments/lexers/graphviz.py +57 -0
- data/vendor/pygments-main/pygments/lexers/haskell.py +48 -22
- data/vendor/pygments-main/pygments/lexers/haxe.py +8 -9
- data/vendor/pygments-main/pygments/lexers/hdl.py +176 -90
- data/vendor/pygments-main/pygments/lexers/hexdump.py +1 -2
- data/vendor/pygments-main/pygments/lexers/html.py +37 -26
- data/vendor/pygments-main/pygments/lexers/idl.py +19 -9
- data/vendor/pygments-main/pygments/lexers/igor.py +244 -113
- data/vendor/pygments-main/pygments/lexers/inferno.py +2 -3
- data/vendor/pygments-main/pygments/lexers/installers.py +1 -2
- data/vendor/pygments-main/pygments/lexers/int_fiction.py +40 -16
- data/vendor/pygments-main/pygments/lexers/iolang.py +3 -4
- data/vendor/pygments-main/pygments/lexers/j.py +4 -5
- data/vendor/pygments-main/pygments/lexers/javascript.py +115 -104
- data/vendor/pygments-main/pygments/lexers/julia.py +44 -47
- data/vendor/pygments-main/pygments/lexers/jvm.py +368 -202
- data/vendor/pygments-main/pygments/lexers/lisp.py +887 -810
- data/vendor/pygments-main/pygments/lexers/make.py +12 -9
- data/vendor/pygments-main/pygments/lexers/markup.py +212 -45
- data/vendor/pygments-main/pygments/lexers/math.py +1 -2
- data/vendor/pygments-main/pygments/lexers/matlab.py +2705 -88
- data/vendor/pygments-main/pygments/lexers/mime.py +225 -0
- data/vendor/pygments-main/pygments/lexers/ml.py +203 -15
- data/vendor/pygments-main/pygments/lexers/modeling.py +26 -19
- data/vendor/pygments-main/pygments/lexers/modula2.py +27 -9
- data/vendor/pygments-main/pygments/lexers/monte.py +1 -2
- data/vendor/pygments-main/pygments/lexers/mosel.py +447 -0
- data/vendor/pygments-main/pygments/lexers/ncl.py +1 -2
- data/vendor/pygments-main/pygments/lexers/nimrod.py +4 -5
- data/vendor/pygments-main/pygments/lexers/nit.py +1 -2
- data/vendor/pygments-main/pygments/lexers/nix.py +1 -2
- data/vendor/pygments-main/pygments/lexers/oberon.py +17 -2
- data/vendor/pygments-main/pygments/lexers/objective.py +18 -19
- data/vendor/pygments-main/pygments/lexers/ooc.py +1 -2
- data/vendor/pygments-main/pygments/lexers/other.py +1 -2
- data/vendor/pygments-main/pygments/lexers/parasail.py +1 -2
- data/vendor/pygments-main/pygments/lexers/parsers.py +47 -83
- data/vendor/pygments-main/pygments/lexers/pascal.py +22 -23
- data/vendor/pygments-main/pygments/lexers/pawn.py +31 -28
- data/vendor/pygments-main/pygments/lexers/perl.py +260 -149
- data/vendor/pygments-main/pygments/lexers/php.py +66 -13
- data/vendor/pygments-main/pygments/lexers/pointless.py +70 -0
- data/vendor/pygments-main/pygments/lexers/pony.py +93 -0
- data/vendor/pygments-main/pygments/lexers/praat.py +38 -31
- data/vendor/pygments-main/pygments/lexers/prolog.py +38 -39
- data/vendor/pygments-main/pygments/lexers/promql.py +182 -0
- data/vendor/pygments-main/pygments/lexers/python.py +450 -231
- data/vendor/pygments-main/pygments/lexers/qvt.py +6 -7
- data/vendor/pygments-main/pygments/lexers/r.py +13 -276
- data/vendor/pygments-main/pygments/lexers/rdf.py +232 -40
- data/vendor/pygments-main/pygments/lexers/rebol.py +8 -9
- data/vendor/pygments-main/pygments/lexers/resource.py +2 -3
- data/vendor/pygments-main/pygments/lexers/ride.py +138 -0
- data/vendor/pygments-main/pygments/lexers/rnc.py +1 -2
- data/vendor/pygments-main/pygments/lexers/roboconf.py +1 -2
- data/vendor/pygments-main/pygments/lexers/robotframework.py +23 -32
- data/vendor/pygments-main/pygments/lexers/ruby.py +50 -46
- data/vendor/pygments-main/pygments/lexers/rust.py +76 -73
- data/vendor/pygments-main/pygments/lexers/sas.py +1 -2
- data/vendor/pygments-main/pygments/lexers/scdoc.py +82 -0
- data/vendor/pygments-main/pygments/lexers/scripting.py +79 -18
- data/vendor/pygments-main/pygments/lexers/sgf.py +60 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +164 -49
- data/vendor/pygments-main/pygments/lexers/sieve.py +68 -0
- data/vendor/pygments-main/pygments/lexers/slash.py +184 -0
- data/vendor/pygments-main/pygments/lexers/smalltalk.py +2 -3
- data/vendor/pygments-main/pygments/lexers/smv.py +3 -4
- data/vendor/pygments-main/pygments/lexers/snobol.py +1 -2
- data/vendor/pygments-main/pygments/lexers/solidity.py +91 -0
- data/vendor/pygments-main/pygments/lexers/special.py +31 -28
- data/vendor/pygments-main/pygments/lexers/sql.py +330 -179
- data/vendor/pygments-main/pygments/lexers/stata.py +107 -45
- data/vendor/pygments-main/pygments/lexers/supercollider.py +8 -4
- data/vendor/pygments-main/pygments/lexers/tcl.py +1 -2
- data/vendor/pygments-main/pygments/lexers/templates.py +116 -136
- data/vendor/pygments-main/pygments/lexers/teraterm.py +334 -0
- data/vendor/pygments-main/pygments/lexers/testing.py +6 -7
- data/vendor/pygments-main/pygments/lexers/text.py +2 -2
- data/vendor/pygments-main/pygments/lexers/textedit.py +6 -7
- data/vendor/pygments-main/pygments/lexers/textfmts.py +146 -14
- data/vendor/pygments-main/pygments/lexers/theorem.py +74 -56
- data/vendor/pygments-main/pygments/lexers/tnt.py +262 -0
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -2
- data/vendor/pygments-main/pygments/lexers/typoscript.py +4 -12
- data/vendor/pygments-main/pygments/lexers/unicon.py +411 -0
- data/vendor/pygments-main/pygments/lexers/urbi.py +16 -4
- data/vendor/pygments-main/pygments/lexers/usd.py +89 -0
- data/vendor/pygments-main/pygments/lexers/varnish.py +4 -5
- data/vendor/pygments-main/pygments/lexers/verification.py +13 -11
- data/vendor/pygments-main/pygments/lexers/web.py +1 -2
- data/vendor/pygments-main/pygments/lexers/webidl.py +298 -0
- data/vendor/pygments-main/pygments/lexers/webmisc.py +35 -32
- data/vendor/pygments-main/pygments/lexers/whiley.py +5 -6
- data/vendor/pygments-main/pygments/lexers/x10.py +2 -3
- data/vendor/pygments-main/pygments/lexers/xorg.py +5 -5
- data/vendor/pygments-main/pygments/lexers/yang.py +103 -0
- data/vendor/pygments-main/pygments/lexers/zig.py +123 -0
- data/vendor/pygments-main/pygments/modeline.py +1 -2
- data/vendor/pygments-main/pygments/plugin.py +4 -3
- data/vendor/pygments-main/pygments/regexopt.py +1 -2
- data/vendor/pygments-main/pygments/scanner.py +2 -3
- data/vendor/pygments-main/pygments/sphinxext.py +2 -5
- data/vendor/pygments-main/pygments/style.py +61 -25
- data/vendor/pygments-main/pygments/styles/__init__.py +12 -5
- data/vendor/pygments-main/pygments/styles/abap.py +1 -2
- data/vendor/pygments-main/pygments/styles/algol.py +1 -2
- data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -2
- data/vendor/pygments-main/pygments/styles/arduino.py +2 -3
- data/vendor/pygments-main/pygments/styles/autumn.py +1 -2
- data/vendor/pygments-main/pygments/styles/borland.py +1 -2
- data/vendor/pygments-main/pygments/styles/bw.py +1 -2
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -2
- data/vendor/pygments-main/pygments/styles/default.py +1 -2
- data/vendor/pygments-main/pygments/styles/emacs.py +1 -2
- data/vendor/pygments-main/pygments/styles/friendly.py +1 -2
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -2
- data/vendor/pygments-main/pygments/styles/igor.py +1 -2
- data/vendor/pygments-main/pygments/styles/inkpot.py +66 -0
- data/vendor/pygments-main/pygments/styles/lovelace.py +1 -2
- data/vendor/pygments-main/pygments/styles/manni.py +1 -2
- data/vendor/pygments-main/pygments/styles/material.py +118 -0
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -2
- data/vendor/pygments-main/pygments/styles/native.py +1 -2
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -2
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -2
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -2
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -2
- data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -2
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -2
- data/vendor/pygments-main/pygments/styles/sas.py +1 -2
- data/vendor/pygments-main/pygments/styles/solarized.py +136 -0
- data/vendor/pygments-main/pygments/styles/stata_dark.py +40 -0
- data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -16
- data/vendor/pygments-main/pygments/styles/tango.py +1 -2
- data/vendor/pygments-main/pygments/styles/trac.py +1 -2
- data/vendor/pygments-main/pygments/styles/vim.py +1 -2
- data/vendor/pygments-main/pygments/styles/vs.py +1 -2
- data/vendor/pygments-main/pygments/styles/xcode.py +1 -2
- data/vendor/pygments-main/pygments/styles/zenburn.py +80 -0
- data/vendor/pygments-main/pygments/token.py +1 -2
- data/vendor/pygments-main/pygments/unistring.py +47 -109
- data/vendor/pygments-main/pygments/util.py +16 -96
- metadata +76 -137
- data/CHANGELOG.md +0 -105
- data/README.md +0 -121
- data/circle.yml +0 -20
- data/test/test_data.c +0 -2581
- data/test/test_data.py +0 -514
- data/test/test_data_generated +0 -2582
- data/vendor/custom_lexers/github.py +0 -565
- data/vendor/pygments-main/CHANGES +0 -1186
- data/vendor/pygments-main/MANIFEST.in +0 -6
- data/vendor/pygments-main/Makefile +0 -65
- data/vendor/pygments-main/README.rst +0 -39
- data/vendor/pygments-main/REVISION +0 -1
- data/vendor/pygments-main/TODO +0 -12
- data/vendor/pygments-main/doc/Makefile +0 -153
- 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 +0 -3
- data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
- data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
- 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 +0 -401
- data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
- data/vendor/pygments-main/doc/conf.py +0 -241
- data/vendor/pygments-main/doc/docs/api.rst +0 -354
- data/vendor/pygments-main/doc/docs/authors.rst +0 -4
- data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
- data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
- data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
- data/vendor/pygments-main/doc/docs/filters.rst +0 -41
- data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
- data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
- data/vendor/pygments-main/doc/docs/index.rst +0 -66
- data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
- data/vendor/pygments-main/doc/docs/java.rst +0 -70
- data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
- data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
- data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
- data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
- data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
- data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
- data/vendor/pygments-main/doc/docs/styles.rst +0 -201
- data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
- data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
- data/vendor/pygments-main/doc/download.rst +0 -41
- data/vendor/pygments-main/doc/faq.rst +0 -139
- data/vendor/pygments-main/doc/index.rst +0 -54
- data/vendor/pygments-main/doc/languages.rst +0 -154
- data/vendor/pygments-main/doc/make.bat +0 -190
- data/vendor/pygments-main/doc/pygmentize.1 +0 -94
- data/vendor/pygments-main/external/autopygmentize +0 -101
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
- data/vendor/pygments-main/external/markdown-processor.py +0 -67
- data/vendor/pygments-main/external/moin-parser.py +0 -112
- data/vendor/pygments-main/external/pygments.bashcomp +0 -38
- data/vendor/pygments-main/external/rst-directive.py +0 -82
- data/vendor/pygments-main/pygmentize +0 -8
- data/vendor/pygments-main/pygments/lexers/github.py +0 -565
- data/vendor/pygments-main/requirements.txt +0 -5
- data/vendor/pygments-main/scripts/check_sources.py +0 -211
- data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
- data/vendor/pygments-main/scripts/epydoc.css +0 -280
- data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
- data/vendor/pygments-main/scripts/pylintrc +0 -301
- data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
- data/vendor/pygments-main/setup.cfg +0 -10
- data/vendor/pygments-main/setup.py +0 -77
- data/vendor/pygments-main/tox.ini +0 -7
- data/vendor/simplejson/.gitignore +0 -10
- data/vendor/simplejson/.travis.yml +0 -5
- data/vendor/simplejson/CHANGES.txt +0 -291
- data/vendor/simplejson/LICENSE.txt +0 -19
- data/vendor/simplejson/MANIFEST.in +0 -5
- data/vendor/simplejson/README.rst +0 -19
- data/vendor/simplejson/conf.py +0 -179
- data/vendor/simplejson/index.rst +0 -628
- data/vendor/simplejson/scripts/make_docs.py +0 -18
- data/vendor/simplejson/setup.py +0 -104
- data/vendor/simplejson/simplejson/__init__.py +0 -510
- data/vendor/simplejson/simplejson/_speedups.c +0 -2745
- data/vendor/simplejson/simplejson/decoder.py +0 -425
- data/vendor/simplejson/simplejson/encoder.py +0 -567
- data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
- data/vendor/simplejson/simplejson/scanner.py +0 -77
- data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
- data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
- data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
- data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
- data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
- data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
- data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
- data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
- data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
- data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
- data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
- data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
- data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
- data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
- data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
- data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
- data/vendor/simplejson/simplejson/tool.py +0 -39
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
pygments
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
"""
|
3
2
|
Pygments
|
4
3
|
~~~~~~~~
|
@@ -17,19 +16,18 @@
|
|
17
16
|
* it is usable as a command-line tool and as a library
|
18
17
|
* ... and it highlights even Brainfuck!
|
19
18
|
|
20
|
-
The `Pygments
|
19
|
+
The `Pygments master branch`_ is installable with ``easy_install Pygments==dev``.
|
21
20
|
|
22
|
-
.. _Pygments
|
23
|
-
|
21
|
+
.. _Pygments master branch:
|
22
|
+
https://github.com/pygments/pygments/archive/master.zip#egg=Pygments-dev
|
24
23
|
|
25
|
-
:copyright: Copyright 2006-
|
24
|
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
26
25
|
:license: BSD, see LICENSE for details.
|
27
26
|
"""
|
28
27
|
import sys
|
28
|
+
from io import StringIO, BytesIO
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
__version__ = '2.2.0'
|
30
|
+
__version__ = '2.8.0'
|
33
31
|
__docformat__ = 'restructuredtext'
|
34
32
|
|
35
33
|
__all__ = ['lex', 'format', 'highlight']
|
@@ -84,7 +82,3 @@ def highlight(code, lexer, formatter, outfile=None):
|
|
84
82
|
"""
|
85
83
|
return format(lex(code, lexer), formatter, outfile)
|
86
84
|
|
87
|
-
|
88
|
-
if __name__ == '__main__': # pragma: no cover
|
89
|
-
from pygments.cmdline import main
|
90
|
-
sys.exit(main(sys.argv))
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"""
|
2
|
+
pygments.__main__
|
3
|
+
~~~~~~~~~~~~~~~~~
|
4
|
+
|
5
|
+
Main entry point for ``python -m pygments``.
|
6
|
+
|
7
|
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
8
|
+
:license: BSD, see LICENSE for details.
|
9
|
+
"""
|
10
|
+
|
11
|
+
import sys
|
12
|
+
import pygments.cmdline
|
13
|
+
|
14
|
+
try:
|
15
|
+
sys.exit(pygments.cmdline.main(sys.argv))
|
16
|
+
except KeyboardInterrupt:
|
17
|
+
sys.exit(1)
|
@@ -1,24 +1,23 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
1
|
"""
|
3
2
|
pygments.cmdline
|
4
3
|
~~~~~~~~~~~~~~~~
|
5
4
|
|
6
5
|
Command line interface.
|
7
6
|
|
8
|
-
:copyright: Copyright 2006-
|
7
|
+
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
9
8
|
:license: BSD, see LICENSE for details.
|
10
9
|
"""
|
11
10
|
|
12
|
-
from __future__ import print_function
|
13
|
-
|
14
11
|
import os
|
15
12
|
import sys
|
16
|
-
import
|
13
|
+
import shutil
|
14
|
+
import argparse
|
17
15
|
from textwrap import dedent
|
18
16
|
|
19
17
|
from pygments import __version__, highlight
|
20
18
|
from pygments.util import ClassNotFound, OptionError, docstring_headline, \
|
21
|
-
guess_decode, guess_decode_from_terminal, terminal_encoding
|
19
|
+
guess_decode, guess_decode_from_terminal, terminal_encoding, \
|
20
|
+
UnclosingTextIOWrapper
|
22
21
|
from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
|
23
22
|
load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
|
24
23
|
from pygments.lexers.special import TextLexer
|
@@ -31,84 +30,6 @@ from pygments.filters import get_all_filters, find_filter_class
|
|
31
30
|
from pygments.styles import get_all_styles, get_style_by_name
|
32
31
|
|
33
32
|
|
34
|
-
USAGE = """\
|
35
|
-
Usage: %s [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]
|
36
|
-
[-O <options>] [-P <option=value>] [-s] [-v] [-x] [-o <outfile>] [<infile>]
|
37
|
-
|
38
|
-
%s -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]
|
39
|
-
%s -L [<which> ...]
|
40
|
-
%s -N <filename>
|
41
|
-
%s -H <type> <name>
|
42
|
-
%s -h | -V
|
43
|
-
|
44
|
-
Highlight the input file and write the result to <outfile>.
|
45
|
-
|
46
|
-
If no input file is given, use stdin, if -o is not given, use stdout.
|
47
|
-
|
48
|
-
If -s is passed, lexing will be done in "streaming" mode, reading and
|
49
|
-
highlighting one line at a time. This will only work properly with
|
50
|
-
lexers that have no constructs spanning multiple lines!
|
51
|
-
|
52
|
-
<lexer> is a lexer name (query all lexer names with -L). If -l is not
|
53
|
-
given, the lexer is guessed from the extension of the input file name
|
54
|
-
(this obviously doesn't work if the input is stdin). If -g is passed,
|
55
|
-
attempt to guess the lexer from the file contents, or pass through as
|
56
|
-
plain text if this fails (this can work for stdin).
|
57
|
-
|
58
|
-
Likewise, <formatter> is a formatter name, and will be guessed from
|
59
|
-
the extension of the output file name. If no output file is given,
|
60
|
-
the terminal formatter will be used by default.
|
61
|
-
|
62
|
-
The additional option -x allows custom lexers and formatters to be
|
63
|
-
loaded from a .py file relative to the current working directory. For
|
64
|
-
example, ``-l ./customlexer.py -x``. By default, this option expects a
|
65
|
-
file with a class named CustomLexer or CustomFormatter; you can also
|
66
|
-
specify your own class name with a colon (``-l ./lexer.py:MyLexer``).
|
67
|
-
Users should be very careful not to use this option with untrusted files,
|
68
|
-
because it will import and run them.
|
69
|
-
|
70
|
-
With the -O option, you can give the lexer and formatter a comma-
|
71
|
-
separated list of options, e.g. ``-O bg=light,python=cool``.
|
72
|
-
|
73
|
-
The -P option adds lexer and formatter options like the -O option, but
|
74
|
-
you can only give one option per -P. That way, the option value may
|
75
|
-
contain commas and equals signs, which it can't with -O, e.g.
|
76
|
-
``-P "heading=Pygments, the Python highlighter".
|
77
|
-
|
78
|
-
With the -F option, you can add filters to the token stream, you can
|
79
|
-
give options in the same way as for -O after a colon (note: there must
|
80
|
-
not be spaces around the colon).
|
81
|
-
|
82
|
-
The -O, -P and -F options can be given multiple times.
|
83
|
-
|
84
|
-
With the -S option, print out style definitions for style <style>
|
85
|
-
for formatter <formatter>. The argument given by -a is formatter
|
86
|
-
dependent.
|
87
|
-
|
88
|
-
The -L option lists lexers, formatters, styles or filters -- set
|
89
|
-
`which` to the thing you want to list (e.g. "styles"), or omit it to
|
90
|
-
list everything.
|
91
|
-
|
92
|
-
The -N option guesses and prints out a lexer name based solely on
|
93
|
-
the given filename. It does not take input or highlight anything.
|
94
|
-
If no specific lexer can be determined "text" is returned.
|
95
|
-
|
96
|
-
The -H option prints detailed help for the object <name> of type <type>,
|
97
|
-
where <type> is one of "lexer", "formatter" or "filter".
|
98
|
-
|
99
|
-
The -s option processes lines one at a time until EOF, rather than
|
100
|
-
waiting to process the entire file. This only works for stdin, and
|
101
|
-
is intended for streaming input such as you get from 'tail -f'.
|
102
|
-
Example usage: "tail -f sql.log | pygmentize -s -l sql"
|
103
|
-
|
104
|
-
The -v option prints a detailed traceback on unhandled exceptions,
|
105
|
-
which is useful for debugging and bug reports.
|
106
|
-
|
107
|
-
The -h option prints this help.
|
108
|
-
The -V option prints the package version.
|
109
|
-
"""
|
110
|
-
|
111
|
-
|
112
33
|
def _parse_options(o_strs):
|
113
34
|
opts = {}
|
114
35
|
if not o_strs:
|
@@ -214,95 +135,94 @@ def _print_list(what):
|
|
214
135
|
print(" %s" % docstring_headline(cls))
|
215
136
|
|
216
137
|
|
217
|
-
def main_inner(
|
218
|
-
|
219
|
-
|
220
|
-
P_opts = []
|
221
|
-
F_opts = []
|
222
|
-
for opt, arg in popts:
|
223
|
-
if opt == '-O':
|
224
|
-
O_opts.append(arg)
|
225
|
-
elif opt == '-P':
|
226
|
-
P_opts.append(arg)
|
227
|
-
elif opt == '-F':
|
228
|
-
F_opts.append(arg)
|
229
|
-
opts[opt] = arg
|
230
|
-
|
231
|
-
if opts.pop('-h', None) is not None:
|
232
|
-
print(usage)
|
138
|
+
def main_inner(parser, argns):
|
139
|
+
if argns.help:
|
140
|
+
parser.print_help()
|
233
141
|
return 0
|
234
142
|
|
235
|
-
if
|
236
|
-
print('Pygments version %s, (c) 2006-
|
143
|
+
if argns.V:
|
144
|
+
print('Pygments version %s, (c) 2006-2021 by Georg Brandl, Matthäus '
|
145
|
+
'Chajdas and contributors.' % __version__)
|
237
146
|
return 0
|
238
147
|
|
148
|
+
def is_only_option(opt):
|
149
|
+
return not any(v for (k, v) in vars(argns).items() if k != opt)
|
150
|
+
|
239
151
|
# handle ``pygmentize -L``
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
print(usage, file=sys.stderr)
|
152
|
+
if argns.L is not None:
|
153
|
+
if not is_only_option('L'):
|
154
|
+
parser.print_help(sys.stderr)
|
244
155
|
return 2
|
245
|
-
|
246
156
|
# print version
|
247
157
|
main(['', '-V'])
|
248
|
-
|
249
|
-
|
250
|
-
for arg in
|
251
|
-
|
158
|
+
allowed_types = {'lexer', 'formatter', 'filter', 'style'}
|
159
|
+
largs = [arg.rstrip('s') for arg in argns.L]
|
160
|
+
if any(arg not in allowed_types for arg in largs):
|
161
|
+
parser.print_help(sys.stderr)
|
162
|
+
return 0
|
163
|
+
if not largs:
|
164
|
+
largs = allowed_types
|
165
|
+
for arg in largs:
|
166
|
+
_print_list(arg)
|
252
167
|
return 0
|
253
168
|
|
254
169
|
# handle ``pygmentize -H``
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
print(usage, file=sys.stderr)
|
170
|
+
if argns.H:
|
171
|
+
if not is_only_option('H'):
|
172
|
+
parser.print_help(sys.stderr)
|
259
173
|
return 2
|
260
|
-
|
261
|
-
what, name = args # pylint: disable=unbalanced-tuple-unpacking
|
174
|
+
what, name = argns.H
|
262
175
|
if what not in ('lexer', 'formatter', 'filter'):
|
263
|
-
|
176
|
+
parser.print_help(sys.stderr)
|
264
177
|
return 2
|
265
|
-
|
266
178
|
return _print_help(what, name)
|
267
179
|
|
268
180
|
# parse -O options
|
269
|
-
parsed_opts = _parse_options(
|
270
|
-
opts.pop('-O', None)
|
181
|
+
parsed_opts = _parse_options(argns.O or [])
|
271
182
|
|
272
183
|
# parse -P options
|
273
|
-
for p_opt in
|
184
|
+
for p_opt in argns.P or []:
|
274
185
|
try:
|
275
186
|
name, value = p_opt.split('=', 1)
|
276
187
|
except ValueError:
|
277
188
|
parsed_opts[p_opt] = True
|
278
189
|
else:
|
279
190
|
parsed_opts[name] = value
|
280
|
-
opts.pop('-P', None)
|
281
191
|
|
282
192
|
# encodings
|
283
193
|
inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
|
284
194
|
outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
|
285
195
|
|
286
196
|
# handle ``pygmentize -N``
|
287
|
-
|
288
|
-
|
289
|
-
lexer = find_lexer_class_for_filename(infn)
|
197
|
+
if argns.N:
|
198
|
+
lexer = find_lexer_class_for_filename(argns.N)
|
290
199
|
if lexer is None:
|
291
200
|
lexer = TextLexer
|
292
201
|
|
293
202
|
print(lexer.aliases[0])
|
294
203
|
return 0
|
295
204
|
|
205
|
+
# handle ``pygmentize -C``
|
206
|
+
if argns.C:
|
207
|
+
inp = sys.stdin.buffer.read()
|
208
|
+
try:
|
209
|
+
lexer = guess_lexer(inp, inencoding=inencoding)
|
210
|
+
except ClassNotFound:
|
211
|
+
lexer = TextLexer
|
212
|
+
|
213
|
+
print(lexer.aliases[0])
|
214
|
+
return 0
|
215
|
+
|
296
216
|
# handle ``pygmentize -S``
|
297
|
-
S_opt =
|
298
|
-
a_opt =
|
217
|
+
S_opt = argns.S
|
218
|
+
a_opt = argns.a
|
299
219
|
if S_opt is not None:
|
300
|
-
f_opt =
|
220
|
+
f_opt = argns.f
|
301
221
|
if not f_opt:
|
302
|
-
|
222
|
+
parser.print_help(sys.stderr)
|
303
223
|
return 2
|
304
|
-
if
|
305
|
-
|
224
|
+
if argns.l or argns.INPUTFILE:
|
225
|
+
parser.print_help(sys.stderr)
|
306
226
|
return 2
|
307
227
|
|
308
228
|
try:
|
@@ -316,30 +236,36 @@ def main_inner(popts, args, usage):
|
|
316
236
|
return 0
|
317
237
|
|
318
238
|
# if no -S is given, -a is not allowed
|
319
|
-
if
|
320
|
-
|
239
|
+
if argns.a is not None:
|
240
|
+
parser.print_help(sys.stderr)
|
321
241
|
return 2
|
322
242
|
|
323
243
|
# parse -F options
|
324
|
-
F_opts = _parse_filters(
|
325
|
-
opts.pop('-F', None)
|
244
|
+
F_opts = _parse_filters(argns.F or [])
|
326
245
|
|
327
|
-
allow_custom_lexer_formatter = False
|
328
246
|
# -x: allow custom (eXternal) lexers and formatters
|
329
|
-
|
330
|
-
allow_custom_lexer_formatter = True
|
247
|
+
allow_custom_lexer_formatter = bool(argns.x)
|
331
248
|
|
332
249
|
# select lexer
|
333
250
|
lexer = None
|
334
251
|
|
335
252
|
# given by name?
|
336
|
-
lexername =
|
253
|
+
lexername = argns.l
|
337
254
|
if lexername:
|
338
255
|
# custom lexer, located relative to user's cwd
|
339
256
|
if allow_custom_lexer_formatter and '.py' in lexername:
|
340
257
|
try:
|
258
|
+
filename = None
|
259
|
+
name = None
|
341
260
|
if ':' in lexername:
|
342
261
|
filename, name = lexername.rsplit(':', 1)
|
262
|
+
|
263
|
+
if '.py' in name:
|
264
|
+
# This can happen on Windows: If the lexername is
|
265
|
+
# C:\lexer.py -- return to normal load path in that case
|
266
|
+
name = None
|
267
|
+
|
268
|
+
if filename and name:
|
343
269
|
lexer = load_lexer_from_file(filename, name,
|
344
270
|
**parsed_opts)
|
345
271
|
else:
|
@@ -357,17 +283,13 @@ def main_inner(popts, args, usage):
|
|
357
283
|
# read input code
|
358
284
|
code = None
|
359
285
|
|
360
|
-
if
|
361
|
-
if
|
362
|
-
print(usage, file=sys.stderr)
|
363
|
-
return 2
|
364
|
-
|
365
|
-
if '-s' in opts:
|
286
|
+
if argns.INPUTFILE:
|
287
|
+
if argns.s:
|
366
288
|
print('Error: -s option not usable when input file specified',
|
367
289
|
file=sys.stderr)
|
368
290
|
return 2
|
369
291
|
|
370
|
-
infn =
|
292
|
+
infn = argns.INPUTFILE
|
371
293
|
try:
|
372
294
|
with open(infn, 'rb') as infp:
|
373
295
|
code = infp.read()
|
@@ -382,7 +304,7 @@ def main_inner(popts, args, usage):
|
|
382
304
|
try:
|
383
305
|
lexer = get_lexer_for_filename(infn, code, **parsed_opts)
|
384
306
|
except ClassNotFound as err:
|
385
|
-
if
|
307
|
+
if argns.g:
|
386
308
|
try:
|
387
309
|
lexer = guess_lexer(code, **parsed_opts)
|
388
310
|
except ClassNotFound:
|
@@ -394,14 +316,10 @@ def main_inner(popts, args, usage):
|
|
394
316
|
print('Error:', err, file=sys.stderr)
|
395
317
|
return 1
|
396
318
|
|
397
|
-
elif
|
319
|
+
elif not argns.s: # treat stdin as full file (-s support is later)
|
398
320
|
# read code from terminal, always in binary mode since we want to
|
399
321
|
# decode ourselves and be tolerant with it
|
400
|
-
|
401
|
-
# Python 3: we have to use .buffer to get a binary stream
|
402
|
-
code = sys.stdin.buffer.read()
|
403
|
-
else:
|
404
|
-
code = sys.stdin.read()
|
322
|
+
code = sys.stdin.buffer.read() # use .buffer to get a binary stream
|
405
323
|
if not inencoding:
|
406
324
|
code, inencoding = guess_decode_from_terminal(code, sys.stdin)
|
407
325
|
# else the lexer will do the decoding
|
@@ -426,15 +344,23 @@ def main_inner(popts, args, usage):
|
|
426
344
|
return 1
|
427
345
|
|
428
346
|
# select formatter
|
429
|
-
outfn =
|
430
|
-
fmter =
|
347
|
+
outfn = argns.o
|
348
|
+
fmter = argns.f
|
431
349
|
if fmter:
|
432
350
|
# custom formatter, located relative to user's cwd
|
433
351
|
if allow_custom_lexer_formatter and '.py' in fmter:
|
434
352
|
try:
|
353
|
+
filename = None
|
354
|
+
name = None
|
435
355
|
if ':' in fmter:
|
436
|
-
|
437
|
-
|
356
|
+
# Same logic as above for custom lexer
|
357
|
+
filename, name = fmter.rsplit(':', 1)
|
358
|
+
|
359
|
+
if '.py' in name:
|
360
|
+
name = None
|
361
|
+
|
362
|
+
if filename and name:
|
363
|
+
fmter = load_formatter_from_file(filename, name,
|
438
364
|
**parsed_opts)
|
439
365
|
else:
|
440
366
|
fmter = load_formatter_from_file(fmter, **parsed_opts)
|
@@ -466,11 +392,7 @@ def main_inner(popts, args, usage):
|
|
466
392
|
fmter = Terminal256Formatter(**parsed_opts)
|
467
393
|
else:
|
468
394
|
fmter = TerminalFormatter(**parsed_opts)
|
469
|
-
|
470
|
-
# Python 3: we have to use .buffer to get a binary stream
|
471
|
-
outfile = sys.stdout.buffer
|
472
|
-
else:
|
473
|
-
outfile = sys.stdout
|
395
|
+
outfile = sys.stdout.buffer
|
474
396
|
|
475
397
|
# determine output encoding if not explicitly selected
|
476
398
|
if not outencoding:
|
@@ -485,10 +407,8 @@ def main_inner(popts, args, usage):
|
|
485
407
|
if not outfn and sys.platform in ('win32', 'cygwin') and \
|
486
408
|
fmter.name in ('Terminal', 'Terminal256'): # pragma: no cover
|
487
409
|
# unfortunately colorama doesn't support binary streams on Py3
|
488
|
-
|
489
|
-
|
490
|
-
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
|
491
|
-
fmter.encoding = None
|
410
|
+
outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
|
411
|
+
fmter.encoding = None
|
492
412
|
try:
|
493
413
|
import colorama.initialise
|
494
414
|
except ImportError:
|
@@ -507,19 +427,19 @@ def main_inner(popts, args, usage):
|
|
507
427
|
lexer = LatexEmbeddedLexer(left, right, lexer)
|
508
428
|
|
509
429
|
# ... and do it!
|
510
|
-
if
|
430
|
+
if not argns.s:
|
511
431
|
# process whole input as per normal...
|
512
|
-
|
432
|
+
try:
|
433
|
+
highlight(code, lexer, fmter, outfile)
|
434
|
+
finally:
|
435
|
+
if outfn:
|
436
|
+
outfile.close()
|
513
437
|
return 0
|
514
438
|
else:
|
515
439
|
# line by line processing of stdin (eg: for 'tail -f')...
|
516
440
|
try:
|
517
441
|
while 1:
|
518
|
-
|
519
|
-
# Python 3: we have to use .buffer to get a binary stream
|
520
|
-
line = sys.stdin.buffer.readline()
|
521
|
-
else:
|
522
|
-
line = sys.stdin.readline()
|
442
|
+
line = sys.stdin.buffer.readline()
|
523
443
|
if not line:
|
524
444
|
break
|
525
445
|
if not inencoding:
|
@@ -530,31 +450,140 @@ def main_inner(popts, args, usage):
|
|
530
450
|
return 0
|
531
451
|
except KeyboardInterrupt: # pragma: no cover
|
532
452
|
return 0
|
453
|
+
finally:
|
454
|
+
if outfn:
|
455
|
+
outfile.close()
|
456
|
+
|
457
|
+
|
458
|
+
class HelpFormatter(argparse.HelpFormatter):
|
459
|
+
def __init__(self, prog, indent_increment=2, max_help_position=16, width=None):
|
460
|
+
if width is None:
|
461
|
+
try:
|
462
|
+
width = shutil.get_terminal_size().columns - 2
|
463
|
+
except Exception:
|
464
|
+
pass
|
465
|
+
argparse.HelpFormatter.__init__(self, prog, indent_increment,
|
466
|
+
max_help_position, width)
|
533
467
|
|
534
468
|
|
535
469
|
def main(args=sys.argv):
|
536
470
|
"""
|
537
471
|
Main command line entry point.
|
538
472
|
"""
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
473
|
+
desc = "Highlight an input file and write the result to an output file."
|
474
|
+
parser = argparse.ArgumentParser(description=desc, add_help=False,
|
475
|
+
formatter_class=HelpFormatter)
|
476
|
+
|
477
|
+
operation = parser.add_argument_group('Main operation')
|
478
|
+
lexersel = operation.add_mutually_exclusive_group()
|
479
|
+
lexersel.add_argument(
|
480
|
+
'-l', metavar='LEXER',
|
481
|
+
help='Specify the lexer to use. (Query names with -L.) If not '
|
482
|
+
'given and -g is not present, the lexer is guessed from the filename.')
|
483
|
+
lexersel.add_argument(
|
484
|
+
'-g', action='store_true',
|
485
|
+
help='Guess the lexer from the file contents, or pass through '
|
486
|
+
'as plain text if nothing can be guessed.')
|
487
|
+
operation.add_argument(
|
488
|
+
'-F', metavar='FILTER[:options]', action='append',
|
489
|
+
help='Add a filter to the token stream. (Query names with -L.) '
|
490
|
+
'Filter options are given after a colon if necessary.')
|
491
|
+
operation.add_argument(
|
492
|
+
'-f', metavar='FORMATTER',
|
493
|
+
help='Specify the formatter to use. (Query names with -L.) '
|
494
|
+
'If not given, the formatter is guessed from the output filename, '
|
495
|
+
'and defaults to the terminal formatter if the output is to the '
|
496
|
+
'terminal or an unknown file extension.')
|
497
|
+
operation.add_argument(
|
498
|
+
'-O', metavar='OPTION=value[,OPTION=value,...]', action='append',
|
499
|
+
help='Give options to the lexer and formatter as a comma-separated '
|
500
|
+
'list of key-value pairs. '
|
501
|
+
'Example: `-O bg=light,python=cool`.')
|
502
|
+
operation.add_argument(
|
503
|
+
'-P', metavar='OPTION=value', action='append',
|
504
|
+
help='Give a single option to the lexer and formatter - with this '
|
505
|
+
'you can pass options whose value contains commas and equal signs. '
|
506
|
+
'Example: `-P "heading=Pygments, the Python highlighter"`.')
|
507
|
+
operation.add_argument(
|
508
|
+
'-o', metavar='OUTPUTFILE',
|
509
|
+
help='Where to write the output. Defaults to standard output.')
|
510
|
+
|
511
|
+
operation.add_argument(
|
512
|
+
'INPUTFILE', nargs='?',
|
513
|
+
help='Where to read the input. Defaults to standard input.')
|
514
|
+
|
515
|
+
flags = parser.add_argument_group('Operation flags')
|
516
|
+
flags.add_argument(
|
517
|
+
'-v', action='store_true',
|
518
|
+
help='Print a detailed traceback on unhandled exceptions, which '
|
519
|
+
'is useful for debugging and bug reports.')
|
520
|
+
flags.add_argument(
|
521
|
+
'-s', action='store_true',
|
522
|
+
help='Process lines one at a time until EOF, rather than waiting to '
|
523
|
+
'process the entire file. This only works for stdin, only for lexers '
|
524
|
+
'with no line-spanning constructs, and is intended for streaming '
|
525
|
+
'input such as you get from `tail -f`. '
|
526
|
+
'Example usage: `tail -f sql.log | pygmentize -s -l sql`.')
|
527
|
+
flags.add_argument(
|
528
|
+
'-x', action='store_true',
|
529
|
+
help='Allow custom lexers and formatters to be loaded from a .py file '
|
530
|
+
'relative to the current working directory. For example, '
|
531
|
+
'`-l ./customlexer.py -x`. By default, this option expects a file '
|
532
|
+
'with a class named CustomLexer or CustomFormatter; you can also '
|
533
|
+
'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
|
534
|
+
'Users should be very careful not to use this option with untrusted '
|
535
|
+
'files, because it will import and run them.')
|
536
|
+
|
537
|
+
special_modes_group = parser.add_argument_group(
|
538
|
+
'Special modes - do not do any highlighting')
|
539
|
+
special_modes = special_modes_group.add_mutually_exclusive_group()
|
540
|
+
special_modes.add_argument(
|
541
|
+
'-S', metavar='STYLE -f formatter',
|
542
|
+
help='Print style definitions for STYLE for a formatter '
|
543
|
+
'given with -f. The argument given by -a is formatter '
|
544
|
+
'dependent.')
|
545
|
+
special_modes.add_argument(
|
546
|
+
'-L', nargs='*', metavar='WHAT',
|
547
|
+
help='List lexers, formatters, styles or filters -- '
|
548
|
+
'give additional arguments for the thing(s) you want to list '
|
549
|
+
'(e.g. "styles"), or omit them to list everything.')
|
550
|
+
special_modes.add_argument(
|
551
|
+
'-N', metavar='FILENAME',
|
552
|
+
help='Guess and print out a lexer name based solely on the given '
|
553
|
+
'filename. Does not take input or highlight anything. If no specific '
|
554
|
+
'lexer can be determined, "text" is printed.')
|
555
|
+
special_modes.add_argument(
|
556
|
+
'-C', action='store_true',
|
557
|
+
help='Like -N, but print out a lexer name based solely on '
|
558
|
+
'a given content from standard input.')
|
559
|
+
special_modes.add_argument(
|
560
|
+
'-H', action='store', nargs=2, metavar=('NAME', 'TYPE'),
|
561
|
+
help='Print detailed help for the object <name> of type <type>, '
|
562
|
+
'where <type> is one of "lexer", "formatter" or "filter".')
|
563
|
+
special_modes.add_argument(
|
564
|
+
'-V', action='store_true',
|
565
|
+
help='Print the package version.')
|
566
|
+
special_modes.add_argument(
|
567
|
+
'-h', '--help', action='store_true',
|
568
|
+
help='Print this help.')
|
569
|
+
special_modes_group.add_argument(
|
570
|
+
'-a', metavar='ARG',
|
571
|
+
help='Formatter-specific additional argument for the -S (print '
|
572
|
+
'style sheet) mode.')
|
573
|
+
|
574
|
+
argns = parser.parse_args(args[1:])
|
546
575
|
|
547
576
|
try:
|
548
|
-
return main_inner(
|
577
|
+
return main_inner(parser, argns)
|
549
578
|
except Exception:
|
550
|
-
if
|
579
|
+
if argns.v:
|
551
580
|
print(file=sys.stderr)
|
552
581
|
print('*' * 65, file=sys.stderr)
|
553
582
|
print('An unhandled exception occurred while highlighting.',
|
554
583
|
file=sys.stderr)
|
555
584
|
print('Please report the whole traceback to the issue tracker at',
|
556
585
|
file=sys.stderr)
|
557
|
-
print('<https://
|
586
|
+
print('<https://github.com/pygments/pygments/issues>.',
|
558
587
|
file=sys.stderr)
|
559
588
|
print('*' * 65, file=sys.stderr)
|
560
589
|
print(file=sys.stderr)
|