pygments.rb 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +7 -0
- data/CHANGELOG.adoc +4 -0
- data/README.adoc +1 -1
- data/bench.rb +1 -1
- data/lib/pygments/popen.rb +3 -7
- data/lib/pygments/version.rb +1 -1
- data/pygments.rb.gemspec +2 -2
- data/test/test_pygments.rb +0 -19
- data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/AUTHORS +21 -1
- data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/LICENSE +1 -1
- data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/METADATA +19 -11
- data/vendor/pygments-main/Pygments-2.15.1.dist-info/RECORD +614 -0
- data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/WHEEL +1 -1
- data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/entry_points.txt +0 -1
- data/vendor/pygments-main/bin/pygmentize +1 -1
- data/vendor/pygments-main/pygments/__init__.py +20 -22
- data/vendor/pygments-main/pygments/__main__.py +1 -1
- data/vendor/pygments-main/pygments/cmdline.py +74 -8
- data/vendor/pygments-main/pygments/console.py +1 -1
- data/vendor/pygments-main/pygments/filter.py +1 -1
- data/vendor/pygments-main/pygments/filters/__init__.py +6 -3
- data/vendor/pygments-main/pygments/formatter.py +41 -11
- data/vendor/pygments-main/pygments/formatters/__init__.py +21 -16
- data/vendor/pygments-main/pygments/formatters/_mapping.py +5 -65
- data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
- data/vendor/pygments-main/pygments/formatters/groff.py +170 -0
- data/vendor/pygments-main/pygments/formatters/html.py +54 -32
- data/vendor/pygments-main/pygments/formatters/img.py +9 -5
- data/vendor/pygments-main/pygments/formatters/irc.py +6 -33
- data/vendor/pygments-main/pygments/formatters/latex.py +24 -14
- data/vendor/pygments-main/pygments/formatters/other.py +1 -1
- data/vendor/pygments-main/pygments/formatters/pangomarkup.py +1 -1
- data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
- data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
- data/vendor/pygments-main/pygments/formatters/terminal.py +1 -3
- data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -4
- data/vendor/pygments-main/pygments/lexer.py +101 -32
- data/vendor/pygments-main/pygments/lexers/__init__.py +50 -29
- data/vendor/pygments-main/pygments/lexers/_ada_builtins.py +103 -0
- data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +2 -2
- data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +21 -6
- data/vendor/pygments-main/pygments/lexers/_css_builtins.py +558 -0
- data/vendor/pygments-main/pygments/lexers/_julia_builtins.py +10 -0
- data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_lilypond_builtins.py +4932 -0
- data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +11 -18
- data/vendor/pygments-main/pygments/lexers/_mapping.py +71 -82
- data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +58 -4
- data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_php_builtins.py +408 -1835
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +70 -8
- data/vendor/pygments-main/pygments/lexers/_qlik_builtins.py +666 -0
- data/vendor/pygments-main/pygments/lexers/_scheme_builtins.py +1609 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3 -3
- data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +9 -18
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +185 -94
- data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1 -1
- data/vendor/pygments-main/pygments/lexers/actionscript.py +15 -14
- data/vendor/pygments-main/pygments/lexers/ada.py +144 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +1 -1
- data/vendor/pygments-main/pygments/lexers/algebra.py +72 -9
- data/vendor/pygments-main/pygments/lexers/ambient.py +8 -7
- data/vendor/pygments-main/pygments/lexers/amdgpu.py +4 -3
- data/vendor/pygments-main/pygments/lexers/ampl.py +10 -8
- data/vendor/pygments-main/pygments/lexers/apdlexer.py +164 -20
- data/vendor/pygments-main/pygments/lexers/apl.py +6 -5
- data/vendor/pygments-main/pygments/lexers/archetype.py +23 -21
- data/vendor/pygments-main/pygments/lexers/arrow.py +10 -9
- data/vendor/pygments-main/pygments/lexers/arturo.py +250 -0
- data/vendor/pygments-main/pygments/lexers/asc.py +9 -5
- data/vendor/pygments-main/pygments/lexers/asm.py +68 -63
- data/vendor/pygments-main/pygments/lexers/automation.py +7 -5
- data/vendor/pygments-main/pygments/lexers/bare.py +20 -21
- data/vendor/pygments-main/pygments/lexers/basic.py +45 -41
- data/vendor/pygments-main/pygments/lexers/bdd.py +58 -0
- data/vendor/pygments-main/pygments/lexers/berry.py +99 -0
- data/vendor/pygments-main/pygments/lexers/bibtex.py +6 -6
- data/vendor/pygments-main/pygments/lexers/boa.py +4 -8
- data/vendor/pygments-main/pygments/lexers/business.py +18 -18
- data/vendor/pygments-main/pygments/lexers/c_cpp.py +80 -40
- data/vendor/pygments-main/pygments/lexers/c_like.py +21 -19
- data/vendor/pygments-main/pygments/lexers/capnproto.py +6 -8
- data/vendor/pygments-main/pygments/lexers/carbon.py +96 -0
- data/vendor/pygments-main/pygments/lexers/cddl.py +16 -33
- data/vendor/pygments-main/pygments/lexers/chapel.py +14 -9
- data/vendor/pygments-main/pygments/lexers/clean.py +3 -2
- data/vendor/pygments-main/pygments/lexers/comal.py +80 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +3 -2
- data/vendor/pygments-main/pygments/lexers/configs.py +235 -120
- data/vendor/pygments-main/pygments/lexers/console.py +5 -4
- data/vendor/pygments-main/pygments/lexers/cplint.py +44 -0
- data/vendor/pygments-main/pygments/lexers/crystal.py +22 -23
- data/vendor/pygments-main/pygments/lexers/csound.py +19 -17
- data/vendor/pygments-main/pygments/lexers/css.py +67 -159
- data/vendor/pygments-main/pygments/lexers/d.py +15 -12
- data/vendor/pygments-main/pygments/lexers/dalvik.py +14 -11
- data/vendor/pygments-main/pygments/lexers/data.py +119 -49
- data/vendor/pygments-main/pygments/lexers/dax.py +136 -0
- data/vendor/pygments-main/pygments/lexers/devicetree.py +9 -8
- data/vendor/pygments-main/pygments/lexers/diff.py +23 -19
- data/vendor/pygments-main/pygments/lexers/dotnet.py +216 -81
- data/vendor/pygments-main/pygments/lexers/dsls.py +86 -64
- data/vendor/pygments-main/pygments/lexers/dylan.py +16 -15
- data/vendor/pygments-main/pygments/lexers/ecl.py +46 -38
- data/vendor/pygments-main/pygments/lexers/eiffel.py +15 -10
- data/vendor/pygments-main/pygments/lexers/elm.py +12 -8
- data/vendor/pygments-main/pygments/lexers/elpi.py +165 -0
- data/vendor/pygments-main/pygments/lexers/email.py +21 -39
- data/vendor/pygments-main/pygments/lexers/erlang.py +21 -22
- data/vendor/pygments-main/pygments/lexers/esoteric.py +28 -30
- data/vendor/pygments-main/pygments/lexers/ezhil.py +10 -9
- data/vendor/pygments-main/pygments/lexers/factor.py +104 -83
- data/vendor/pygments-main/pygments/lexers/fantom.py +31 -29
- data/vendor/pygments-main/pygments/lexers/felix.py +18 -14
- data/vendor/pygments-main/pygments/lexers/fift.py +67 -0
- data/vendor/pygments-main/pygments/lexers/floscript.py +7 -7
- data/vendor/pygments-main/pygments/lexers/forth.py +8 -6
- data/vendor/pygments-main/pygments/lexers/fortran.py +16 -11
- data/vendor/pygments-main/pygments/lexers/foxpro.py +2 -2
- data/vendor/pygments-main/pygments/lexers/freefem.py +7 -10
- data/vendor/pygments-main/pygments/lexers/func.py +108 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1 -1
- data/vendor/pygments-main/pygments/lexers/futhark.py +12 -17
- data/vendor/pygments-main/pygments/lexers/gcodelexer.py +1 -2
- data/vendor/pygments-main/pygments/lexers/gdscript.py +76 -233
- data/vendor/pygments-main/pygments/lexers/go.py +12 -14
- data/vendor/pygments-main/pygments/lexers/grammar_notation.py +22 -26
- data/vendor/pygments-main/pygments/lexers/graph.py +36 -15
- data/vendor/pygments-main/pygments/lexers/graphics.py +37 -38
- data/vendor/pygments-main/pygments/lexers/graphviz.py +2 -1
- data/vendor/pygments-main/pygments/lexers/gsql.py +39 -27
- data/vendor/pygments-main/pygments/lexers/haskell.py +73 -71
- data/vendor/pygments-main/pygments/lexers/haxe.py +13 -11
- data/vendor/pygments-main/pygments/lexers/hdl.py +31 -34
- data/vendor/pygments-main/pygments/lexers/hexdump.py +21 -21
- data/vendor/pygments-main/pygments/lexers/html.py +11 -19
- data/vendor/pygments-main/pygments/lexers/idl.py +10 -5
- data/vendor/pygments-main/pygments/lexers/igor.py +3 -2
- data/vendor/pygments-main/pygments/lexers/inferno.py +9 -8
- data/vendor/pygments-main/pygments/lexers/installers.py +39 -33
- data/vendor/pygments-main/pygments/lexers/int_fiction.py +35 -20
- data/vendor/pygments-main/pygments/lexers/iolang.py +9 -9
- data/vendor/pygments-main/pygments/lexers/j.py +20 -13
- data/vendor/pygments-main/pygments/lexers/javascript.py +183 -149
- data/vendor/pygments-main/pygments/lexers/jmespath.py +68 -0
- data/vendor/pygments-main/pygments/lexers/jslt.py +4 -3
- data/vendor/pygments-main/pygments/lexers/jsonnet.py +168 -0
- data/vendor/pygments-main/pygments/lexers/julia.py +44 -32
- data/vendor/pygments-main/pygments/lexers/jvm.py +161 -140
- data/vendor/pygments-main/pygments/lexers/kuin.py +93 -59
- data/vendor/pygments-main/pygments/lexers/lilypond.py +226 -0
- data/vendor/pygments-main/pygments/lexers/lisp.py +244 -107
- data/vendor/pygments-main/pygments/lexers/macaulay2.py +1739 -0
- data/vendor/pygments-main/pygments/lexers/make.py +21 -16
- data/vendor/pygments-main/pygments/lexers/markup.py +752 -11
- data/vendor/pygments-main/pygments/lexers/math.py +1 -1
- data/vendor/pygments-main/pygments/lexers/matlab.py +18 -3
- data/vendor/pygments-main/pygments/lexers/maxima.py +85 -0
- data/vendor/pygments-main/pygments/lexers/meson.py +10 -25
- data/vendor/pygments-main/pygments/lexers/mime.py +2 -2
- data/vendor/pygments-main/pygments/lexers/minecraft.py +394 -0
- data/vendor/pygments-main/pygments/lexers/mips.py +128 -0
- data/vendor/pygments-main/pygments/lexers/ml.py +9 -6
- data/vendor/pygments-main/pygments/lexers/modeling.py +12 -8
- data/vendor/pygments-main/pygments/lexers/modula2.py +3 -2
- data/vendor/pygments-main/pygments/lexers/monte.py +3 -2
- data/vendor/pygments-main/pygments/lexers/mosel.py +1 -1
- data/vendor/pygments-main/pygments/lexers/ncl.py +1 -1
- data/vendor/pygments-main/pygments/lexers/nimrod.py +62 -20
- data/vendor/pygments-main/pygments/lexers/nit.py +3 -2
- data/vendor/pygments-main/pygments/lexers/nix.py +5 -5
- data/vendor/pygments-main/pygments/lexers/oberon.py +2 -2
- data/vendor/pygments-main/pygments/lexers/objective.py +6 -4
- data/vendor/pygments-main/pygments/lexers/ooc.py +3 -2
- data/vendor/pygments-main/pygments/lexers/other.py +1 -1
- data/vendor/pygments-main/pygments/lexers/parasail.py +3 -2
- data/vendor/pygments-main/pygments/lexers/parsers.py +23 -21
- data/vendor/pygments-main/pygments/lexers/pascal.py +196 -198
- data/vendor/pygments-main/pygments/lexers/pawn.py +1 -1
- data/vendor/pygments-main/pygments/lexers/perl.py +17 -15
- data/vendor/pygments-main/pygments/lexers/phix.py +364 -0
- data/vendor/pygments-main/pygments/lexers/php.py +35 -20
- data/vendor/pygments-main/pygments/lexers/pointless.py +3 -2
- data/vendor/pygments-main/pygments/lexers/pony.py +1 -1
- data/vendor/pygments-main/pygments/lexers/praat.py +41 -38
- data/vendor/pygments-main/pygments/lexers/procfile.py +2 -3
- data/vendor/pygments-main/pygments/lexers/prolog.py +7 -8
- data/vendor/pygments-main/pygments/lexers/promql.py +5 -12
- data/vendor/pygments-main/pygments/lexers/python.py +145 -119
- data/vendor/pygments-main/pygments/lexers/q.py +188 -0
- data/vendor/pygments-main/pygments/lexers/qlik.py +117 -0
- data/vendor/pygments-main/pygments/lexers/qvt.py +1 -1
- data/vendor/pygments-main/pygments/lexers/r.py +4 -4
- data/vendor/pygments-main/pygments/lexers/rdf.py +3 -3
- data/vendor/pygments-main/pygments/lexers/rebol.py +1 -12
- data/vendor/pygments-main/pygments/lexers/resource.py +1 -1
- data/vendor/pygments-main/pygments/lexers/ride.py +3 -2
- data/vendor/pygments-main/pygments/lexers/rita.py +43 -0
- data/vendor/pygments-main/pygments/lexers/rnc.py +3 -2
- data/vendor/pygments-main/pygments/lexers/roboconf.py +3 -3
- data/vendor/pygments-main/pygments/lexers/robotframework.py +6 -5
- data/vendor/pygments-main/pygments/lexers/ruby.py +24 -24
- data/vendor/pygments-main/pygments/lexers/rust.py +3 -2
- data/vendor/pygments-main/pygments/lexers/sas.py +2 -2
- data/vendor/pygments-main/pygments/lexers/savi.py +170 -0
- data/vendor/pygments-main/pygments/lexers/scdoc.py +4 -7
- data/vendor/pygments-main/pygments/lexers/scripting.py +24 -21
- data/vendor/pygments-main/pygments/lexers/sgf.py +6 -6
- data/vendor/pygments-main/pygments/lexers/shell.py +29 -21
- data/vendor/pygments-main/pygments/lexers/sieve.py +14 -4
- data/vendor/pygments-main/pygments/lexers/slash.py +1 -1
- data/vendor/pygments-main/pygments/lexers/smalltalk.py +5 -3
- data/vendor/pygments-main/pygments/lexers/smithy.py +5 -6
- data/vendor/pygments-main/pygments/lexers/smv.py +1 -1
- data/vendor/pygments-main/pygments/lexers/snobol.py +1 -1
- data/vendor/pygments-main/pygments/lexers/solidity.py +3 -7
- data/vendor/pygments-main/pygments/lexers/sophia.py +103 -0
- data/vendor/pygments-main/pygments/lexers/special.py +2 -5
- data/vendor/pygments-main/pygments/lexers/spice.py +71 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +212 -17
- data/vendor/pygments-main/pygments/lexers/srcinfo.py +62 -0
- data/vendor/pygments-main/pygments/lexers/stata.py +4 -3
- data/vendor/pygments-main/pygments/lexers/supercollider.py +4 -3
- data/vendor/pygments-main/pygments/lexers/tal.py +74 -0
- data/vendor/pygments-main/pygments/lexers/tcl.py +21 -16
- data/vendor/pygments-main/pygments/lexers/teal.py +9 -8
- data/vendor/pygments-main/pygments/lexers/templates.py +62 -29
- data/vendor/pygments-main/pygments/lexers/teraterm.py +12 -20
- data/vendor/pygments-main/pygments/lexers/testing.py +6 -2
- data/vendor/pygments-main/pygments/lexers/text.py +3 -2
- data/vendor/pygments-main/pygments/lexers/textedit.py +41 -7
- data/vendor/pygments-main/pygments/lexers/textfmts.py +7 -5
- data/vendor/pygments-main/pygments/lexers/theorem.py +42 -36
- data/vendor/pygments-main/pygments/lexers/thingsdb.py +2 -4
- data/vendor/pygments-main/pygments/lexers/tlb.py +57 -0
- data/vendor/pygments-main/pygments/lexers/tnt.py +3 -4
- data/vendor/pygments-main/pygments/lexers/trafficscript.py +2 -4
- data/vendor/pygments-main/pygments/lexers/typoscript.py +2 -3
- data/vendor/pygments-main/pygments/lexers/ul4.py +267 -0
- data/vendor/pygments-main/pygments/lexers/unicon.py +1 -1
- data/vendor/pygments-main/pygments/lexers/urbi.py +4 -4
- data/vendor/pygments-main/pygments/lexers/usd.py +2 -1
- data/vendor/pygments-main/pygments/lexers/varnish.py +5 -5
- data/vendor/pygments-main/pygments/lexers/verification.py +4 -3
- data/vendor/pygments-main/pygments/lexers/web.py +1 -1
- data/vendor/pygments-main/pygments/lexers/webassembly.py +5 -5
- data/vendor/pygments-main/pygments/lexers/webidl.py +2 -1
- data/vendor/pygments-main/pygments/lexers/webmisc.py +90 -71
- data/vendor/pygments-main/pygments/lexers/wgsl.py +407 -0
- data/vendor/pygments-main/pygments/lexers/whiley.py +2 -1
- data/vendor/pygments-main/pygments/lexers/wowtoc.py +120 -0
- data/vendor/pygments-main/pygments/lexers/wren.py +99 -0
- data/vendor/pygments-main/pygments/lexers/x10.py +5 -6
- data/vendor/pygments-main/pygments/lexers/xorg.py +3 -2
- data/vendor/pygments-main/pygments/lexers/yang.py +6 -5
- data/vendor/pygments-main/pygments/lexers/zig.py +3 -2
- data/vendor/pygments-main/pygments/modeline.py +1 -1
- data/vendor/pygments-main/pygments/plugin.py +28 -9
- 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 +63 -1
- data/vendor/pygments-main/pygments/style.py +7 -1
- data/vendor/pygments-main/pygments/styles/__init__.py +19 -5
- data/vendor/pygments-main/pygments/styles/abap.py +2 -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 -3
- data/vendor/pygments-main/pygments/styles/borland.py +1 -3
- data/vendor/pygments-main/pygments/styles/bw.py +1 -2
- data/vendor/pygments-main/pygments/styles/colorful.py +1 -3
- data/vendor/pygments-main/pygments/styles/default.py +13 -14
- data/vendor/pygments-main/pygments/styles/dracula.py +102 -0
- 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/friendly_grayscale.py +75 -0
- data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
- data/vendor/pygments-main/pygments/styles/gh_dark.py +107 -0
- data/vendor/pygments-main/pygments/styles/gruvbox.py +4 -2
- data/vendor/pygments-main/pygments/styles/igor.py +1 -2
- data/vendor/pygments-main/pygments/styles/inkpot.py +3 -2
- data/vendor/pygments-main/pygments/styles/lilypond.py +56 -0
- data/vendor/pygments-main/pygments/styles/lovelace.py +1 -3
- data/vendor/pygments-main/pygments/styles/manni.py +1 -1
- data/vendor/pygments-main/pygments/styles/material.py +1 -2
- data/vendor/pygments-main/pygments/styles/monokai.py +3 -3
- data/vendor/pygments-main/pygments/styles/murphy.py +1 -3
- data/vendor/pygments-main/pygments/styles/native.py +11 -11
- data/vendor/pygments-main/pygments/styles/nord.py +150 -0
- data/vendor/pygments-main/pygments/styles/onedark.py +59 -0
- data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -6
- data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -6
- data/vendor/pygments-main/pygments/styles/pastie.py +1 -3
- data/vendor/pygments-main/pygments/styles/perldoc.py +1 -2
- data/vendor/pygments-main/pygments/styles/rainbow_dash.py +3 -3
- data/vendor/pygments-main/pygments/styles/rrt.py +3 -2
- data/vendor/pygments-main/pygments/styles/sas.py +2 -4
- data/vendor/pygments-main/pygments/styles/solarized.py +1 -1
- data/vendor/pygments-main/pygments/styles/staroffice.py +26 -0
- data/vendor/pygments-main/pygments/styles/stata_dark.py +4 -6
- data/vendor/pygments-main/pygments/styles/stata_light.py +1 -2
- data/vendor/pygments-main/pygments/styles/tango.py +2 -3
- data/vendor/pygments-main/pygments/styles/trac.py +1 -3
- 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 -3
- data/vendor/pygments-main/pygments/styles/zenburn.py +4 -6
- data/vendor/pygments-main/pygments/token.py +2 -1
- data/vendor/pygments-main/pygments/unistring.py +4 -6
- data/vendor/pygments-main/pygments/util.py +27 -5
- metadata +59 -14
- data/vendor/pygments-main/Pygments-2.10.0.dist-info/RECORD +0 -524
- /data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/INSTALLER +0 -0
- /data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/REQUESTED +0 -0
- /data/vendor/pygments-main/{Pygments-2.10.0.dist-info → Pygments-2.15.1.dist-info}/top_level.txt +0 -0
@@ -21,13 +21,12 @@
|
|
21
21
|
.. _Pygments master branch:
|
22
22
|
https://github.com/pygments/pygments/archive/master.zip#egg=Pygments-dev
|
23
23
|
|
24
|
-
:copyright: Copyright 2006-
|
24
|
+
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
25
25
|
:license: BSD, see LICENSE for details.
|
26
26
|
"""
|
27
|
-
import sys
|
28
27
|
from io import StringIO, BytesIO
|
29
28
|
|
30
|
-
__version__ = '2.
|
29
|
+
__version__ = '2.15.1'
|
31
30
|
__docformat__ = 'restructuredtext'
|
32
31
|
|
33
32
|
__all__ = ['lex', 'format', 'highlight']
|
@@ -35,14 +34,16 @@ __all__ = ['lex', 'format', 'highlight']
|
|
35
34
|
|
36
35
|
def lex(code, lexer):
|
37
36
|
"""
|
38
|
-
Lex
|
37
|
+
Lex `code` with the `lexer` (must be a `Lexer` instance)
|
38
|
+
and return an iterable of tokens. Currently, this only calls
|
39
|
+
`lexer.get_tokens()`.
|
39
40
|
"""
|
40
41
|
try:
|
41
42
|
return lexer.get_tokens(code)
|
42
|
-
except TypeError
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
except TypeError:
|
44
|
+
# Heuristic to catch a common mistake.
|
45
|
+
from pygments.lexer import RegexLexer
|
46
|
+
if isinstance(lexer, type) and issubclass(lexer, RegexLexer):
|
46
47
|
raise TypeError('lex() argument must be a lexer instance, '
|
47
48
|
'not a class')
|
48
49
|
raise
|
@@ -50,11 +51,12 @@ def lex(code, lexer):
|
|
50
51
|
|
51
52
|
def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builtin
|
52
53
|
"""
|
53
|
-
Format
|
54
|
+
Format ``tokens`` (an iterable of tokens) with the formatter ``formatter``
|
55
|
+
(a `Formatter` instance).
|
54
56
|
|
55
|
-
If ``outfile`` is given and a valid file object (an object
|
56
|
-
|
57
|
-
|
57
|
+
If ``outfile`` is given and a valid file object (an object with a
|
58
|
+
``write`` method), the result will be written to it, otherwise it
|
59
|
+
is returned as a string.
|
58
60
|
"""
|
59
61
|
try:
|
60
62
|
if not outfile:
|
@@ -63,10 +65,10 @@ def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builti
|
|
63
65
|
return realoutfile.getvalue()
|
64
66
|
else:
|
65
67
|
formatter.format(tokens, outfile)
|
66
|
-
except TypeError
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
except TypeError:
|
69
|
+
# Heuristic to catch a common mistake.
|
70
|
+
from pygments.formatter import Formatter
|
71
|
+
if isinstance(formatter, type) and issubclass(formatter, Formatter):
|
70
72
|
raise TypeError('format() argument must be a formatter instance, '
|
71
73
|
'not a class')
|
72
74
|
raise
|
@@ -74,11 +76,7 @@ def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builti
|
|
74
76
|
|
75
77
|
def highlight(code, lexer, formatter, outfile=None):
|
76
78
|
"""
|
77
|
-
|
78
|
-
|
79
|
-
If ``outfile`` is given and a valid file object (an object
|
80
|
-
with a ``write`` method), the result will be written to it, otherwise
|
81
|
-
it is returned as a string.
|
79
|
+
This is the most high-level highlighting function. It combines `lex` and
|
80
|
+
`format` in one function.
|
82
81
|
"""
|
83
82
|
return format(lex(code, lexer), formatter, outfile)
|
84
|
-
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Command line interface.
|
6
6
|
|
7
|
-
:copyright: Copyright 2006-
|
7
|
+
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
8
8
|
:license: BSD, see LICENSE for details.
|
9
9
|
"""
|
10
10
|
|
@@ -25,7 +25,7 @@ from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
|
|
25
25
|
from pygments.formatters import get_all_formatters, get_formatter_by_name, \
|
26
26
|
load_formatter_from_file, get_formatter_for_filename, find_formatter_class
|
27
27
|
from pygments.formatters.terminal import TerminalFormatter
|
28
|
-
from pygments.formatters.terminal256 import Terminal256Formatter
|
28
|
+
from pygments.formatters.terminal256 import Terminal256Formatter, TerminalTrueColorFormatter
|
29
29
|
from pygments.filters import get_all_filters, find_filter_class
|
30
30
|
from pygments.styles import get_all_styles, get_style_by_name
|
31
31
|
|
@@ -135,13 +135,57 @@ def _print_list(what):
|
|
135
135
|
print(" %s" % docstring_headline(cls))
|
136
136
|
|
137
137
|
|
138
|
+
def _print_list_as_json(requested_items):
|
139
|
+
import json
|
140
|
+
result = {}
|
141
|
+
if 'lexer' in requested_items:
|
142
|
+
info = {}
|
143
|
+
for fullname, names, filenames, mimetypes in get_all_lexers():
|
144
|
+
info[fullname] = {
|
145
|
+
'aliases': names,
|
146
|
+
'filenames': filenames,
|
147
|
+
'mimetypes': mimetypes
|
148
|
+
}
|
149
|
+
result['lexers'] = info
|
150
|
+
|
151
|
+
if 'formatter' in requested_items:
|
152
|
+
info = {}
|
153
|
+
for cls in get_all_formatters():
|
154
|
+
doc = docstring_headline(cls)
|
155
|
+
info[cls.name] = {
|
156
|
+
'aliases': cls.aliases,
|
157
|
+
'filenames': cls.filenames,
|
158
|
+
'doc': doc
|
159
|
+
}
|
160
|
+
result['formatters'] = info
|
161
|
+
|
162
|
+
if 'filter' in requested_items:
|
163
|
+
info = {}
|
164
|
+
for name in get_all_filters():
|
165
|
+
cls = find_filter_class(name)
|
166
|
+
info[name] = {
|
167
|
+
'doc': docstring_headline(cls)
|
168
|
+
}
|
169
|
+
result['filters'] = info
|
170
|
+
|
171
|
+
if 'style' in requested_items:
|
172
|
+
info = {}
|
173
|
+
for name in get_all_styles():
|
174
|
+
cls = get_style_by_name(name)
|
175
|
+
info[name] = {
|
176
|
+
'doc': docstring_headline(cls)
|
177
|
+
}
|
178
|
+
result['styles'] = info
|
179
|
+
|
180
|
+
json.dump(result, sys.stdout)
|
181
|
+
|
138
182
|
def main_inner(parser, argns):
|
139
183
|
if argns.help:
|
140
184
|
parser.print_help()
|
141
185
|
return 0
|
142
186
|
|
143
187
|
if argns.V:
|
144
|
-
print('Pygments version %s, (c) 2006-
|
188
|
+
print('Pygments version %s, (c) 2006-2023 by Georg Brandl, Matthäus '
|
145
189
|
'Chajdas and contributors.' % __version__)
|
146
190
|
return 0
|
147
191
|
|
@@ -150,11 +194,21 @@ def main_inner(parser, argns):
|
|
150
194
|
|
151
195
|
# handle ``pygmentize -L``
|
152
196
|
if argns.L is not None:
|
153
|
-
|
197
|
+
arg_set = set()
|
198
|
+
for k, v in vars(argns).items():
|
199
|
+
if v:
|
200
|
+
arg_set.add(k)
|
201
|
+
|
202
|
+
arg_set.discard('L')
|
203
|
+
arg_set.discard('json')
|
204
|
+
|
205
|
+
if arg_set:
|
154
206
|
parser.print_help(sys.stderr)
|
155
207
|
return 2
|
208
|
+
|
156
209
|
# print version
|
157
|
-
|
210
|
+
if not argns.json:
|
211
|
+
main(['', '-V'])
|
158
212
|
allowed_types = {'lexer', 'formatter', 'filter', 'style'}
|
159
213
|
largs = [arg.rstrip('s') for arg in argns.L]
|
160
214
|
if any(arg not in allowed_types for arg in largs):
|
@@ -162,8 +216,11 @@ def main_inner(parser, argns):
|
|
162
216
|
return 0
|
163
217
|
if not largs:
|
164
218
|
largs = allowed_types
|
165
|
-
|
166
|
-
|
219
|
+
if not argns.json:
|
220
|
+
for arg in largs:
|
221
|
+
_print_list(arg)
|
222
|
+
else:
|
223
|
+
_print_list_as_json(largs)
|
167
224
|
return 0
|
168
225
|
|
169
226
|
# handle ``pygmentize -H``
|
@@ -388,7 +445,9 @@ def main_inner(parser, argns):
|
|
388
445
|
return 1
|
389
446
|
else:
|
390
447
|
if not fmter:
|
391
|
-
if
|
448
|
+
if os.environ.get('COLORTERM','') in ('truecolor', '24bit'):
|
449
|
+
fmter = TerminalTrueColorFormatter(**parsed_opts)
|
450
|
+
elif '256' in os.environ.get('TERM', ''):
|
392
451
|
fmter = Terminal256Formatter(**parsed_opts)
|
393
452
|
else:
|
394
453
|
fmter = TerminalFormatter(**parsed_opts)
|
@@ -533,6 +592,10 @@ def main(args=sys.argv):
|
|
533
592
|
'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
|
534
593
|
'Users should be very careful not to use this option with untrusted '
|
535
594
|
'files, because it will import and run them.')
|
595
|
+
flags.add_argument('--json', help='Output as JSON. This can '
|
596
|
+
'be only used in conjunction with -L.',
|
597
|
+
default=False,
|
598
|
+
action='store_true')
|
536
599
|
|
537
600
|
special_modes_group = parser.add_argument_group(
|
538
601
|
'Special modes - do not do any highlighting')
|
@@ -575,6 +638,9 @@ def main(args=sys.argv):
|
|
575
638
|
|
576
639
|
try:
|
577
640
|
return main_inner(parser, argns)
|
641
|
+
except BrokenPipeError:
|
642
|
+
# someone closed our stdout, e.g. by quitting a pager.
|
643
|
+
return 0
|
578
644
|
except Exception:
|
579
645
|
if argns.v:
|
580
646
|
print(file=sys.stderr)
|
@@ -5,7 +5,7 @@
|
|
5
5
|
Module containing filter lookup functions and default
|
6
6
|
filters.
|
7
7
|
|
8
|
-
:copyright: Copyright 2006-
|
8
|
+
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
9
9
|
:license: BSD, see LICENSE for details.
|
10
10
|
"""
|
11
11
|
|
@@ -69,13 +69,16 @@ class CodeTagFilter(Filter):
|
|
69
69
|
|
70
70
|
`codetags` : list of strings
|
71
71
|
A list of strings that are flagged as code tags. The default is to
|
72
|
-
highlight ``XXX``, ``TODO``, ``BUG`` and ``NOTE``.
|
72
|
+
highlight ``XXX``, ``TODO``, ``FIXME``, ``BUG`` and ``NOTE``.
|
73
|
+
|
74
|
+
.. versionchanged:: 2.13
|
75
|
+
Now recognizes ``FIXME`` by default.
|
73
76
|
"""
|
74
77
|
|
75
78
|
def __init__(self, **options):
|
76
79
|
Filter.__init__(self, **options)
|
77
80
|
tags = get_list_opt(options, 'codetags',
|
78
|
-
['XXX', 'TODO', 'BUG', 'NOTE'])
|
81
|
+
['XXX', 'TODO', 'FIXME', 'BUG', 'NOTE'])
|
79
82
|
self.tag_re = re.compile(r'\b(%s)\b' % '|'.join([
|
80
83
|
re.escape(tag) for tag in tags if tag
|
81
84
|
]))
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Base formatter class.
|
6
6
|
|
7
|
-
:copyright: Copyright 2006-
|
7
|
+
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
8
8
|
:license: BSD, see LICENSE for details.
|
9
9
|
"""
|
10
10
|
|
@@ -26,7 +26,21 @@ class Formatter:
|
|
26
26
|
"""
|
27
27
|
Converts a token stream to text.
|
28
28
|
|
29
|
-
|
29
|
+
Formatters should have attributes to help selecting them. These
|
30
|
+
are similar to the corresponding :class:`~pygments.lexer.Lexer`
|
31
|
+
attributes.
|
32
|
+
|
33
|
+
.. autoattribute:: name
|
34
|
+
:no-value:
|
35
|
+
|
36
|
+
.. autoattribute:: aliases
|
37
|
+
:no-value:
|
38
|
+
|
39
|
+
.. autoattribute:: filenames
|
40
|
+
:no-value:
|
41
|
+
|
42
|
+
You can pass options as keyword arguments to the constructor.
|
43
|
+
All formatters accept these basic options:
|
30
44
|
|
31
45
|
``style``
|
32
46
|
The style to use, can be a string or a Style subclass
|
@@ -47,15 +61,19 @@ class Formatter:
|
|
47
61
|
support (default: None).
|
48
62
|
``outencoding``
|
49
63
|
Overrides ``encoding`` if given.
|
64
|
+
|
50
65
|
"""
|
51
66
|
|
52
|
-
#:
|
67
|
+
#: Full name for the formatter, in human-readable form.
|
53
68
|
name = None
|
54
69
|
|
55
|
-
#:
|
70
|
+
#: A list of short, unique identifiers that can be used to lookup
|
71
|
+
#: the formatter from a list, e.g. using :func:`.get_formatter_by_name()`.
|
56
72
|
aliases = []
|
57
73
|
|
58
|
-
#:
|
74
|
+
#: A list of fnmatch patterns that match filenames for which this
|
75
|
+
#: formatter can produce output. The patterns in this list should be unique
|
76
|
+
#: among all formatters.
|
59
77
|
filenames = []
|
60
78
|
|
61
79
|
#: If True, this formatter outputs Unicode strings when no encoding
|
@@ -63,6 +81,11 @@ class Formatter:
|
|
63
81
|
unicodeoutput = True
|
64
82
|
|
65
83
|
def __init__(self, **options):
|
84
|
+
"""
|
85
|
+
As with lexers, this constructor takes arbitrary optional arguments,
|
86
|
+
and if you override it, you should first process your own options, then
|
87
|
+
call the base class implementation.
|
88
|
+
"""
|
66
89
|
self.style = _lookup_style(options.get('style', 'default'))
|
67
90
|
self.full = get_bool_opt(options, 'full', False)
|
68
91
|
self.title = options.get('title', '')
|
@@ -75,18 +98,25 @@ class Formatter:
|
|
75
98
|
|
76
99
|
def get_style_defs(self, arg=''):
|
77
100
|
"""
|
78
|
-
|
101
|
+
This method must return statements or declarations suitable to define
|
102
|
+
the current style for subsequent highlighted text (e.g. CSS classes
|
103
|
+
in the `HTMLFormatter`).
|
79
104
|
|
80
|
-
|
81
|
-
formatter
|
82
|
-
|
105
|
+
The optional argument `arg` can be used to modify the generation and
|
106
|
+
is formatter dependent (it is standardized because it can be given on
|
107
|
+
the command line).
|
108
|
+
|
109
|
+
This method is called by the ``-S`` :doc:`command-line option <cmdline>`,
|
110
|
+
the `arg` is then given by the ``-a`` option.
|
83
111
|
"""
|
84
112
|
return ''
|
85
113
|
|
86
114
|
def format(self, tokensource, outfile):
|
87
115
|
"""
|
88
|
-
|
89
|
-
|
116
|
+
This method must format the tokens from the `tokensource` iterable and
|
117
|
+
write the formatted version to the file object `outfile`.
|
118
|
+
|
119
|
+
Formatter options can control how exactly the tokens are converted.
|
90
120
|
"""
|
91
121
|
if self.encoding:
|
92
122
|
# wrap the outfile in a StreamWriter
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
Pygments formatters.
|
6
6
|
|
7
|
-
:copyright: Copyright 2006-
|
7
|
+
:copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
|
8
8
|
:license: BSD, see LICENSE for details.
|
9
9
|
"""
|
10
10
|
|
@@ -68,9 +68,12 @@ def find_formatter_class(alias):
|
|
68
68
|
|
69
69
|
|
70
70
|
def get_formatter_by_name(_alias, **options):
|
71
|
-
"""
|
71
|
+
"""
|
72
|
+
Return an instance of a :class:`.Formatter` subclass that has `alias` in its
|
73
|
+
aliases list. The formatter is given the `options` at its instantiation.
|
72
74
|
|
73
|
-
|
75
|
+
Will raise :exc:`pygments.util.ClassNotFound` if no formatter with that
|
76
|
+
alias is found.
|
74
77
|
"""
|
75
78
|
cls = find_formatter_class(_alias)
|
76
79
|
if cls is None:
|
@@ -78,19 +81,18 @@ def get_formatter_by_name(_alias, **options):
|
|
78
81
|
return cls(**options)
|
79
82
|
|
80
83
|
|
81
|
-
def load_formatter_from_file(filename, formattername="CustomFormatter",
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
This method expects a file located relative to the current working
|
86
|
-
directory, which contains a class named CustomFormatter. By default,
|
87
|
-
it expects the Formatter to be named CustomFormatter; you can specify
|
88
|
-
your own class name as the second argument to this function.
|
84
|
+
def load_formatter_from_file(filename, formattername="CustomFormatter", **options):
|
85
|
+
"""
|
86
|
+
Return a `Formatter` subclass instance loaded from the provided file, relative
|
87
|
+
to the current directory.
|
89
88
|
|
90
|
-
|
91
|
-
|
89
|
+
The file is expected to contain a Formatter class named ``formattername``
|
90
|
+
(by default, CustomFormatter). Users should be very careful with the input, because
|
91
|
+
this method is equivalent to running ``eval()`` on the input file. The formatter is
|
92
|
+
given the `options` at its instantiation.
|
92
93
|
|
93
|
-
|
94
|
+
:exc:`pygments.util.ClassNotFound` is raised if there are any errors loading
|
95
|
+
the formatter.
|
94
96
|
|
95
97
|
.. versionadded:: 2.2
|
96
98
|
"""
|
@@ -115,9 +117,12 @@ def load_formatter_from_file(filename, formattername="CustomFormatter",
|
|
115
117
|
|
116
118
|
|
117
119
|
def get_formatter_for_filename(fn, **options):
|
118
|
-
"""
|
120
|
+
"""
|
121
|
+
Return a :class:`.Formatter` subclass instance that has a filename pattern
|
122
|
+
matching `fn`. The formatter is given the `options` at its instantiation.
|
119
123
|
|
120
|
-
|
124
|
+
Will raise :exc:`pygments.util.ClassNotFound` if no formatter for that filename
|
125
|
+
is found.
|
121
126
|
"""
|
122
127
|
fn = basename(fn)
|
123
128
|
for modname, name, _, filenames, _ in FORMATTERS.values():
|
@@ -1,22 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
4
|
-
|
5
|
-
Formatter mapping definitions. This file is generated by itself. Everytime
|
6
|
-
you change something on a builtin formatter definition, run this script from
|
7
|
-
the formatters folder to update it.
|
8
|
-
|
9
|
-
Do not alter the FORMATTERS dictionary by hand.
|
10
|
-
|
11
|
-
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
|
12
|
-
:license: BSD, see LICENSE for details.
|
13
|
-
"""
|
1
|
+
# Automatically generated by scripts/gen_mapfiles.py.
|
2
|
+
# DO NOT EDIT BY HAND; run `tox -e mapfiles` instead.
|
14
3
|
|
15
4
|
FORMATTERS = {
|
16
5
|
'BBCodeFormatter': ('pygments.formatters.bbcode', 'BBCode', ('bbcode', 'bb'), (), 'Format tokens with BBcodes. These formatting codes are used by many bulletin boards, so you can highlight your sourcecode with pygments before posting it there.'),
|
17
6
|
'BmpImageFormatter': ('pygments.formatters.img', 'img_bmp', ('bmp', 'bitmap'), ('*.bmp',), 'Create a bitmap image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
|
18
7
|
'GifImageFormatter': ('pygments.formatters.img', 'img_gif', ('gif',), ('*.gif',), 'Create a GIF image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
|
19
|
-
'
|
8
|
+
'GroffFormatter': ('pygments.formatters.groff', 'groff', ('groff', 'troff', 'roff'), (), 'Format tokens with groff escapes to change their color and font style.'),
|
9
|
+
'HtmlFormatter': ('pygments.formatters.html', 'HTML', ('html',), ('*.html', '*.htm'), "Format tokens as HTML 4 ``<span>`` tags. By default, the content is enclosed in a ``<pre>`` tag, itself wrapped in a ``<div>`` tag (but see the `nowrap` option). The ``<div>``'s CSS class can be set by the `cssclass` option."),
|
20
10
|
'IRCFormatter': ('pygments.formatters.irc', 'IRC', ('irc', 'IRC'), (), 'Format tokens with IRC color sequences'),
|
21
11
|
'ImageFormatter': ('pygments.formatters.img', 'img', ('img', 'IMG', 'png'), ('*.png',), 'Create a PNG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
|
22
12
|
'JpgImageFormatter': ('pygments.formatters.img', 'img_jpg', ('jpg', 'jpeg'), ('*.jpg',), 'Create a JPEG image from source code. This uses the Python Imaging Library to generate a pixmap from the source code.'),
|
@@ -29,55 +19,5 @@ FORMATTERS = {
|
|
29
19
|
'Terminal256Formatter': ('pygments.formatters.terminal256', 'Terminal256', ('terminal256', 'console256', '256'), (), 'Format tokens with ANSI color sequences, for output in a 256-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'),
|
30
20
|
'TerminalFormatter': ('pygments.formatters.terminal', 'Terminal', ('terminal', 'console'), (), 'Format tokens with ANSI color sequences, for output in a text console. Color sequences are terminated at newlines, so that paging the output works correctly.'),
|
31
21
|
'TerminalTrueColorFormatter': ('pygments.formatters.terminal256', 'TerminalTrueColor', ('terminal16m', 'console16m', '16m'), (), 'Format tokens with ANSI color sequences, for output in a true-color terminal or console. Like in `TerminalFormatter` color sequences are terminated at newlines, so that paging the output works correctly.'),
|
32
|
-
'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.')
|
22
|
+
'TestcaseFormatter': ('pygments.formatters.other', 'Testcase', ('testcase',), (), 'Format tokens as appropriate for a new testcase.'),
|
33
23
|
}
|
34
|
-
|
35
|
-
if __name__ == '__main__': # pragma: no cover
|
36
|
-
import sys
|
37
|
-
import os
|
38
|
-
|
39
|
-
# lookup formatters
|
40
|
-
found_formatters = []
|
41
|
-
imports = []
|
42
|
-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
|
43
|
-
from pygments.util import docstring_headline
|
44
|
-
|
45
|
-
for root, dirs, files in os.walk('.'):
|
46
|
-
for filename in files:
|
47
|
-
if filename.endswith('.py') and not filename.startswith('_'):
|
48
|
-
module_name = 'pygments.formatters%s.%s' % (
|
49
|
-
root[1:].replace('/', '.'), filename[:-3])
|
50
|
-
print(module_name)
|
51
|
-
module = __import__(module_name, None, None, [''])
|
52
|
-
for formatter_name in module.__all__:
|
53
|
-
formatter = getattr(module, formatter_name)
|
54
|
-
found_formatters.append(
|
55
|
-
'%r: %r' % (formatter_name,
|
56
|
-
(module_name,
|
57
|
-
formatter.name,
|
58
|
-
tuple(formatter.aliases),
|
59
|
-
tuple(formatter.filenames),
|
60
|
-
docstring_headline(formatter))))
|
61
|
-
# sort them to make the diff minimal
|
62
|
-
found_formatters.sort()
|
63
|
-
|
64
|
-
# extract useful sourcecode from this file
|
65
|
-
with open(__file__) as fp:
|
66
|
-
content = fp.read()
|
67
|
-
# replace crnl to nl for Windows.
|
68
|
-
#
|
69
|
-
# Note that, originally, contributers should keep nl of master
|
70
|
-
# repository, for example by using some kind of automatic
|
71
|
-
# management EOL, like `EolExtension
|
72
|
-
# <https://www.mercurial-scm.org/wiki/EolExtension>`.
|
73
|
-
content = content.replace("\r\n", "\n")
|
74
|
-
header = content[:content.find('FORMATTERS = {')]
|
75
|
-
footer = content[content.find("if __name__ == '__main__':"):]
|
76
|
-
|
77
|
-
# write new file
|
78
|
-
with open(__file__, 'w') as fp:
|
79
|
-
fp.write(header)
|
80
|
-
fp.write('FORMATTERS = {\n %s\n}\n\n' % ',\n '.join(found_formatters))
|
81
|
-
fp.write(footer)
|
82
|
-
|
83
|
-
print ('=== %d formatters processed.' % len(found_formatters))
|