mortar-pygments.rb 0.5.5
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.
- data/.gitignore +6 -0
- data/CHANGELOG.md +71 -0
- data/Gemfile +2 -0
- data/LICENSE +17 -0
- data/README.md +121 -0
- data/Rakefile +66 -0
- data/bench.rb +22 -0
- data/cache-lexers.rb +8 -0
- data/lexers +0 -0
- data/lib/pygments/lexer.rb +148 -0
- data/lib/pygments/mentos.py +351 -0
- data/lib/pygments/popen.rb +406 -0
- data/lib/pygments/version.rb +3 -0
- data/lib/pygments.rb +8 -0
- data/pygments.rb.gemspec +25 -0
- data/test/test_data.c +2581 -0
- data/test/test_data.py +514 -0
- data/test/test_data_generated +2582 -0
- data/test/test_pygments.rb +287 -0
- data/vendor/custom_lexers/github.py +565 -0
- data/vendor/pygments-main/AUTHORS +153 -0
- data/vendor/pygments-main/CHANGES +889 -0
- data/vendor/pygments-main/LICENSE +25 -0
- data/vendor/pygments-main/MANIFEST.in +6 -0
- data/vendor/pygments-main/Makefile +59 -0
- data/vendor/pygments-main/REVISION +1 -0
- data/vendor/pygments-main/TODO +15 -0
- data/vendor/pygments-main/docs/generate.py +472 -0
- data/vendor/pygments-main/docs/pygmentize.1 +94 -0
- data/vendor/pygments-main/docs/src/api.txt +270 -0
- data/vendor/pygments-main/docs/src/authors.txt +5 -0
- data/vendor/pygments-main/docs/src/changelog.txt +5 -0
- data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
- data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
- data/vendor/pygments-main/docs/src/filters.txt +42 -0
- data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
- data/vendor/pygments-main/docs/src/formatters.txt +48 -0
- data/vendor/pygments-main/docs/src/index.txt +69 -0
- data/vendor/pygments-main/docs/src/installation.txt +71 -0
- data/vendor/pygments-main/docs/src/integrate.txt +48 -0
- data/vendor/pygments-main/docs/src/java.txt +70 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +603 -0
- data/vendor/pygments-main/docs/src/lexers.txt +67 -0
- data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
- data/vendor/pygments-main/docs/src/plugins.txt +93 -0
- data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
- data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
- data/vendor/pygments-main/docs/src/styles.txt +143 -0
- data/vendor/pygments-main/docs/src/tokens.txt +349 -0
- data/vendor/pygments-main/docs/src/unicode.txt +49 -0
- data/vendor/pygments-main/external/autopygmentize +64 -0
- data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +144 -0
- data/vendor/pygments-main/external/markdown-processor.py +67 -0
- data/vendor/pygments-main/external/moin-parser.py +112 -0
- data/vendor/pygments-main/external/pygments.bashcomp +38 -0
- data/vendor/pygments-main/external/rst-directive-old.py +77 -0
- data/vendor/pygments-main/external/rst-directive.py +83 -0
- data/vendor/pygments-main/ez_setup.py +276 -0
- data/vendor/pygments-main/pygmentize +7 -0
- data/vendor/pygments-main/pygments/__init__.py +91 -0
- data/vendor/pygments-main/pygments/cmdline.py +441 -0
- data/vendor/pygments-main/pygments/console.py +74 -0
- data/vendor/pygments-main/pygments/filter.py +74 -0
- data/vendor/pygments-main/pygments/filters/__init__.py +356 -0
- data/vendor/pygments-main/pygments/formatter.py +95 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +92 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/html.py +821 -0
- data/vendor/pygments-main/pygments/formatters/img.py +553 -0
- data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
- data/vendor/pygments-main/pygments/formatters/other.py +115 -0
- data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
- data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
- data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
- data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
- data/vendor/pygments-main/pygments/lexer.py +765 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +240 -0
- data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
- data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +5172 -0
- data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +355 -0
- data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +562 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +233 -0
- data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +557 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +40 -0
- data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +360 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +13 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +2290 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +398 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +3723 -0
- data/vendor/pygments-main/pygments/lexers/dalvik.py +104 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +671 -0
- data/vendor/pygments-main/pygments/lexers/foxpro.py +428 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +2731 -0
- data/vendor/pygments-main/pygments/lexers/github.py +565 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +1112 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1918 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3778 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +778 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +424 -0
- data/vendor/pygments-main/pygments/lexers/special.py +100 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +609 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +1742 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1893 -0
- data/vendor/pygments-main/pygments/lexers/web.py +4045 -0
- data/vendor/pygments-main/pygments/modeline.py +40 -0
- data/vendor/pygments-main/pygments/plugin.py +74 -0
- data/vendor/pygments-main/pygments/scanner.py +104 -0
- data/vendor/pygments-main/pygments/style.py +117 -0
- data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
- data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
- data/vendor/pygments-main/pygments/styles/borland.py +51 -0
- data/vendor/pygments-main/pygments/styles/bw.py +49 -0
- data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
- data/vendor/pygments-main/pygments/styles/default.py +73 -0
- data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
- data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
- data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
- data/vendor/pygments-main/pygments/styles/manni.py +75 -0
- data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
- data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
- data/vendor/pygments-main/pygments/styles/native.py +65 -0
- data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
- data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
- data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
- data/vendor/pygments-main/pygments/styles/tango.py +141 -0
- data/vendor/pygments-main/pygments/styles/trac.py +63 -0
- data/vendor/pygments-main/pygments/styles/vim.py +63 -0
- data/vendor/pygments-main/pygments/styles/vs.py +38 -0
- data/vendor/pygments-main/pygments/token.py +195 -0
- data/vendor/pygments-main/pygments/unistring.py +140 -0
- data/vendor/pygments-main/pygments/util.py +277 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +32 -0
- data/vendor/pygments-main/scripts/epydoc.css +280 -0
- data/vendor/pygments-main/scripts/find_codetags.py +205 -0
- data/vendor/pygments-main/scripts/find_error.py +170 -0
- data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
- data/vendor/pygments-main/scripts/pylintrc +301 -0
- data/vendor/pygments-main/scripts/reindent.py +291 -0
- data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
- data/vendor/pygments-main/setup.cfg +7 -0
- data/vendor/pygments-main/setup.py +90 -0
- data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
- data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
- data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
- data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
- data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
- data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
- data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
- data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
- data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
- data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
- data/vendor/pygments-main/tests/examplefiles/BOM.js +1 -0
- data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
- data/vendor/pygments-main/tests/examplefiles/Config.in.cache +1973 -0
- data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
- data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
- data/vendor/pygments-main/tests/examplefiles/Deflate.fs +578 -0
- data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
- data/vendor/pygments-main/tests/examplefiles/Get-CommandDefinitionHtml.ps1 +66 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchC.nc +104 -0
- data/vendor/pygments-main/tests/examplefiles/IPDispatchP.nc +671 -0
- data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
- data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
- data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
- data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
- data/vendor/pygments-main/tests/examplefiles/RoleQ.pm6 +23 -0
- data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
- data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
- data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
- data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
- data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
- data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
- data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
- data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/autoit_submit.au3 +25 -0
- data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/bigtest.nsi +308 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
- data/vendor/pygments-main/tests/examplefiles/ca65_example +284 -0
- data/vendor/pygments-main/tests/examplefiles/cbmbas_example +9 -0
- data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
- data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
- data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
- data/vendor/pygments-main/tests/examplefiles/classes.dylan +125 -0
- data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
- data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
- data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
- data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
- data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
- data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
- data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
- data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
- data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
- data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
- data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.Rd +78 -0
- data/vendor/pygments-main/tests/examplefiles/example.bug +54 -0
- data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.ceylon +52 -0
- data/vendor/pygments-main/tests/examplefiles/example.clay +33 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.cob +3556 -0
- data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
- data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
- data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
- data/vendor/pygments-main/tests/examplefiles/example.hx +142 -0
- data/vendor/pygments-main/tests/examplefiles/example.jag +48 -0
- data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lagda +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
- data/vendor/pygments-main/tests/examplefiles/example.monkey +152 -0
- data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
- data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
- data/vendor/pygments-main/tests/examplefiles/example.msc +43 -0
- data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
- data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
- data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
- data/vendor/pygments-main/tests/examplefiles/example.prg +161 -0
- data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.reg +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.rexx +50 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.rkt +95 -0
- data/vendor/pygments-main/tests/examplefiles/example.rpf +4 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
- data/vendor/pygments-main/tests/examplefiles/example.shell-session +45 -0
- data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
- data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
- data/vendor/pygments-main/tests/examplefiles/example.stan +108 -0
- data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.ts +28 -0
- data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
- data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
- data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
- data/vendor/pygments-main/tests/examplefiles/example.xtend +34 -0
- data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
- data/vendor/pygments-main/tests/examplefiles/example2.msc +79 -0
- data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
- data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
- data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
- data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
- data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
- data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
- data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
- data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
- data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
- data/vendor/pygments-main/tests/examplefiles/garcia-wachs.kk +133 -0
- data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
- data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
- data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
- data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
- data/vendor/pygments-main/tests/examplefiles/grammar-test.p6 +22 -0
- data/vendor/pygments-main/tests/examplefiles/hello.smali +40 -0
- data/vendor/pygments-main/tests/examplefiles/hello.sp +9 -0
- data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +15 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +29 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
- data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +71 -0
- data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
- data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
- data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
- data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
- data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
- data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
- data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
- data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso +301 -0
- data/vendor/pygments-main/tests/examplefiles/json.lasso9 +213 -0
- data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
- data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +41 -0
- data/vendor/pygments-main/tests/examplefiles/logos_example.xm +28 -0
- data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
- data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
- data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
- data/vendor/pygments-main/tests/examplefiles/matlab_sample +30 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
- data/vendor/pygments-main/tests/examplefiles/metagrammar.treetop +455 -0
- data/vendor/pygments-main/tests/examplefiles/mg_sample.pro +73 -0
- data/vendor/pygments-main/tests/examplefiles/minehunt.qml +112 -0
- data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
- data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
- data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
- data/vendor/pygments-main/tests/examplefiles/nanomsg.intr +95 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
- data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
- data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
- data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
- data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example.m +32 -0
- data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
- data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
- data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
- data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
- data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
- data/vendor/pygments-main/tests/examplefiles/phpMyAdmin.spec +163 -0
- data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
- data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
- data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
- data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
- data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
- data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
- data/vendor/pygments-main/tests/examplefiles/py3tb_test.py3tb +4 -0
- data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test3.pytb +4 -0
- data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
- data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
- data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
- data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
- data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
- data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
- data/vendor/pygments-main/tests/examplefiles/robotframework.txt +39 -0
- data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/rust_example.rs +233 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
- data/vendor/pygments-main/tests/examplefiles/session.dylan-console +9 -0
- data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
- data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
- data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
- data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
- data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
- data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
- data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
- data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
- data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
- data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
- data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
- data/vendor/pygments-main/tests/examplefiles/swig_java.swg +1329 -0
- data/vendor/pygments-main/tests/examplefiles/swig_std_vector.i +225 -0
- data/vendor/pygments-main/tests/examplefiles/test.R +153 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
- data/vendor/pygments-main/tests/examplefiles/test.agda +102 -0
- data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
- data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
- data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
- data/vendor/pygments-main/tests/examplefiles/test.bb +95 -0
- data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
- data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
- data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
- data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
- data/vendor/pygments-main/tests/examplefiles/test.cu +36 -0
- data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
- data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
- data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
- data/vendor/pygments-main/tests/examplefiles/test.ebnf +31 -0
- data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
- data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
- data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
- data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
- data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
- data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
- data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
- data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
- data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
- data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
- data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
- data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
- data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
- data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
- data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
- data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
- data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
- data/vendor/pygments-main/tests/examplefiles/test.opa +10 -0
- data/vendor/pygments-main/tests/examplefiles/test.p6 +252 -0
- data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
- data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
- data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
- data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
- data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
- data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
- data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
- data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
- data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
- data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
- data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
- data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
- data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
- data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
- data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
- data/vendor/pygments-main/tests/examplefiles/test2.pypylog +120 -0
- data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1218 -0
- data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
- data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
- data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
- data/vendor/pygments-main/tests/examplefiles/unix-io.lid +37 -0
- data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
- data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
- data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
- data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
- data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
- data/vendor/pygments-main/tests/old_run.py +138 -0
- data/vendor/pygments-main/tests/run.py +49 -0
- data/vendor/pygments-main/tests/support/tags +36 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/test_basic_api.py +295 -0
- data/vendor/pygments-main/tests/test_clexer.py +31 -0
- data/vendor/pygments-main/tests/test_cmdline.py +105 -0
- data/vendor/pygments-main/tests/test_examplefiles.py +99 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +178 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
- data/vendor/pygments-main/tests/test_lexers_other.py +68 -0
- data/vendor/pygments-main/tests/test_perllexer.py +137 -0
- data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
- data/vendor/pygments-main/tests/test_token.py +46 -0
- data/vendor/pygments-main/tests/test_using_api.py +40 -0
- data/vendor/pygments-main/tests/test_util.py +135 -0
- data/vendor/simplejson/.gitignore +10 -0
- data/vendor/simplejson/.travis.yml +5 -0
- data/vendor/simplejson/CHANGES.txt +291 -0
- data/vendor/simplejson/LICENSE.txt +19 -0
- data/vendor/simplejson/MANIFEST.in +5 -0
- data/vendor/simplejson/README.rst +19 -0
- data/vendor/simplejson/conf.py +179 -0
- data/vendor/simplejson/index.rst +628 -0
- data/vendor/simplejson/scripts/make_docs.py +18 -0
- data/vendor/simplejson/setup.py +104 -0
- data/vendor/simplejson/simplejson/__init__.py +510 -0
- data/vendor/simplejson/simplejson/_speedups.c +2745 -0
- data/vendor/simplejson/simplejson/decoder.py +425 -0
- data/vendor/simplejson/simplejson/encoder.py +567 -0
- data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
- data/vendor/simplejson/simplejson/scanner.py +77 -0
- data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
- data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
- data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
- data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
- data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
- data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
- data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
- data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
- data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
- data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
- data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
- data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
- data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
- data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
- data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
- data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
- data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
- data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
- data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
- data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
- data/vendor/simplejson/simplejson/tool.py +39 -0
- metadata +566 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
.. -*- mode: rst -*-
|
|
2
|
+
|
|
3
|
+
========================
|
|
4
|
+
Write your own formatter
|
|
5
|
+
========================
|
|
6
|
+
|
|
7
|
+
As well as creating `your own lexer <lexerdevelopment.txt>`_, writing a new
|
|
8
|
+
formatter for Pygments is easy and straightforward.
|
|
9
|
+
|
|
10
|
+
A formatter is a class that is initialized with some keyword arguments (the
|
|
11
|
+
formatter options) and that must provides a `format()` method.
|
|
12
|
+
Additionally a formatter should provide a `get_style_defs()` method that
|
|
13
|
+
returns the style definitions from the style in a form usable for the
|
|
14
|
+
formatter's output format.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
Quickstart
|
|
18
|
+
==========
|
|
19
|
+
|
|
20
|
+
The most basic formatter shipped with Pygments is the `NullFormatter`. It just
|
|
21
|
+
sends the value of a token to the output stream:
|
|
22
|
+
|
|
23
|
+
.. sourcecode:: python
|
|
24
|
+
|
|
25
|
+
from pygments.formatter import Formatter
|
|
26
|
+
|
|
27
|
+
class NullFormatter(Formatter):
|
|
28
|
+
def format(self, tokensource, outfile):
|
|
29
|
+
for ttype, value in tokensource:
|
|
30
|
+
outfile.write(value)
|
|
31
|
+
|
|
32
|
+
As you can see, the `format()` method is passed two parameters: `tokensource`
|
|
33
|
+
and `outfile`. The first is an iterable of ``(token_type, value)`` tuples,
|
|
34
|
+
the latter a file like object with a `write()` method.
|
|
35
|
+
|
|
36
|
+
Because the formatter is that basic it doesn't overwrite the `get_style_defs()`
|
|
37
|
+
method.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Styles
|
|
41
|
+
======
|
|
42
|
+
|
|
43
|
+
Styles aren't instantiated but their metaclass provides some class functions
|
|
44
|
+
so that you can access the style definitions easily.
|
|
45
|
+
|
|
46
|
+
Styles are iterable and yield tuples in the form ``(ttype, d)`` where `ttype`
|
|
47
|
+
is a token and `d` is a dict with the following keys:
|
|
48
|
+
|
|
49
|
+
``'color'``
|
|
50
|
+
Hexadecimal color value (eg: ``'ff0000'`` for red) or `None` if not
|
|
51
|
+
defined.
|
|
52
|
+
|
|
53
|
+
``'bold'``
|
|
54
|
+
`True` if the value should be bold
|
|
55
|
+
|
|
56
|
+
``'italic'``
|
|
57
|
+
`True` if the value should be italic
|
|
58
|
+
|
|
59
|
+
``'underline'``
|
|
60
|
+
`True` if the value should be underlined
|
|
61
|
+
|
|
62
|
+
``'bgcolor'``
|
|
63
|
+
Hexadecimal color value for the background (eg: ``'eeeeeee'`` for light
|
|
64
|
+
gray) or `None` if not defined.
|
|
65
|
+
|
|
66
|
+
``'border'``
|
|
67
|
+
Hexadecimal color value for the border (eg: ``'0000aa'`` for a dark
|
|
68
|
+
blue) or `None` for no border.
|
|
69
|
+
|
|
70
|
+
Additional keys might appear in the future, formatters should ignore all keys
|
|
71
|
+
they don't support.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
HTML 3.2 Formatter
|
|
75
|
+
==================
|
|
76
|
+
|
|
77
|
+
For an more complex example, let's implement a HTML 3.2 Formatter. We don't
|
|
78
|
+
use CSS but inline markup (``<u>``, ``<font>``, etc). Because this isn't good
|
|
79
|
+
style this formatter isn't in the standard library ;-)
|
|
80
|
+
|
|
81
|
+
.. sourcecode:: python
|
|
82
|
+
|
|
83
|
+
from pygments.formatter import Formatter
|
|
84
|
+
|
|
85
|
+
class OldHtmlFormatter(Formatter):
|
|
86
|
+
|
|
87
|
+
def __init__(self, **options):
|
|
88
|
+
Formatter.__init__(self, **options)
|
|
89
|
+
|
|
90
|
+
# create a dict of (start, end) tuples that wrap the
|
|
91
|
+
# value of a token so that we can use it in the format
|
|
92
|
+
# method later
|
|
93
|
+
self.styles = {}
|
|
94
|
+
|
|
95
|
+
# we iterate over the `_styles` attribute of a style item
|
|
96
|
+
# that contains the parsed style values.
|
|
97
|
+
for token, style in self.style:
|
|
98
|
+
start = end = ''
|
|
99
|
+
# a style item is a tuple in the following form:
|
|
100
|
+
# colors are readily specified in hex: 'RRGGBB'
|
|
101
|
+
if style['color']:
|
|
102
|
+
start += '<font color="#%s">' % style['color']
|
|
103
|
+
end = '</font>' + end
|
|
104
|
+
if style['bold']:
|
|
105
|
+
start += '<b>'
|
|
106
|
+
end = '</b>' + end
|
|
107
|
+
if style['italic']:
|
|
108
|
+
start += '<i>'
|
|
109
|
+
end = '</i>' + end
|
|
110
|
+
if style['underline']:
|
|
111
|
+
start += '<u>'
|
|
112
|
+
end = '</u>' + end
|
|
113
|
+
self.styles[token] = (start, end)
|
|
114
|
+
|
|
115
|
+
def format(self, tokensource, outfile):
|
|
116
|
+
# lastval is a string we use for caching
|
|
117
|
+
# because it's possible that an lexer yields a number
|
|
118
|
+
# of consecutive tokens with the same token type.
|
|
119
|
+
# to minimize the size of the generated html markup we
|
|
120
|
+
# try to join the values of same-type tokens here
|
|
121
|
+
lastval = ''
|
|
122
|
+
lasttype = None
|
|
123
|
+
|
|
124
|
+
# wrap the whole output with <pre>
|
|
125
|
+
outfile.write('<pre>')
|
|
126
|
+
|
|
127
|
+
for ttype, value in tokensource:
|
|
128
|
+
# if the token type doesn't exist in the stylemap
|
|
129
|
+
# we try it with the parent of the token type
|
|
130
|
+
# eg: parent of Token.Literal.String.Double is
|
|
131
|
+
# Token.Literal.String
|
|
132
|
+
while ttype not in self.styles:
|
|
133
|
+
ttype = ttype.parent
|
|
134
|
+
if ttype == lasttype:
|
|
135
|
+
# the current token type is the same of the last
|
|
136
|
+
# iteration. cache it
|
|
137
|
+
lastval += value
|
|
138
|
+
else:
|
|
139
|
+
# not the same token as last iteration, but we
|
|
140
|
+
# have some data in the buffer. wrap it with the
|
|
141
|
+
# defined style and write it to the output file
|
|
142
|
+
if lastval:
|
|
143
|
+
stylebegin, styleend = self.styles[lasttype]
|
|
144
|
+
outfile.write(stylebegin + lastval + styleend)
|
|
145
|
+
# set lastval/lasttype to current values
|
|
146
|
+
lastval = value
|
|
147
|
+
lasttype = ttype
|
|
148
|
+
|
|
149
|
+
# if something is left in the buffer, write it to the
|
|
150
|
+
# output file, then close the opened <pre> tag
|
|
151
|
+
if lastval:
|
|
152
|
+
stylebegin, styleend = self.styles[lasttype]
|
|
153
|
+
outfile.write(stylebegin + lastval + styleend)
|
|
154
|
+
outfile.write('</pre>\n')
|
|
155
|
+
|
|
156
|
+
The comments should explain it. Again, this formatter doesn't override the
|
|
157
|
+
`get_style_defs()` method. If we would have used CSS classes instead of
|
|
158
|
+
inline HTML markup, we would need to generate the CSS first. For that
|
|
159
|
+
purpose the `get_style_defs()` method exists:
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
Generating Style Definitions
|
|
163
|
+
============================
|
|
164
|
+
|
|
165
|
+
Some formatters like the `LatexFormatter` and the `HtmlFormatter` don't
|
|
166
|
+
output inline markup but reference either macros or css classes. Because
|
|
167
|
+
the definitions of those are not part of the output, the `get_style_defs()`
|
|
168
|
+
method exists. It is passed one parameter (if it's used and how it's used
|
|
169
|
+
is up to the formatter) and has to return a string or ``None``.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.. -*- mode: rst -*-
|
|
2
|
+
|
|
3
|
+
====================
|
|
4
|
+
Available formatters
|
|
5
|
+
====================
|
|
6
|
+
|
|
7
|
+
This page lists all builtin formatters.
|
|
8
|
+
|
|
9
|
+
Common options
|
|
10
|
+
==============
|
|
11
|
+
|
|
12
|
+
All formatters support these options:
|
|
13
|
+
|
|
14
|
+
`encoding`
|
|
15
|
+
*New in Pygments 0.6.*
|
|
16
|
+
|
|
17
|
+
If given, must be an encoding name (such as ``"utf-8"``). This will
|
|
18
|
+
be used to convert the token strings (which are Unicode strings)
|
|
19
|
+
to byte strings in the output (default: ``None``).
|
|
20
|
+
It will also be written in an encoding declaration suitable for the
|
|
21
|
+
document format if the `full` option is given (e.g. a ``meta
|
|
22
|
+
content-type`` directive in HTML or an invocation of the `inputenc`
|
|
23
|
+
package in LaTeX).
|
|
24
|
+
|
|
25
|
+
If this is ``""`` or ``None``, Unicode strings will be written
|
|
26
|
+
to the output file, which most file-like objects do not support.
|
|
27
|
+
For example, `pygments.highlight()` will return a Unicode string if
|
|
28
|
+
called with no `outfile` argument and a formatter that has `encoding`
|
|
29
|
+
set to ``None`` because it uses a `StringIO.StringIO` object that
|
|
30
|
+
supports Unicode arguments to `write()`. Using a regular file object
|
|
31
|
+
wouldn't work.
|
|
32
|
+
|
|
33
|
+
`outencoding`
|
|
34
|
+
*New in Pygments 0.7.*
|
|
35
|
+
|
|
36
|
+
When using Pygments from the command line, any `encoding` option given is
|
|
37
|
+
passed to the lexer and the formatter. This is sometimes not desirable,
|
|
38
|
+
for example if you want to set the input encoding to ``"guess"``.
|
|
39
|
+
Therefore, `outencoding` has been introduced which overrides `encoding`
|
|
40
|
+
for the formatter if given.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Formatter classes
|
|
44
|
+
=================
|
|
45
|
+
|
|
46
|
+
All these classes are importable from `pygments.formatters`.
|
|
47
|
+
|
|
48
|
+
[builtin_formatter_docs]
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.. -*- mode: rst -*-
|
|
2
|
+
|
|
3
|
+
========
|
|
4
|
+
Overview
|
|
5
|
+
========
|
|
6
|
+
|
|
7
|
+
Welcome to the Pygments documentation.
|
|
8
|
+
|
|
9
|
+
- Starting with Pygments
|
|
10
|
+
|
|
11
|
+
- `Installation <installation.txt>`_
|
|
12
|
+
|
|
13
|
+
- `Introduction and Quickstart <quickstart.txt>`_
|
|
14
|
+
|
|
15
|
+
- `Command line interface <cmdline.txt>`_
|
|
16
|
+
|
|
17
|
+
- Builtin components
|
|
18
|
+
|
|
19
|
+
- `Lexers <lexers.txt>`_
|
|
20
|
+
|
|
21
|
+
- `Formatters <formatters.txt>`_
|
|
22
|
+
|
|
23
|
+
- `Filters <filters.txt>`_
|
|
24
|
+
|
|
25
|
+
- `Styles <styles.txt>`_
|
|
26
|
+
|
|
27
|
+
- Reference
|
|
28
|
+
|
|
29
|
+
- `Unicode and encodings <unicode.txt>`_
|
|
30
|
+
|
|
31
|
+
- `Builtin tokens <tokens.txt>`_
|
|
32
|
+
|
|
33
|
+
- `API documentation <api.txt>`_
|
|
34
|
+
|
|
35
|
+
- Hacking for Pygments
|
|
36
|
+
|
|
37
|
+
- `Write your own lexer <lexerdevelopment.txt>`_
|
|
38
|
+
|
|
39
|
+
- `Write your own formatter <formatterdevelopment.txt>`_
|
|
40
|
+
|
|
41
|
+
- `Write your own filter <filterdevelopment.txt>`_
|
|
42
|
+
|
|
43
|
+
- `Register plugins <plugins.txt>`_
|
|
44
|
+
|
|
45
|
+
- Hints and Tricks
|
|
46
|
+
|
|
47
|
+
- `Using Pygments in ReST documents <rstdirective.txt>`_
|
|
48
|
+
|
|
49
|
+
- `Using Pygments with MoinMoin <moinmoin.txt>`_
|
|
50
|
+
|
|
51
|
+
- `Using Pygments in other contexts <integrate.txt>`_
|
|
52
|
+
|
|
53
|
+
- About Pygments
|
|
54
|
+
|
|
55
|
+
- `Changelog <changelog.txt>`_
|
|
56
|
+
|
|
57
|
+
- `Authors <authors.txt>`_
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
--------------
|
|
61
|
+
|
|
62
|
+
If you find bugs or have suggestions for the documentation, please
|
|
63
|
+
look `here`_ for info on how to contact the team.
|
|
64
|
+
|
|
65
|
+
You can download an offline version of this documentation from the
|
|
66
|
+
`download page`_.
|
|
67
|
+
|
|
68
|
+
.. _here: http://pygments.org/contribute/
|
|
69
|
+
.. _download page: http://pygments.org/download/
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
.. -*- mode: rst -*-
|
|
2
|
+
|
|
3
|
+
============
|
|
4
|
+
Installation
|
|
5
|
+
============
|
|
6
|
+
|
|
7
|
+
Pygments requires at least Python 2.4 to work correctly. Just to clarify:
|
|
8
|
+
there *won't* ever be support for Python versions below 2.4. However, there
|
|
9
|
+
are no other dependencies.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Installing a released version
|
|
13
|
+
=============================
|
|
14
|
+
|
|
15
|
+
As a Python egg (via easy_install)
|
|
16
|
+
----------------------------------
|
|
17
|
+
|
|
18
|
+
You can install the most recent Pygments version using `easy_install`_::
|
|
19
|
+
|
|
20
|
+
sudo easy_install Pygments
|
|
21
|
+
|
|
22
|
+
This will install a Pygments egg in your Python installation's site-packages
|
|
23
|
+
directory.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
From the tarball release
|
|
27
|
+
-------------------------
|
|
28
|
+
|
|
29
|
+
1. Download the most recent tarball from the `download page`_
|
|
30
|
+
2. Unpack the tarball
|
|
31
|
+
3. ``sudo python setup.py install``
|
|
32
|
+
|
|
33
|
+
Note that the last command will automatically download and install
|
|
34
|
+
`setuptools`_ if you don't already have it installed. This requires a working
|
|
35
|
+
internet connection.
|
|
36
|
+
|
|
37
|
+
This will install Pygments into your Python installation's site-packages directory.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Installing the development version
|
|
41
|
+
==================================
|
|
42
|
+
|
|
43
|
+
If you want to play around with the code
|
|
44
|
+
----------------------------------------
|
|
45
|
+
|
|
46
|
+
1. Install `Mercurial`_
|
|
47
|
+
2. ``hg clone http://bitbucket.org/birkenfeld/pygments-main pygments``
|
|
48
|
+
3. ``cd pygments``
|
|
49
|
+
4. ``ln -s pygments /usr/lib/python2.X/site-packages``
|
|
50
|
+
5. ``ln -s pygmentize /usr/local/bin``
|
|
51
|
+
|
|
52
|
+
As an alternative to steps 4 and 5 you can also do ``python setup.py develop``
|
|
53
|
+
which will install the package via setuptools in development mode.
|
|
54
|
+
|
|
55
|
+
..
|
|
56
|
+
If you just want the latest features and use them
|
|
57
|
+
-------------------------------------------------
|
|
58
|
+
|
|
59
|
+
::
|
|
60
|
+
|
|
61
|
+
sudo easy_install Pygments==dev
|
|
62
|
+
|
|
63
|
+
This will install a Pygments egg containing the latest Subversion trunk code
|
|
64
|
+
in your Python installation's site-packages directory. Every time the command
|
|
65
|
+
is run, the sources are updated from Subversion.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
.. _download page: http://pygments.org/download/
|
|
69
|
+
.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
|
|
70
|
+
.. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
|
|
71
|
+
.. _Mercurial: http://selenic.com/mercurial/
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
.. -*- mode: rst -*-
|
|
2
|
+
|
|
3
|
+
===================================
|
|
4
|
+
Using Pygments in various scenarios
|
|
5
|
+
===================================
|
|
6
|
+
|
|
7
|
+
PyGtk
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
Armin has written a piece of sample code that shows how to create a Gtk
|
|
11
|
+
`TextBuffer` object containing Pygments-highlighted text.
|
|
12
|
+
|
|
13
|
+
See the article here: http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-gtk-rendering/
|
|
14
|
+
|
|
15
|
+
Wordpress
|
|
16
|
+
---------
|
|
17
|
+
|
|
18
|
+
He also has a snippet that shows how to use Pygments in WordPress:
|
|
19
|
+
|
|
20
|
+
http://lucumr.pocoo.org/cogitations/2007/05/30/pygments-in-wordpress/
|
|
21
|
+
|
|
22
|
+
Markdown
|
|
23
|
+
--------
|
|
24
|
+
|
|
25
|
+
Since Pygments 0.9, the distribution ships Markdown_ preprocessor sample code
|
|
26
|
+
that uses Pygments to render source code in `external/markdown-processor.py`.
|
|
27
|
+
You can copy and adapt it to your liking.
|
|
28
|
+
|
|
29
|
+
.. _Markdown: http://www.freewisdom.org/projects/python-markdown/
|
|
30
|
+
|
|
31
|
+
TextMate
|
|
32
|
+
--------
|
|
33
|
+
|
|
34
|
+
Antonio Cangiano has created a Pygments bundle for TextMate that allows to
|
|
35
|
+
colorize code via a simple menu option. It can be found here_.
|
|
36
|
+
|
|
37
|
+
.. _here: http://antoniocangiano.com/2008/10/28/pygments-textmate-bundle/
|
|
38
|
+
|
|
39
|
+
Bash completion
|
|
40
|
+
---------------
|
|
41
|
+
|
|
42
|
+
The source distribution contains a file ``external/pygments.bashcomp`` that
|
|
43
|
+
sets up completion for the ``pygmentize`` command in bash.
|
|
44
|
+
|
|
45
|
+
Java
|
|
46
|
+
----
|
|
47
|
+
|
|
48
|
+
See the `Java quickstart <java.txt>`_ document.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
=====================
|
|
2
|
+
Use Pygments in Java
|
|
3
|
+
=====================
|
|
4
|
+
|
|
5
|
+
Thanks to `Jython <http://www.jython.org>`__ it is possible to use Pygments in
|
|
6
|
+
Java.
|
|
7
|
+
|
|
8
|
+
This page is a simple tutorial to get an idea of how this is working. You can
|
|
9
|
+
then look at the `Jython documentation <http://www.jython.org/docs/>`__ for more
|
|
10
|
+
advanced use.
|
|
11
|
+
|
|
12
|
+
Since version 1.5, Pygments is deployed on `Maven Central
|
|
13
|
+
<http://repo1.maven.org/maven2/org/pygments/pygments/>`__ as a JAR so is Jython
|
|
14
|
+
which makes it a lot easier to create the Java project.
|
|
15
|
+
|
|
16
|
+
Here is an example of a `Maven <http://www.maven.org>`__ ``pom.xml`` file for a
|
|
17
|
+
project running Pygments:
|
|
18
|
+
|
|
19
|
+
.. sourcecode:: xml
|
|
20
|
+
|
|
21
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
22
|
+
|
|
23
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
24
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
25
|
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
|
26
|
+
http://maven.apache.org/maven-v4_0_0.xsd">
|
|
27
|
+
<modelVersion>4.0.0</modelVersion>
|
|
28
|
+
<groupId>example</groupId>
|
|
29
|
+
<artifactId>example</artifactId>
|
|
30
|
+
<version>1.0-SNAPSHOT</version>
|
|
31
|
+
<dependencies>
|
|
32
|
+
<dependency>
|
|
33
|
+
<groupId>org.python</groupId>
|
|
34
|
+
<artifactId>jython-standalone</artifactId>
|
|
35
|
+
<version>2.5.3</version>
|
|
36
|
+
</dependency>
|
|
37
|
+
<dependency>
|
|
38
|
+
<groupId>org.pygments</groupId>
|
|
39
|
+
<artifactId>pygments</artifactId>
|
|
40
|
+
<version>1.5</version>
|
|
41
|
+
<scope>runtime</scope>
|
|
42
|
+
</dependency>
|
|
43
|
+
</dependencies>
|
|
44
|
+
</project>
|
|
45
|
+
|
|
46
|
+
The following Java example:
|
|
47
|
+
|
|
48
|
+
.. sourcecode:: java
|
|
49
|
+
|
|
50
|
+
PythonInterpreter interpreter = new PythonInterpreter();
|
|
51
|
+
|
|
52
|
+
// Set a variable with the content you want to work with
|
|
53
|
+
interpreter.set("code", code);
|
|
54
|
+
|
|
55
|
+
// Simple use Pygments as you would in Python
|
|
56
|
+
interpreter.exec("from pygments import highlight\n"
|
|
57
|
+
+ "from pygments.lexers import PythonLexer\n"
|
|
58
|
+
+ "from pygments.formatters import HtmlFormatter\n"
|
|
59
|
+
+ "\nresult = highlight(code, PythonLexer(), HtmlFormatter())");
|
|
60
|
+
|
|
61
|
+
// Get the result that has been set in a variable
|
|
62
|
+
System.out.println(interpreter.get("result", String.class));
|
|
63
|
+
|
|
64
|
+
will print something like:
|
|
65
|
+
|
|
66
|
+
.. sourcecode:: html
|
|
67
|
+
|
|
68
|
+
<div class="highlight">
|
|
69
|
+
<pre><span class="k">print</span> <span class="s">"Hello World"</span></pre>
|
|
70
|
+
</div>
|