pygments.rb 1.2.1 → 2.0.0.rc2
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 +28 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +5 -6
- data/CHANGELOG.adoc +119 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.adoc +161 -0
- data/Rakefile +10 -21
- data/bench.rb +8 -7
- data/cache-lexers.rb +3 -2
- data/lib/pygments.rb +10 -11
- data/lib/pygments/lexer.rb +5 -5
- data/lib/pygments/mentos.py +23 -66
- data/lib/pygments/popen.rb +152 -204
- data/lib/pygments/version.rb +2 -2
- data/pygments.rb.gemspec +11 -9
- data/test/test_pygments.rb +51 -84
- data/vendor/pygments-main/{AUTHORS → Pygments-2.7.3.dist-info/AUTHORS} +21 -3
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/INSTALLER +1 -0
- data/vendor/pygments-main/{LICENSE → Pygments-2.7.3.dist-info/LICENSE} +1 -1
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/METADATA +49 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/RECORD +482 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/REQUESTED +0 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/WHEEL +5 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/entry_points.txt +3 -0
- data/vendor/pygments-main/Pygments-2.7.3.dist-info/top_level.txt +1 -0
- data/vendor/pygments-main/bin/pygmentize +8 -0
- data/vendor/pygments-main/pygments/__init__.py +6 -11
- data/vendor/pygments-main/pygments/__main__.py +18 -0
- data/vendor/pygments-main/pygments/cmdline.py +38 -29
- data/vendor/pygments-main/pygments/console.py +6 -9
- data/vendor/pygments-main/pygments/filter.py +4 -6
- data/vendor/pygments-main/pygments/filters/__init__.py +609 -21
- data/vendor/pygments-main/pygments/formatter.py +4 -4
- data/vendor/pygments-main/pygments/formatters/__init__.py +9 -8
- data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -3
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/html.py +223 -135
- data/vendor/pygments-main/pygments/formatters/img.py +68 -41
- data/vendor/pygments-main/pygments/formatters/irc.py +39 -39
- data/vendor/pygments-main/pygments/formatters/latex.py +56 -26
- data/vendor/pygments-main/pygments/formatters/other.py +12 -8
- data/vendor/pygments-main/pygments/formatters/rtf.py +29 -29
- data/vendor/pygments-main/pygments/formatters/svg.py +38 -4
- data/vendor/pygments-main/pygments/formatters/terminal.py +25 -31
- data/vendor/pygments-main/pygments/formatters/terminal256.py +22 -12
- data/vendor/pygments-main/pygments/lexer.py +41 -39
- data/vendor/pygments-main/pygments/lexers/__init__.py +342 -0
- data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +71 -0
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1725 -0
- data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +5327 -0
- data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +293 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +551 -0
- data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1172 -0
- data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1282 -0
- data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2547 -0
- data/vendor/pygments-main/pygments/lexers/_php_builtins.py +4753 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +678 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3094 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1161 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +558 -0
- data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +421 -0
- data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1004 -0
- data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +113 -0
- data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +280 -0
- data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1939 -0
- data/vendor/pygments-main/pygments/lexers/actionscript.py +245 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +24 -0
- data/vendor/pygments-main/pygments/lexers/algebra.py +240 -0
- data/vendor/pygments-main/pygments/lexers/ambient.py +76 -0
- data/vendor/pygments-main/pygments/lexers/ampl.py +87 -0
- data/vendor/pygments-main/pygments/lexers/apl.py +101 -0
- data/vendor/pygments-main/pygments/lexers/archetype.py +318 -0
- data/vendor/pygments-main/pygments/lexers/arrow.py +117 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +1005 -0
- data/vendor/pygments-main/pygments/lexers/automation.py +374 -0
- data/vendor/pygments-main/pygments/lexers/bare.py +104 -0
- data/vendor/pygments-main/pygments/lexers/basic.py +662 -0
- data/vendor/pygments-main/pygments/lexers/bibtex.py +160 -0
- data/vendor/pygments-main/pygments/lexers/boa.py +102 -0
- data/vendor/pygments-main/pygments/lexers/business.py +627 -0
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +344 -0
- data/vendor/pygments-main/pygments/lexers/c_like.py +566 -0
- data/vendor/pygments-main/pygments/lexers/capnproto.py +78 -0
- data/vendor/pygments-main/pygments/lexers/chapel.py +112 -0
- data/vendor/pygments-main/pygments/lexers/clean.py +179 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +34 -0
- data/vendor/pygments-main/pygments/lexers/configs.py +984 -0
- data/vendor/pygments-main/pygments/lexers/console.py +114 -0
- data/vendor/pygments-main/pygments/lexers/crystal.py +392 -0
- data/vendor/pygments-main/pygments/lexers/csound.py +467 -0
- data/vendor/pygments-main/pygments/lexers/css.py +691 -0
- data/vendor/pygments-main/pygments/lexers/d.py +256 -0
- data/vendor/pygments-main/pygments/lexers/dalvik.py +125 -0
- data/vendor/pygments-main/pygments/lexers/data.py +698 -0
- data/vendor/pygments-main/pygments/lexers/devicetree.py +109 -0
- data/vendor/pygments-main/pygments/lexers/diff.py +165 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +707 -0
- data/vendor/pygments-main/pygments/lexers/dsls.py +960 -0
- data/vendor/pygments-main/pygments/lexers/dylan.py +287 -0
- data/vendor/pygments-main/pygments/lexers/ecl.py +139 -0
- data/vendor/pygments-main/pygments/lexers/eiffel.py +65 -0
- data/vendor/pygments-main/pygments/lexers/elm.py +121 -0
- data/vendor/pygments-main/pygments/lexers/email.py +151 -0
- data/vendor/pygments-main/pygments/lexers/erlang.py +530 -0
- data/vendor/pygments-main/pygments/lexers/esoteric.py +304 -0
- data/vendor/pygments-main/pygments/lexers/ezhil.py +77 -0
- data/vendor/pygments-main/pygments/lexers/factor.py +344 -0
- data/vendor/pygments-main/pygments/lexers/fantom.py +250 -0
- data/vendor/pygments-main/pygments/lexers/felix.py +273 -0
- data/vendor/pygments-main/pygments/lexers/floscript.py +83 -0
- data/vendor/pygments-main/pygments/lexers/forth.py +178 -0
- data/vendor/pygments-main/pygments/lexers/fortran.py +206 -0
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/freefem.py +898 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +21 -0
- data/vendor/pygments-main/pygments/lexers/gdscript.py +346 -0
- data/vendor/pygments-main/pygments/lexers/go.py +101 -0
- data/vendor/pygments-main/pygments/lexers/grammar_notation.py +270 -0
- data/vendor/pygments-main/pygments/lexers/graph.py +85 -0
- data/vendor/pygments-main/pygments/lexers/graphics.py +800 -0
- data/vendor/pygments-main/pygments/lexers/haskell.py +870 -0
- data/vendor/pygments-main/pygments/lexers/haxe.py +936 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +472 -0
- data/vendor/pygments-main/pygments/lexers/hexdump.py +103 -0
- data/vendor/pygments-main/pygments/lexers/html.py +614 -0
- data/vendor/pygments-main/pygments/lexers/idl.py +281 -0
- data/vendor/pygments-main/pygments/lexers/igor.py +420 -0
- data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
- data/vendor/pygments-main/pygments/lexers/installers.py +322 -0
- data/vendor/pygments-main/pygments/lexers/int_fiction.py +1368 -0
- data/vendor/pygments-main/pygments/lexers/iolang.py +63 -0
- data/vendor/pygments-main/pygments/lexers/j.py +146 -0
- data/vendor/pygments-main/pygments/lexers/javascript.py +1540 -0
- data/vendor/pygments-main/pygments/lexers/julia.py +331 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +1673 -0
- data/vendor/pygments-main/pygments/lexers/lisp.py +2699 -0
- data/vendor/pygments-main/pygments/lexers/make.py +206 -0
- data/vendor/pygments-main/pygments/lexers/markup.py +765 -0
- data/vendor/pygments-main/pygments/lexers/math.py +21 -0
- data/vendor/pygments-main/pygments/lexers/matlab.py +720 -0
- data/vendor/pygments-main/pygments/lexers/mime.py +226 -0
- data/vendor/pygments-main/pygments/lexers/ml.py +958 -0
- data/vendor/pygments-main/pygments/lexers/modeling.py +366 -0
- data/vendor/pygments-main/pygments/lexers/modula2.py +1580 -0
- data/vendor/pygments-main/pygments/lexers/monte.py +204 -0
- data/vendor/pygments-main/pygments/lexers/mosel.py +448 -0
- data/vendor/pygments-main/pygments/lexers/ncl.py +894 -0
- data/vendor/pygments-main/pygments/lexers/nimrod.py +159 -0
- data/vendor/pygments-main/pygments/lexers/nit.py +64 -0
- data/vendor/pygments-main/pygments/lexers/nix.py +136 -0
- data/vendor/pygments-main/pygments/lexers/oberon.py +121 -0
- data/vendor/pygments-main/pygments/lexers/objective.py +504 -0
- data/vendor/pygments-main/pygments/lexers/ooc.py +85 -0
- data/vendor/pygments-main/pygments/lexers/other.py +41 -0
- data/vendor/pygments-main/pygments/lexers/parasail.py +79 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +800 -0
- data/vendor/pygments-main/pygments/lexers/pascal.py +644 -0
- data/vendor/pygments-main/pygments/lexers/pawn.py +205 -0
- data/vendor/pygments-main/pygments/lexers/perl.py +732 -0
- data/vendor/pygments-main/pygments/lexers/php.py +321 -0
- data/vendor/pygments-main/pygments/lexers/pointless.py +71 -0
- data/vendor/pygments-main/pygments/lexers/pony.py +94 -0
- data/vendor/pygments-main/pygments/lexers/praat.py +302 -0
- data/vendor/pygments-main/pygments/lexers/prolog.py +306 -0
- data/vendor/pygments-main/pygments/lexers/promql.py +183 -0
- data/vendor/pygments-main/pygments/lexers/python.py +1151 -0
- data/vendor/pygments-main/pygments/lexers/qvt.py +152 -0
- data/vendor/pygments-main/pygments/lexers/r.py +191 -0
- data/vendor/pygments-main/pygments/lexers/rdf.py +463 -0
- data/vendor/pygments-main/pygments/lexers/rebol.py +431 -0
- data/vendor/pygments-main/pygments/lexers/resource.py +85 -0
- data/vendor/pygments-main/pygments/lexers/ride.py +139 -0
- data/vendor/pygments-main/pygments/lexers/rnc.py +67 -0
- data/vendor/pygments-main/pygments/lexers/roboconf.py +82 -0
- data/vendor/pygments-main/pygments/lexers/robotframework.py +552 -0
- data/vendor/pygments-main/pygments/lexers/ruby.py +517 -0
- data/vendor/pygments-main/pygments/lexers/rust.py +224 -0
- data/vendor/pygments-main/pygments/lexers/sas.py +228 -0
- data/vendor/pygments-main/pygments/lexers/scdoc.py +83 -0
- data/vendor/pygments-main/pygments/lexers/scripting.py +1284 -0
- data/vendor/pygments-main/pygments/lexers/sgf.py +61 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +914 -0
- data/vendor/pygments-main/pygments/lexers/sieve.py +69 -0
- data/vendor/pygments-main/pygments/lexers/slash.py +185 -0
- data/vendor/pygments-main/pygments/lexers/smalltalk.py +195 -0
- data/vendor/pygments-main/pygments/lexers/smv.py +79 -0
- data/vendor/pygments-main/pygments/lexers/snobol.py +83 -0
- data/vendor/pygments-main/pygments/lexers/solidity.py +92 -0
- data/vendor/pygments-main/pygments/lexers/special.py +105 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +837 -0
- data/vendor/pygments-main/pygments/lexers/stata.py +171 -0
- data/vendor/pygments-main/pygments/lexers/supercollider.py +95 -0
- data/vendor/pygments-main/pygments/lexers/tcl.py +145 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +2264 -0
- data/vendor/pygments-main/pygments/lexers/teraterm.py +335 -0
- data/vendor/pygments-main/pygments/lexers/testing.py +207 -0
- data/vendor/pygments-main/pygments/lexers/text.py +26 -0
- data/vendor/pygments-main/pygments/lexers/textedit.py +169 -0
- data/vendor/pygments-main/pygments/lexers/textfmts.py +430 -0
- data/vendor/pygments-main/pygments/lexers/theorem.py +474 -0
- data/vendor/pygments-main/pygments/lexers/tnt.py +263 -0
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +54 -0
- data/vendor/pygments-main/pygments/lexers/typoscript.py +219 -0
- data/vendor/pygments-main/pygments/lexers/unicon.py +412 -0
- data/vendor/pygments-main/pygments/lexers/urbi.py +146 -0
- data/vendor/pygments-main/pygments/lexers/usd.py +90 -0
- data/vendor/pygments-main/pygments/lexers/varnish.py +190 -0
- data/vendor/pygments-main/pygments/lexers/verification.py +114 -0
- data/vendor/pygments-main/pygments/lexers/web.py +24 -0
- data/vendor/pygments-main/pygments/lexers/webidl.py +299 -0
- data/vendor/pygments-main/pygments/lexers/webmisc.py +991 -0
- data/vendor/pygments-main/pygments/lexers/whiley.py +116 -0
- data/vendor/pygments-main/pygments/lexers/x10.py +69 -0
- data/vendor/pygments-main/pygments/lexers/xorg.py +37 -0
- data/vendor/pygments-main/pygments/lexers/yang.py +104 -0
- data/vendor/pygments-main/pygments/lexers/zig.py +124 -0
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +4 -2
- data/vendor/pygments-main/pygments/regexopt.py +1 -1
- data/vendor/pygments-main/pygments/scanner.py +2 -2
- data/vendor/pygments-main/pygments/sphinxext.py +2 -4
- data/vendor/pygments-main/pygments/style.py +61 -24
- data/vendor/pygments-main/pygments/styles/__init__.py +10 -4
- data/vendor/pygments-main/pygments/styles/abap.py +1 -1
- data/vendor/pygments-main/pygments/styles/algol.py +1 -1
- data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
- data/vendor/pygments-main/pygments/styles/arduino.py +2 -2
- 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 +1 -1
- data/vendor/pygments-main/pygments/styles/inkpot.py +67 -0
- data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/monokai.py +4 -3
- 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 +1 -1
- data/vendor/pygments-main/pygments/styles/paraiso_light.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/rainbow_dash.py +1 -1
- data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
- data/vendor/pygments-main/pygments/styles/sas.py +1 -1
- data/vendor/pygments-main/pygments/styles/solarized.py +134 -0
- data/vendor/pygments-main/pygments/styles/stata_dark.py +41 -0
- data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -15
- 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 +1 -1
- data/vendor/pygments-main/pygments/token.py +1 -1
- data/vendor/pygments-main/pygments/unistring.py +47 -108
- data/vendor/pygments-main/pygments/util.py +15 -92
- metadata +69 -136
- data/CHANGELOG.md +0 -111
- data/README.md +0 -121
- data/circle.yml +0 -20
- 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/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
@@ -1,69 +0,0 @@
|
|
1
|
-
.. -*- mode: rst -*-
|
2
|
-
|
3
|
-
================
|
4
|
-
Available lexers
|
5
|
-
================
|
6
|
-
|
7
|
-
This page lists all available builtin lexers and the options they take.
|
8
|
-
|
9
|
-
Currently, **all lexers** support these options:
|
10
|
-
|
11
|
-
`stripnl`
|
12
|
-
Strip leading and trailing newlines from the input (default: ``True``)
|
13
|
-
|
14
|
-
`stripall`
|
15
|
-
Strip all leading and trailing whitespace from the input (default:
|
16
|
-
``False``).
|
17
|
-
|
18
|
-
`ensurenl`
|
19
|
-
Make sure that the input ends with a newline (default: ``True``). This
|
20
|
-
is required for some lexers that consume input linewise.
|
21
|
-
|
22
|
-
.. versionadded:: 1.3
|
23
|
-
|
24
|
-
`tabsize`
|
25
|
-
If given and greater than 0, expand tabs in the input (default: ``0``).
|
26
|
-
|
27
|
-
`encoding`
|
28
|
-
If given, must be an encoding name (such as ``"utf-8"``). This encoding
|
29
|
-
will be used to convert the input string to Unicode (if it is not already
|
30
|
-
a Unicode string). The default is ``"guess"``.
|
31
|
-
|
32
|
-
If this option is set to ``"guess"``, a simple UTF-8 vs. Latin-1
|
33
|
-
detection is used, if it is set to ``"chardet"``, the
|
34
|
-
`chardet library <https://chardet.github.io/>`_ is used to
|
35
|
-
guess the encoding of the input.
|
36
|
-
|
37
|
-
.. versionadded:: 0.6
|
38
|
-
|
39
|
-
|
40
|
-
The "Short Names" field lists the identifiers that can be used with the
|
41
|
-
`get_lexer_by_name()` function.
|
42
|
-
|
43
|
-
These lexers are builtin and can be imported from `pygments.lexers`:
|
44
|
-
|
45
|
-
.. pygmentsdoc:: lexers
|
46
|
-
|
47
|
-
|
48
|
-
Iterating over all lexers
|
49
|
-
-------------------------
|
50
|
-
|
51
|
-
.. versionadded:: 0.6
|
52
|
-
|
53
|
-
To get all lexers (both the builtin and the plugin ones), you can
|
54
|
-
use the `get_all_lexers()` function from the `pygments.lexers`
|
55
|
-
module:
|
56
|
-
|
57
|
-
.. sourcecode:: pycon
|
58
|
-
|
59
|
-
>>> from pygments.lexers import get_all_lexers
|
60
|
-
>>> i = get_all_lexers()
|
61
|
-
>>> i.next()
|
62
|
-
('Diff', ('diff',), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch'))
|
63
|
-
>>> i.next()
|
64
|
-
('Delphi', ('delphi', 'objectpascal', 'pas', 'pascal'), ('*.pas',), ('text/x-pascal',))
|
65
|
-
>>> i.next()
|
66
|
-
('XML+Ruby', ('xml+erb', 'xml+ruby'), (), ())
|
67
|
-
|
68
|
-
As you can see, the return value is an iterator which yields tuples
|
69
|
-
in the form ``(name, aliases, filetypes, mimetypes)``.
|
@@ -1,39 +0,0 @@
|
|
1
|
-
.. -*- mode: rst -*-
|
2
|
-
|
3
|
-
============================
|
4
|
-
Using Pygments with MoinMoin
|
5
|
-
============================
|
6
|
-
|
7
|
-
From Pygments 0.7, the source distribution ships a `Moin`_ parser plugin that
|
8
|
-
can be used to get Pygments highlighting in Moin wiki pages.
|
9
|
-
|
10
|
-
To use it, copy the file `external/moin-parser.py` from the Pygments
|
11
|
-
distribution to the `data/plugin/parser` subdirectory of your Moin instance.
|
12
|
-
Edit the options at the top of the file (currently ``ATTACHMENTS`` and
|
13
|
-
``INLINESTYLES``) and rename the file to the name that the parser directive
|
14
|
-
should have. For example, if you name the file ``code.py``, you can get a
|
15
|
-
highlighted Python code sample with this Wiki markup::
|
16
|
-
|
17
|
-
{{{
|
18
|
-
#!code python
|
19
|
-
[...]
|
20
|
-
}}}
|
21
|
-
|
22
|
-
where ``python`` is the Pygments name of the lexer to use.
|
23
|
-
|
24
|
-
Additionally, if you set the ``ATTACHMENTS`` option to True, Pygments will also
|
25
|
-
be called for all attachments for whose filenames there is no other parser
|
26
|
-
registered.
|
27
|
-
|
28
|
-
You are responsible for including CSS rules that will map the Pygments CSS
|
29
|
-
classes to colors. You can output a stylesheet file with `pygmentize`, put it
|
30
|
-
into the `htdocs` directory of your Moin instance and then include it in the
|
31
|
-
`stylesheets` configuration option in the Moin config, e.g.::
|
32
|
-
|
33
|
-
stylesheets = [('screen', '/htdocs/pygments.css')]
|
34
|
-
|
35
|
-
If you do not want to do that and are willing to accept larger HTML output, you
|
36
|
-
can set the ``INLINESTYLES`` option to True.
|
37
|
-
|
38
|
-
|
39
|
-
.. _Moin: http://moinmoin.wikiwikiweb.de/
|
@@ -1,93 +0,0 @@
|
|
1
|
-
================
|
2
|
-
Register Plugins
|
3
|
-
================
|
4
|
-
|
5
|
-
If you want to extend Pygments without hacking the sources, but want to
|
6
|
-
use the lexer/formatter/style/filter lookup functions (`lexers.get_lexer_by_name`
|
7
|
-
et al.), you can use `setuptools`_ entrypoints to add new lexers, formatters
|
8
|
-
or styles as if they were in the Pygments core.
|
9
|
-
|
10
|
-
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
|
11
|
-
|
12
|
-
That means you can use your highlighter modules with the `pygmentize` script,
|
13
|
-
which relies on the mentioned functions.
|
14
|
-
|
15
|
-
|
16
|
-
Entrypoints
|
17
|
-
===========
|
18
|
-
|
19
|
-
Here is a list of setuptools entrypoints that Pygments understands:
|
20
|
-
|
21
|
-
`pygments.lexers`
|
22
|
-
|
23
|
-
This entrypoint is used for adding new lexers to the Pygments core.
|
24
|
-
The name of the entrypoint values doesn't really matter, Pygments extracts
|
25
|
-
required metadata from the class definition:
|
26
|
-
|
27
|
-
.. sourcecode:: ini
|
28
|
-
|
29
|
-
[pygments.lexers]
|
30
|
-
yourlexer = yourmodule:YourLexer
|
31
|
-
|
32
|
-
Note that you have to define ``name``, ``aliases`` and ``filename``
|
33
|
-
attributes so that you can use the highlighter from the command line:
|
34
|
-
|
35
|
-
.. sourcecode:: python
|
36
|
-
|
37
|
-
class YourLexer(...):
|
38
|
-
name = 'Name Of Your Lexer'
|
39
|
-
aliases = ['alias']
|
40
|
-
filenames = ['*.ext']
|
41
|
-
|
42
|
-
|
43
|
-
`pygments.formatters`
|
44
|
-
|
45
|
-
You can use this entrypoint to add new formatters to Pygments. The
|
46
|
-
name of an entrypoint item is the name of the formatter. If you
|
47
|
-
prefix the name with a slash it's used as a filename pattern:
|
48
|
-
|
49
|
-
.. sourcecode:: ini
|
50
|
-
|
51
|
-
[pygments.formatters]
|
52
|
-
yourformatter = yourmodule:YourFormatter
|
53
|
-
/.ext = yourmodule:YourFormatter
|
54
|
-
|
55
|
-
|
56
|
-
`pygments.styles`
|
57
|
-
|
58
|
-
To add a new style you can use this entrypoint. The name of the entrypoint
|
59
|
-
is the name of the style:
|
60
|
-
|
61
|
-
.. sourcecode:: ini
|
62
|
-
|
63
|
-
[pygments.styles]
|
64
|
-
yourstyle = yourmodule:YourStyle
|
65
|
-
|
66
|
-
|
67
|
-
`pygments.filters`
|
68
|
-
|
69
|
-
Use this entrypoint to register a new filter. The name of the
|
70
|
-
entrypoint is the name of the filter:
|
71
|
-
|
72
|
-
.. sourcecode:: ini
|
73
|
-
|
74
|
-
[pygments.filters]
|
75
|
-
yourfilter = yourmodule:YourFilter
|
76
|
-
|
77
|
-
|
78
|
-
How To Use Entrypoints
|
79
|
-
======================
|
80
|
-
|
81
|
-
This documentation doesn't explain how to use those entrypoints because this is
|
82
|
-
covered in the `setuptools documentation`_. That page should cover everything
|
83
|
-
you need to write a plugin.
|
84
|
-
|
85
|
-
.. _setuptools documentation: http://peak.telecommunity.com/DevCenter/setuptools
|
86
|
-
|
87
|
-
|
88
|
-
Extending The Core
|
89
|
-
==================
|
90
|
-
|
91
|
-
If you have written a Pygments plugin that is open source, please inform us
|
92
|
-
about that. There is a high chance that we'll add it to the Pygments
|
93
|
-
distribution.
|
@@ -1,205 +0,0 @@
|
|
1
|
-
.. -*- mode: rst -*-
|
2
|
-
|
3
|
-
===========================
|
4
|
-
Introduction and Quickstart
|
5
|
-
===========================
|
6
|
-
|
7
|
-
|
8
|
-
Welcome to Pygments! This document explains the basic concepts and terms and
|
9
|
-
gives a few examples of how to use the library.
|
10
|
-
|
11
|
-
|
12
|
-
Architecture
|
13
|
-
============
|
14
|
-
|
15
|
-
There are four types of components that work together highlighting a piece of
|
16
|
-
code:
|
17
|
-
|
18
|
-
* A **lexer** splits the source into tokens, fragments of the source that
|
19
|
-
have a token type that determines what the text represents semantically
|
20
|
-
(e.g., keyword, string, or comment). There is a lexer for every language
|
21
|
-
or markup format that Pygments supports.
|
22
|
-
* The token stream can be piped through **filters**, which usually modify
|
23
|
-
the token types or text fragments, e.g. uppercasing all keywords.
|
24
|
-
* A **formatter** then takes the token stream and writes it to an output
|
25
|
-
file, in a format such as HTML, LaTeX or RTF.
|
26
|
-
* While writing the output, a **style** determines how to highlight all the
|
27
|
-
different token types. It maps them to attributes like "red and bold".
|
28
|
-
|
29
|
-
|
30
|
-
Example
|
31
|
-
=======
|
32
|
-
|
33
|
-
Here is a small example for highlighting Python code:
|
34
|
-
|
35
|
-
.. sourcecode:: python
|
36
|
-
|
37
|
-
from pygments import highlight
|
38
|
-
from pygments.lexers import PythonLexer
|
39
|
-
from pygments.formatters import HtmlFormatter
|
40
|
-
|
41
|
-
code = 'print "Hello World"'
|
42
|
-
print highlight(code, PythonLexer(), HtmlFormatter())
|
43
|
-
|
44
|
-
which prints something like this:
|
45
|
-
|
46
|
-
.. sourcecode:: html
|
47
|
-
|
48
|
-
<div class="highlight">
|
49
|
-
<pre><span class="k">print</span> <span class="s">"Hello World"</span></pre>
|
50
|
-
</div>
|
51
|
-
|
52
|
-
As you can see, Pygments uses CSS classes (by default, but you can change that)
|
53
|
-
instead of inline styles in order to avoid outputting redundant style information over
|
54
|
-
and over. A CSS stylesheet that contains all CSS classes possibly used in the output
|
55
|
-
can be produced by:
|
56
|
-
|
57
|
-
.. sourcecode:: python
|
58
|
-
|
59
|
-
print HtmlFormatter().get_style_defs('.highlight')
|
60
|
-
|
61
|
-
The argument to :func:`get_style_defs` is used as an additional CSS selector:
|
62
|
-
the output may look like this:
|
63
|
-
|
64
|
-
.. sourcecode:: css
|
65
|
-
|
66
|
-
.highlight .k { color: #AA22FF; font-weight: bold }
|
67
|
-
.highlight .s { color: #BB4444 }
|
68
|
-
...
|
69
|
-
|
70
|
-
|
71
|
-
Options
|
72
|
-
=======
|
73
|
-
|
74
|
-
The :func:`highlight()` function supports a fourth argument called *outfile*, it
|
75
|
-
must be a file object if given. The formatted output will then be written to
|
76
|
-
this file instead of being returned as a string.
|
77
|
-
|
78
|
-
Lexers and formatters both support options. They are given to them as keyword
|
79
|
-
arguments either to the class or to the lookup method:
|
80
|
-
|
81
|
-
.. sourcecode:: python
|
82
|
-
|
83
|
-
from pygments import highlight
|
84
|
-
from pygments.lexers import get_lexer_by_name
|
85
|
-
from pygments.formatters import HtmlFormatter
|
86
|
-
|
87
|
-
lexer = get_lexer_by_name("python", stripall=True)
|
88
|
-
formatter = HtmlFormatter(linenos=True, cssclass="source")
|
89
|
-
result = highlight(code, lexer, formatter)
|
90
|
-
|
91
|
-
This makes the lexer strip all leading and trailing whitespace from the input
|
92
|
-
(`stripall` option), lets the formatter output line numbers (`linenos` option),
|
93
|
-
and sets the wrapping ``<div>``'s class to ``source`` (instead of
|
94
|
-
``highlight``).
|
95
|
-
|
96
|
-
Important options include:
|
97
|
-
|
98
|
-
`encoding` : for lexers and formatters
|
99
|
-
Since Pygments uses Unicode strings internally, this determines which
|
100
|
-
encoding will be used to convert to or from byte strings.
|
101
|
-
`style` : for formatters
|
102
|
-
The name of the style to use when writing the output.
|
103
|
-
|
104
|
-
|
105
|
-
For an overview of builtin lexers and formatters and their options, visit the
|
106
|
-
:doc:`lexer <lexers>` and :doc:`formatters <formatters>` lists.
|
107
|
-
|
108
|
-
For a documentation on filters, see :doc:`this page <filters>`.
|
109
|
-
|
110
|
-
|
111
|
-
Lexer and formatter lookup
|
112
|
-
==========================
|
113
|
-
|
114
|
-
If you want to lookup a built-in lexer by its alias or a filename, you can use
|
115
|
-
one of the following methods:
|
116
|
-
|
117
|
-
.. sourcecode:: pycon
|
118
|
-
|
119
|
-
>>> from pygments.lexers import (get_lexer_by_name,
|
120
|
-
... get_lexer_for_filename, get_lexer_for_mimetype)
|
121
|
-
|
122
|
-
>>> get_lexer_by_name('python')
|
123
|
-
<pygments.lexers.PythonLexer>
|
124
|
-
|
125
|
-
>>> get_lexer_for_filename('spam.rb')
|
126
|
-
<pygments.lexers.RubyLexer>
|
127
|
-
|
128
|
-
>>> get_lexer_for_mimetype('text/x-perl')
|
129
|
-
<pygments.lexers.PerlLexer>
|
130
|
-
|
131
|
-
All these functions accept keyword arguments; they will be passed to the lexer
|
132
|
-
as options.
|
133
|
-
|
134
|
-
A similar API is available for formatters: use :func:`.get_formatter_by_name()`
|
135
|
-
and :func:`.get_formatter_for_filename()` from the :mod:`pygments.formatters`
|
136
|
-
module for this purpose.
|
137
|
-
|
138
|
-
|
139
|
-
Guessing lexers
|
140
|
-
===============
|
141
|
-
|
142
|
-
If you don't know the content of the file, or you want to highlight a file
|
143
|
-
whose extension is ambiguous, such as ``.html`` (which could contain plain HTML
|
144
|
-
or some template tags), use these functions:
|
145
|
-
|
146
|
-
.. sourcecode:: pycon
|
147
|
-
|
148
|
-
>>> from pygments.lexers import guess_lexer, guess_lexer_for_filename
|
149
|
-
|
150
|
-
>>> guess_lexer('#!/usr/bin/python\nprint "Hello World!"')
|
151
|
-
<pygments.lexers.PythonLexer>
|
152
|
-
|
153
|
-
>>> guess_lexer_for_filename('test.py', 'print "Hello World!"')
|
154
|
-
<pygments.lexers.PythonLexer>
|
155
|
-
|
156
|
-
:func:`.guess_lexer()` passes the given content to the lexer classes'
|
157
|
-
:meth:`analyse_text()` method and returns the one for which it returns the
|
158
|
-
highest number.
|
159
|
-
|
160
|
-
All lexers have two different filename pattern lists: the primary and the
|
161
|
-
secondary one. The :func:`.get_lexer_for_filename()` function only uses the
|
162
|
-
primary list, whose entries are supposed to be unique among all lexers.
|
163
|
-
:func:`.guess_lexer_for_filename()`, however, will first loop through all lexers
|
164
|
-
and look at the primary and secondary filename patterns if the filename matches.
|
165
|
-
If only one lexer matches, it is returned, else the guessing mechanism of
|
166
|
-
:func:`.guess_lexer()` is used with the matching lexers.
|
167
|
-
|
168
|
-
As usual, keyword arguments to these functions are given to the created lexer
|
169
|
-
as options.
|
170
|
-
|
171
|
-
|
172
|
-
Command line usage
|
173
|
-
==================
|
174
|
-
|
175
|
-
You can use Pygments from the command line, using the :program:`pygmentize`
|
176
|
-
script::
|
177
|
-
|
178
|
-
$ pygmentize test.py
|
179
|
-
|
180
|
-
will highlight the Python file test.py using ANSI escape sequences
|
181
|
-
(a.k.a. terminal colors) and print the result to standard output.
|
182
|
-
|
183
|
-
To output HTML, use the ``-f`` option::
|
184
|
-
|
185
|
-
$ pygmentize -f html -o test.html test.py
|
186
|
-
|
187
|
-
to write an HTML-highlighted version of test.py to the file test.html.
|
188
|
-
Note that it will only be a snippet of HTML, if you want a full HTML document,
|
189
|
-
use the "full" option::
|
190
|
-
|
191
|
-
$ pygmentize -f html -O full -o test.html test.py
|
192
|
-
|
193
|
-
This will produce a full HTML document with included stylesheet.
|
194
|
-
|
195
|
-
A style can be selected with ``-O style=<name>``.
|
196
|
-
|
197
|
-
If you need a stylesheet for an existing HTML file using Pygments CSS classes,
|
198
|
-
it can be created with::
|
199
|
-
|
200
|
-
$ pygmentize -S default -f html > style.css
|
201
|
-
|
202
|
-
where ``default`` is the style name.
|
203
|
-
|
204
|
-
More options and tricks and be found in the :doc:`command line reference
|
205
|
-
<cmdline>`.
|
@@ -1,22 +0,0 @@
|
|
1
|
-
.. -*- mode: rst -*-
|
2
|
-
|
3
|
-
================================
|
4
|
-
Using Pygments in ReST documents
|
5
|
-
================================
|
6
|
-
|
7
|
-
Many Python people use `ReST`_ for documentation their sourcecode, programs,
|
8
|
-
scripts et cetera. This also means that documentation often includes sourcecode
|
9
|
-
samples or snippets.
|
10
|
-
|
11
|
-
You can easily enable Pygments support for your ReST texts using a custom
|
12
|
-
directive -- this is also how this documentation displays source code.
|
13
|
-
|
14
|
-
From Pygments 0.9, the directive is shipped in the distribution as
|
15
|
-
`external/rst-directive.py`. You can copy and adapt this code to your liking.
|
16
|
-
|
17
|
-
.. removed -- too confusing
|
18
|
-
*Loosely related note:* The ReST lexer now recognizes ``.. sourcecode::`` and
|
19
|
-
``.. code::`` directives and highlights the contents in the specified language
|
20
|
-
if the `handlecodeblocks` option is true.
|
21
|
-
|
22
|
-
.. _ReST: http://docutils.sf.net/rst.html
|
@@ -1,201 +0,0 @@
|
|
1
|
-
.. -*- mode: rst -*-
|
2
|
-
|
3
|
-
======
|
4
|
-
Styles
|
5
|
-
======
|
6
|
-
|
7
|
-
Pygments comes with some builtin styles that work for both the HTML and
|
8
|
-
LaTeX formatter.
|
9
|
-
|
10
|
-
The builtin styles can be looked up with the `get_style_by_name` function:
|
11
|
-
|
12
|
-
.. sourcecode:: pycon
|
13
|
-
|
14
|
-
>>> from pygments.styles import get_style_by_name
|
15
|
-
>>> get_style_by_name('colorful')
|
16
|
-
<class 'pygments.styles.colorful.ColorfulStyle'>
|
17
|
-
|
18
|
-
You can pass a instance of a `Style` class to a formatter as the `style`
|
19
|
-
option in form of a string:
|
20
|
-
|
21
|
-
.. sourcecode:: pycon
|
22
|
-
|
23
|
-
>>> from pygments.styles import get_style_by_name
|
24
|
-
>>> from pygments.formatters import HtmlFormatter
|
25
|
-
>>> HtmlFormatter(style='colorful').style
|
26
|
-
<class 'pygments.styles.colorful.ColorfulStyle'>
|
27
|
-
|
28
|
-
Or you can also import your own style (which must be a subclass of
|
29
|
-
`pygments.style.Style`) and pass it to the formatter:
|
30
|
-
|
31
|
-
.. sourcecode:: pycon
|
32
|
-
|
33
|
-
>>> from yourapp.yourmodule import YourStyle
|
34
|
-
>>> from pygments.formatters import HtmlFormatter
|
35
|
-
>>> HtmlFormatter(style=YourStyle).style
|
36
|
-
<class 'yourapp.yourmodule.YourStyle'>
|
37
|
-
|
38
|
-
|
39
|
-
Creating Own Styles
|
40
|
-
===================
|
41
|
-
|
42
|
-
So, how to create a style? All you have to do is to subclass `Style` and
|
43
|
-
define some styles:
|
44
|
-
|
45
|
-
.. sourcecode:: python
|
46
|
-
|
47
|
-
from pygments.style import Style
|
48
|
-
from pygments.token import Keyword, Name, Comment, String, Error, \
|
49
|
-
Number, Operator, Generic
|
50
|
-
|
51
|
-
class YourStyle(Style):
|
52
|
-
default_style = ""
|
53
|
-
styles = {
|
54
|
-
Comment: 'italic #888',
|
55
|
-
Keyword: 'bold #005',
|
56
|
-
Name: '#f00',
|
57
|
-
Name.Function: '#0f0',
|
58
|
-
Name.Class: 'bold #0f0',
|
59
|
-
String: 'bg:#eee #111'
|
60
|
-
}
|
61
|
-
|
62
|
-
That's it. There are just a few rules. When you define a style for `Name`
|
63
|
-
the style automatically also affects `Name.Function` and so on. If you
|
64
|
-
defined ``'bold'`` and you don't want boldface for a subtoken use ``'nobold'``.
|
65
|
-
|
66
|
-
(Philosophy: the styles aren't written in CSS syntax since this way
|
67
|
-
they can be used for a variety of formatters.)
|
68
|
-
|
69
|
-
`default_style` is the style inherited by all token types.
|
70
|
-
|
71
|
-
To make the style usable for Pygments, you must
|
72
|
-
|
73
|
-
* either register it as a plugin (see :doc:`the plugin docs <plugins>`)
|
74
|
-
* or drop it into the `styles` subpackage of your Pygments distribution one style
|
75
|
-
class per style, where the file name is the style name and the class name is
|
76
|
-
`StylenameClass`. For example, if your style should be called
|
77
|
-
``"mondrian"``, name the class `MondrianStyle`, put it into the file
|
78
|
-
``mondrian.py`` and this file into the ``pygments.styles`` subpackage
|
79
|
-
directory.
|
80
|
-
|
81
|
-
|
82
|
-
Style Rules
|
83
|
-
===========
|
84
|
-
|
85
|
-
Here a small overview of all allowed styles:
|
86
|
-
|
87
|
-
``bold``
|
88
|
-
render text as bold
|
89
|
-
``nobold``
|
90
|
-
don't render text as bold (to prevent subtokens being highlighted bold)
|
91
|
-
``italic``
|
92
|
-
render text italic
|
93
|
-
``noitalic``
|
94
|
-
don't render text as italic
|
95
|
-
``underline``
|
96
|
-
render text underlined
|
97
|
-
``nounderline``
|
98
|
-
don't render text underlined
|
99
|
-
``bg:``
|
100
|
-
transparent background
|
101
|
-
``bg:#000000``
|
102
|
-
background color (black)
|
103
|
-
``border:``
|
104
|
-
no border
|
105
|
-
``border:#ffffff``
|
106
|
-
border color (white)
|
107
|
-
``#ff0000``
|
108
|
-
text color (red)
|
109
|
-
``noinherit``
|
110
|
-
don't inherit styles from supertoken
|
111
|
-
|
112
|
-
Note that there may not be a space between ``bg:`` and the color value
|
113
|
-
since the style definition string is split at whitespace.
|
114
|
-
Also, using named colors is not allowed since the supported color names
|
115
|
-
vary for different formatters.
|
116
|
-
|
117
|
-
Furthermore, not all lexers might support every style.
|
118
|
-
|
119
|
-
|
120
|
-
Builtin Styles
|
121
|
-
==============
|
122
|
-
|
123
|
-
Pygments ships some builtin styles which are maintained by the Pygments team.
|
124
|
-
|
125
|
-
To get a list of known styles you can use this snippet:
|
126
|
-
|
127
|
-
.. sourcecode:: pycon
|
128
|
-
|
129
|
-
>>> from pygments.styles import STYLE_MAP
|
130
|
-
>>> STYLE_MAP.keys()
|
131
|
-
['default', 'emacs', 'friendly', 'colorful']
|
132
|
-
|
133
|
-
|
134
|
-
Getting a list of available styles
|
135
|
-
==================================
|
136
|
-
|
137
|
-
.. versionadded:: 0.6
|
138
|
-
|
139
|
-
Because it could be that a plugin registered a style, there is
|
140
|
-
a way to iterate over all styles:
|
141
|
-
|
142
|
-
.. sourcecode:: pycon
|
143
|
-
|
144
|
-
>>> from pygments.styles import get_all_styles
|
145
|
-
>>> styles = list(get_all_styles())
|
146
|
-
|
147
|
-
|
148
|
-
.. _AnsiTerminalStyle:
|
149
|
-
|
150
|
-
Terminal Styles
|
151
|
-
===============
|
152
|
-
|
153
|
-
.. versionadded:: 2.2
|
154
|
-
|
155
|
-
Custom styles used with the 256-color terminal formatter can also map colors to
|
156
|
-
use the 8 default ANSI colors. To do so, use ``#ansigreen``, ``#ansired`` or
|
157
|
-
any other colors defined in :attr:`pygments.style.ansicolors`. Foreground ANSI
|
158
|
-
colors will be mapped to the corresponding `escape codes 30 to 37
|
159
|
-
<https://en.wikipedia.org/wiki/ANSI_escape_code#Colors>`_ thus respecting any
|
160
|
-
custom color mapping and themes provided by many terminal emulators. Light
|
161
|
-
variants are treated as foreground color with and an added bold flag.
|
162
|
-
``bg:#ansi<color>`` will also be respected, except the light variant will be the
|
163
|
-
same shade as their dark variant.
|
164
|
-
|
165
|
-
See the following example where the color of the string ``"hello world"`` is
|
166
|
-
governed by the escape sequence ``\x1b[34;01m`` (Ansi Blue, Bold, 41 being red
|
167
|
-
background) instead of an extended foreground & background color.
|
168
|
-
|
169
|
-
.. sourcecode:: pycon
|
170
|
-
|
171
|
-
>>> from pygments import highlight
|
172
|
-
>>> from pygments.style import Style
|
173
|
-
>>> from pygments.token import Token
|
174
|
-
>>> from pygments.lexers import Python3Lexer
|
175
|
-
>>> from pygments.formatters import Terminal256Formatter
|
176
|
-
|
177
|
-
>>> class MyStyle(Style):
|
178
|
-
styles = {
|
179
|
-
Token.String: '#ansiblue bg:#ansired',
|
180
|
-
}
|
181
|
-
|
182
|
-
>>> code = 'print("Hello World")'
|
183
|
-
>>> result = highlight(code, Python3Lexer(), Terminal256Formatter(style=MyStyle))
|
184
|
-
>>> print(result.encode())
|
185
|
-
b'\x1b[34;41;01m"\x1b[39;49;00m\x1b[34;41;01mHello World\x1b[39;49;00m\x1b[34;41;01m"\x1b[39;49;00m'
|
186
|
-
|
187
|
-
Colors specified using ``#ansi*`` are converted to a default set of RGB colors
|
188
|
-
when used with formatters other than the terminal-256 formatter.
|
189
|
-
|
190
|
-
By definition of ANSI, the following colors are considered "light" colors, and
|
191
|
-
will be rendered by most terminals as bold:
|
192
|
-
|
193
|
-
- "darkgray", "red", "green", "yellow", "blue", "fuchsia", "turquoise", "white"
|
194
|
-
|
195
|
-
The following are considered "dark" colors and will be rendered as non-bold:
|
196
|
-
|
197
|
-
- "black", "darkred", "darkgreen", "brown", "darkblue", "purple", "teal",
|
198
|
-
"lightgray"
|
199
|
-
|
200
|
-
Exact behavior might depends on the terminal emulator you are using, and its
|
201
|
-
settings.
|