gitlab-pygments.rb 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +2 -0
- data/README.md +91 -0
- data/Rakefile +78 -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 +344 -0
- data/lib/pygments/popen.rb +389 -0
- data/lib/pygments/version.rb +3 -0
- data/lib/pygments.rb +8 -0
- data/pygments.rb.gemspec +24 -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 +276 -0
- data/vendor/custom_formatters/gitlab.py +171 -0
- data/vendor/custom_lexers/github.py +362 -0
- data/vendor/pygments-main/AUTHORS +115 -0
- data/vendor/pygments-main/CHANGES +762 -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 +43 -0
- data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -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/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 +433 -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 +357 -0
- data/vendor/pygments-main/pygments/formatter.py +92 -0
- data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
- data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
- data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
- data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
- data/vendor/pygments-main/pygments/formatters/html.py +750 -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 +117 -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 +697 -0
- data/vendor/pygments-main/pygments/lexers/__init__.py +229 -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/_luabuiltins.py +249 -0
- data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
- data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
- data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
- data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
- data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
- data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
- data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
- data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
- data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
- data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
- data/vendor/pygments-main/pygments/lexers/github.py +362 -0
- data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
- data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
- data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
- data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
- data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
- data/vendor/pygments-main/pygments/lexers/shell.py +361 -0
- data/vendor/pygments-main/pygments/lexers/special.py +100 -0
- data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
- data/vendor/pygments-main/pygments/lexers/templates.py +1631 -0
- data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
- data/vendor/pygments-main/pygments/lexers/web.py +2864 -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 +130 -0
- data/vendor/pygments-main/pygments/util.py +232 -0
- data/vendor/pygments-main/scripts/check_sources.py +242 -0
- data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -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 +171 -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 +6 -0
- data/vendor/pygments-main/setup.py +88 -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/CPDictionary.j +611 -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/Errors.scala +18 -0
- data/vendor/pygments-main/tests/examplefiles/File.hy +174 -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/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/badcase.java +2 -0
- data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
- data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -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 +40 -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.c +2080 -0
- data/vendor/pygments-main/tests/examplefiles/example.cls +15 -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.kt +47 -0
- data/vendor/pygments-main/tests/examplefiles/example.lua +250 -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.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.rb +1852 -0
- data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
- data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -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.tea +34 -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.yaml +302 -0
- data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -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/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/html+php_faulty.php +1 -0
- data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
- data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
- data/vendor/pygments-main/tests/examplefiles/import.hs +4 -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/lighttpd_config.conf +13 -0
- data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -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 +27 -0
- data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -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/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 +25 -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/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/pycon_test.pycon +14 -0
- data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -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/ruby_func_def.rb +11 -0
- data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -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/test.R +119 -0
- data/vendor/pygments-main/tests/examplefiles/test.adb +211 -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.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.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.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.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/truncated.pytb +15 -0
- data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -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/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 +48 -0
- data/vendor/pygments-main/tests/support.py +15 -0
- data/vendor/pygments-main/tests/test_basic_api.py +294 -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 +97 -0
- data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
- data/vendor/pygments-main/tests/test_latex_formatter.py +55 -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 +116 -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 +492 -0
@@ -0,0 +1,276 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require File.join(File.dirname(__FILE__), '..', '/lib/pygments.rb')
|
5
|
+
ENV['mentos-test'] = "yes"
|
6
|
+
|
7
|
+
P = Pygments
|
8
|
+
|
9
|
+
class PygmentsHighlightTest < Test::Unit::TestCase
|
10
|
+
RUBY_CODE = "#!/usr/bin/ruby\nputs 'foo'"
|
11
|
+
RUBY_CODE_TRAILING_NEWLINE = "#!/usr/bin/ruby\nputs 'foo'\n"
|
12
|
+
REDIS_CODE = File.read(File.join(File.dirname(__FILE__), '..', '/test/test_data.c'))
|
13
|
+
|
14
|
+
def test_highlight_defaults_to_html
|
15
|
+
code = P.highlight(RUBY_CODE)
|
16
|
+
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
|
17
|
+
assert_equal '<div class', code[0..9]
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_highlight_works_with_larger_files
|
21
|
+
code = P.highlight(REDIS_CODE)
|
22
|
+
assert_match 'used_memory_peak_human', code
|
23
|
+
assert_equal 454107, code.bytesize.to_i
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_returns_nil_on_timeout
|
27
|
+
large_code = REDIS_CODE * 300
|
28
|
+
code = P.highlight(large_code) # a 30 mb highlight request will timeout
|
29
|
+
assert_equal nil, code
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_highlight_works_with_null_bytes
|
33
|
+
code = P.highlight("\0hello", :lexer => 'rb')
|
34
|
+
assert_match "hello", code
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_highlight_works_on_utf8
|
38
|
+
code = P.highlight('# ø', :lexer => 'rb', :options => {:encoding => 'utf-8'})
|
39
|
+
assert_match "# ø", code
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_highlight_works_on_utf8_automatically
|
43
|
+
code = P.highlight('# ø', :lexer => 'rb')
|
44
|
+
assert_match "# ø", code
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_highlight_works_on_utf8_all_chars_automatically
|
48
|
+
code = P.highlight('def foo: # ø', :lexer => 'py')
|
49
|
+
|
50
|
+
assert_equal '<div class="highlight"><pre><span clas', code[0,38]
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_highlight_works_with_multiple_utf8
|
54
|
+
code = P.highlight('# ø ø ø', :lexer => 'rb', :options => {:encoding => 'utf-8'})
|
55
|
+
assert_match "# ø ø ø", code
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_highlight_works_with_multiple_utf8_and_trailing_newline
|
59
|
+
code = P.highlight("#!/usr/bin/ruby\nputs 'ø..ø'\n", :lexer => 'rb')
|
60
|
+
assert_match "ø..ø", code
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_highlight_formatter_bbcode
|
64
|
+
code = P.highlight(RUBY_CODE, :formatter => 'bbcode')
|
65
|
+
assert_match 'color=#408080][i]#!/usr/bin/ruby[/i]', code
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_highlight_formatter_terminal
|
69
|
+
code = P.highlight(RUBY_CODE, :formatter => 'terminal')
|
70
|
+
assert_match '39;49;00m', code
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_highlight_options
|
74
|
+
code = P.highlight(RUBY_CODE, :options => {:full => true, :title => 'test'})
|
75
|
+
assert_match '<title>test</title>', code
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_highlight_works_with_single_character_input
|
79
|
+
code = P.highlight("a")
|
80
|
+
assert_match 'a</span>', code
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_highlight_works_with_trailing_newline
|
84
|
+
code = P.highlight(RUBY_CODE_TRAILING_NEWLINE)
|
85
|
+
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_highlight_works_with_multiple_newlines
|
89
|
+
code = P.highlight(RUBY_CODE_TRAILING_NEWLINE + "derp\n\n")
|
90
|
+
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_highlight_works_with_trailing_cr
|
94
|
+
code = P.highlight(RUBY_CODE_TRAILING_NEWLINE + "\r")
|
95
|
+
assert_match '<span class="c1">#!/usr/bin/ruby</span>', code
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_highlight_still_works_with_invalid_code
|
99
|
+
code = P.highlight("importr python; wat?", :lexer => 'py')
|
100
|
+
assert_match ">importr</span>", code
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Philosophically, I'm not the biggest fan of testing private
|
105
|
+
# methods, but given the relative delicacy of validity checking
|
106
|
+
# over the pipe I think it's necessary and informative.
|
107
|
+
class PygmentsValidityTest < Test::Unit::TestCase
|
108
|
+
def test_add_ids_with_padding
|
109
|
+
res = P.send(:add_ids, "herp derp baz boo foo", "ABCDEFGH")
|
110
|
+
assert_equal "ABCDEFGH herp derp baz boo foo ABCDEFGH", res
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_add_ids_on_empty_string
|
114
|
+
res = P.send(:add_ids, "", "ABCDEFGH")
|
115
|
+
assert_equal "ABCDEFGH ABCDEFGH", res
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_add_ids_with_unicode_data
|
119
|
+
res = P.send(:add_ids, "# ø ø ø", "ABCDEFGH")
|
120
|
+
assert_equal "ABCDEFGH # ø ø ø ABCDEFGH", res
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_add_ids_with_starting_slashes
|
124
|
+
res = P.send(:add_ids, '\\# ø ø ø..//', "ABCDEFGH")
|
125
|
+
assert_equal "ABCDEFGH \\# ø ø ø..// ABCDEFGH", res
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_get_fixed_bits_from_header
|
129
|
+
bits = P.send(:get_fixed_bits_from_header, '{"herp": "derp"}')
|
130
|
+
assert_equal "00000000000000000000000000010000", bits
|
131
|
+
end
|
132
|
+
|
133
|
+
def test_get_fixed_bits_from_header_works_with_large_headers
|
134
|
+
bits = P.send(:get_fixed_bits_from_header, '{"herp": "derp"}' * 10000)
|
135
|
+
assert_equal "00000000000000100111000100000000", bits
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_size_check
|
139
|
+
size = "00000000000000000000000000100110"
|
140
|
+
res = P.send(:size_check, size)
|
141
|
+
assert_equal res, true
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_size_check_bad
|
145
|
+
size = "some random thing"
|
146
|
+
res = P.send(:size_check, size)
|
147
|
+
assert_equal res, false
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
class PygmentsLexerTest < Test::Unit::TestCase
|
152
|
+
RUBY_CODE = "#!/usr/bin/ruby\nputs 'foo'"
|
153
|
+
|
154
|
+
def test_lexer_by_mimetype
|
155
|
+
assert_equal 'rb', P.lexer_name_for(:mimetype => 'text/x-ruby')
|
156
|
+
assert_equal 'json', P.lexer_name_for(:mimetype => 'application/json')
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_lexer_by_filename
|
160
|
+
assert_equal 'rb', P.lexer_name_for(:filename => 'test.rb')
|
161
|
+
assert_equal 'scala', P.lexer_name_for(:filename => 'test.scala')
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_lexer_by_name
|
165
|
+
assert_equal 'rb', P.lexer_name_for(:lexer => 'ruby')
|
166
|
+
assert_equal 'python', P.lexer_name_for(:lexer => 'python')
|
167
|
+
assert_equal 'c', P.lexer_name_for(:lexer => 'c')
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_lexer_by_filename_and_content
|
171
|
+
assert_equal 'rb', P.lexer_name_for(RUBY_CODE, :filename => 'test.rb')
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_lexer_by_content
|
175
|
+
assert_equal 'rb', P.lexer_name_for(RUBY_CODE)
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_lexer_by_nothing
|
179
|
+
assert_raise MentosError do
|
180
|
+
P.lexer_name_for(:invalid => true)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
class PygmentsLexerClassTest < Test::Unit::TestCase
|
186
|
+
def test_find
|
187
|
+
assert_equal 'Ruby', P::Lexer['Ruby'].name
|
188
|
+
assert_equal 'Ruby', P::Lexer['ruby'].name
|
189
|
+
assert_equal 'Ruby', P::Lexer['rb'].name
|
190
|
+
assert_equal 'Ruby', P::Lexer['rake'].name
|
191
|
+
assert_equal 'Ruby', P::Lexer['gemspec'].name
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_find_by_name
|
195
|
+
assert_equal P::Lexer['Ruby'], P::Lexer.find_by_name('Ruby')
|
196
|
+
assert_equal P::Lexer['C'], P::Lexer.find_by_name('C')
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_find_by_alias
|
200
|
+
assert_equal P::Lexer['Ruby'], P::Lexer.find_by_alias('rb')
|
201
|
+
assert_equal P::Lexer['Ruby'], P::Lexer.find_by_alias('ruby')
|
202
|
+
assert_equal P::Lexer['Scala'], P::Lexer.find_by_alias('scala')
|
203
|
+
assert_equal P::Lexer['Go'], P::Lexer.find_by_alias('go')
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_find_lexer_by_extname
|
207
|
+
assert_equal P::Lexer['Ruby'], P::Lexer.find_by_extname('.rb')
|
208
|
+
assert_equal P::Lexer['PHP'], P::Lexer.find_by_extname('.php4')
|
209
|
+
assert_equal P::Lexer['PHP'], P::Lexer.find_by_extname('.php5')
|
210
|
+
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.1')
|
211
|
+
assert_equal P::Lexer['Groff'], P::Lexer.find_by_extname('.3')
|
212
|
+
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.c')
|
213
|
+
assert_equal P::Lexer['C'], P::Lexer.find_by_extname('.h')
|
214
|
+
assert_equal P::Lexer['Python'], P::Lexer.find_by_extname('.py')
|
215
|
+
assert_equal P::Lexer['Java'], P::Lexer.find_by_extname('.java')
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_find_lexer_by_mimetype
|
219
|
+
assert_equal P::Lexer['Ruby'], P::Lexer.find_by_mimetype('text/x-ruby')
|
220
|
+
assert_equal P::Lexer['JSON'], P::Lexer.find_by_mimetype('application/json')
|
221
|
+
assert_equal P::Lexer['Python'], P::Lexer.find_by_mimetype('text/x-python')
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
class PygmentsCssTest < Test::Unit::TestCase
|
227
|
+
include Pygments
|
228
|
+
|
229
|
+
def test_css
|
230
|
+
assert_match /^\.err \{/, P.css
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_css_prefix
|
234
|
+
assert_match /^\.highlight \.err \{/, P.css('.highlight')
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_css_options
|
238
|
+
assert_match /^\.codeerr \{/, P.css(:classprefix => 'code')
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_css_prefix_and_options
|
242
|
+
assert_match /^\.mycode \.codeerr \{/, P.css('.mycode', :classprefix => 'code')
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_css_default
|
246
|
+
assert_match '.c { color: #408080; font-style: italic }', P.css
|
247
|
+
end
|
248
|
+
|
249
|
+
def test_css_colorful
|
250
|
+
assert_match '.c { color: #888888 }', P.css(:style => 'colorful')
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
class PygmentsConfigTest < Test::Unit::TestCase
|
255
|
+
def test_styles
|
256
|
+
assert P.styles.include?('colorful')
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_filters
|
260
|
+
assert P.filters.include?('codetagify')
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_lexers
|
264
|
+
list = P.lexers
|
265
|
+
assert list.has_key?('Ruby')
|
266
|
+
assert list['Ruby'][:aliases].include?('duby')
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_formatters
|
270
|
+
list = P.formatters
|
271
|
+
assert list.has_key?('Html')
|
272
|
+
assert list['Html'][:aliases].include?('html')
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.formatters.gitlab
|
4
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
GitLab specific formatter for HTML output.
|
7
|
+
Based on the standard HTML formatter.
|
8
|
+
|
9
|
+
:copyright: Copyright 2012 by the GitLab team (http://www.gitlab.org).
|
10
|
+
:license: BSD, see LICENSE for details.
|
11
|
+
"""
|
12
|
+
|
13
|
+
import os
|
14
|
+
import sys
|
15
|
+
import StringIO
|
16
|
+
|
17
|
+
from pygments.formatter import Formatter
|
18
|
+
from pygments.token import Token, Text, STANDARD_TYPES
|
19
|
+
from pygments.util import get_bool_opt, get_int_opt
|
20
|
+
|
21
|
+
|
22
|
+
__all__ = ['GitlabFormatter']
|
23
|
+
|
24
|
+
|
25
|
+
_escape_html_table = {
|
26
|
+
ord('&'): u'&',
|
27
|
+
ord('<'): u'<',
|
28
|
+
ord('>'): u'>',
|
29
|
+
ord('"'): u'"',
|
30
|
+
ord("'"): u''',
|
31
|
+
}
|
32
|
+
|
33
|
+
def escape_html(text, table=_escape_html_table):
|
34
|
+
"""Escape &, <, > as well as single and double quotes for HTML."""
|
35
|
+
return text.translate(table)
|
36
|
+
|
37
|
+
|
38
|
+
def _get_ttype_class(ttype):
|
39
|
+
fname = STANDARD_TYPES.get(ttype)
|
40
|
+
if fname:
|
41
|
+
return fname
|
42
|
+
aname = ''
|
43
|
+
while fname is None:
|
44
|
+
aname = '-' + ttype[-1] + aname
|
45
|
+
ttype = ttype.parent
|
46
|
+
fname = STANDARD_TYPES.get(ttype)
|
47
|
+
return fname + aname
|
48
|
+
|
49
|
+
|
50
|
+
class GitlabFormatter(Formatter):
|
51
|
+
r"""
|
52
|
+
GitLab specific formatter for HTML output.
|
53
|
+
|
54
|
+
Additional options accepted:
|
55
|
+
|
56
|
+
`show_line_numbers`
|
57
|
+
Determines whether the line number column should be shown (default:
|
58
|
+
``True``).
|
59
|
+
|
60
|
+
`first_line_number`
|
61
|
+
The line number for the first line (default: ``1``).
|
62
|
+
"""
|
63
|
+
|
64
|
+
name = 'GitLab'
|
65
|
+
aliases = ['gitlab']
|
66
|
+
filenames = []
|
67
|
+
|
68
|
+
def __init__(self, **options):
|
69
|
+
Formatter.__init__(self, **options)
|
70
|
+
self.show_line_numbers = get_bool_opt(options, 'show_line_numbers', True)
|
71
|
+
self.first_line_number = abs(get_int_opt(options, 'first_line_number', 1))
|
72
|
+
|
73
|
+
def _wrap_table(self, inner):
|
74
|
+
"""
|
75
|
+
Wrap the whole thing into a table and add line numbers
|
76
|
+
"""
|
77
|
+
dummyoutfile = StringIO.StringIO()
|
78
|
+
lncount = 0
|
79
|
+
for line in inner:
|
80
|
+
lncount += 1
|
81
|
+
dummyoutfile.write(line)
|
82
|
+
|
83
|
+
sln = self.show_line_numbers
|
84
|
+
if sln:
|
85
|
+
fl = self.first_line_number
|
86
|
+
mw = len(str(lncount + fl - 1))
|
87
|
+
|
88
|
+
lines = []
|
89
|
+
for i in range(fl, fl+lncount):
|
90
|
+
lines.append('<a id="L%d" href="#L%d" rel="#L%d">' % (i, i, i) +
|
91
|
+
'<i class="icon-link"></i> %*d' % (mw, i) +
|
92
|
+
'</a>')
|
93
|
+
ls = '\n'.join(lines)
|
94
|
+
|
95
|
+
yield '<table class="lines"><tr>'
|
96
|
+
if sln:
|
97
|
+
yield '<td><pre class="line_numbers">' + ls + '</pre></td>'
|
98
|
+
yield '<td><div class="highlight"><pre>'
|
99
|
+
yield dummyoutfile.getvalue()
|
100
|
+
yield '</pre></div></td></tr></table>'
|
101
|
+
|
102
|
+
def _wrap_code_lines(self, inner):
|
103
|
+
"""
|
104
|
+
Wrap each line in a <div class="line">
|
105
|
+
"""
|
106
|
+
# subtract 1 since we have to increment i *before* yielding
|
107
|
+
i = self.first_line_number - 1
|
108
|
+
|
109
|
+
for line in inner:
|
110
|
+
i += 1
|
111
|
+
yield '<div id="LC%d" class="line">%s</div>' % (i, line)
|
112
|
+
|
113
|
+
def _format_code_lines(self, tokensource):
|
114
|
+
"""
|
115
|
+
Just format the tokens, without any wrapping tags.
|
116
|
+
Yield individual lines.
|
117
|
+
"""
|
118
|
+
# for <span style=""> lookup only
|
119
|
+
escape_table = _escape_html_table
|
120
|
+
|
121
|
+
lspan = ''
|
122
|
+
line = ''
|
123
|
+
for ttype, value in tokensource:
|
124
|
+
cls = _get_ttype_class(ttype)
|
125
|
+
cspan = cls and '<span class="%s">' % cls or ''
|
126
|
+
|
127
|
+
parts = escape_html(value).split('\n')
|
128
|
+
|
129
|
+
# for all but the last line
|
130
|
+
for part in parts[:-1]:
|
131
|
+
if line:
|
132
|
+
if lspan != cspan:
|
133
|
+
line += (lspan and '</span>') + cspan + part + \
|
134
|
+
(cspan and '</span>')
|
135
|
+
else: # both are the same
|
136
|
+
line += part + (lspan and '</span>')
|
137
|
+
yield line
|
138
|
+
line = ''
|
139
|
+
elif part:
|
140
|
+
yield cspan + part + (cspan and '</span>')
|
141
|
+
else:
|
142
|
+
yield '<br/>'
|
143
|
+
# for the last line
|
144
|
+
if line and parts[-1]:
|
145
|
+
if lspan != cspan:
|
146
|
+
line += (lspan and '</span>') + cspan + parts[-1]
|
147
|
+
lspan = cspan
|
148
|
+
else:
|
149
|
+
line += parts[-1]
|
150
|
+
elif parts[-1]:
|
151
|
+
line = cspan + parts[-1]
|
152
|
+
lspan = cspan
|
153
|
+
# else we neither have to open a new span nor set lspan
|
154
|
+
|
155
|
+
if line:
|
156
|
+
yield line + (lspan and '</span>')
|
157
|
+
|
158
|
+
def format_unencoded(self, tokensource, outfile):
|
159
|
+
"""
|
160
|
+
The formatting process uses several nested generators; which of
|
161
|
+
them are used is determined by the user's options.
|
162
|
+
|
163
|
+
Each generator should take at least one argument, ``inner``,
|
164
|
+
and wrap the pieces of text generated by this.
|
165
|
+
"""
|
166
|
+
source = self._format_code_lines(tokensource)
|
167
|
+
source = self._wrap_code_lines(source)
|
168
|
+
source = self._wrap_table(source)
|
169
|
+
|
170
|
+
for piece in source:
|
171
|
+
outfile.write(piece)
|
@@ -0,0 +1,362 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.github
|
4
|
+
~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Custom lexers for GitHub.com
|
7
|
+
|
8
|
+
:copyright: Copyright 2012 by GitHub, Inc
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
import re
|
12
|
+
|
13
|
+
from pygments.lexer import RegexLexer, include, bygroups, using, DelegatingLexer
|
14
|
+
from pygments.token import Text, Name, Number, String, Comment, Punctuation, \
|
15
|
+
Other, Keyword, Operator, Literal
|
16
|
+
|
17
|
+
__all__ = ['Dasm16Lexer', 'PuppetLexer', 'AugeasLexer']
|
18
|
+
|
19
|
+
class Dasm16Lexer(RegexLexer):
|
20
|
+
"""
|
21
|
+
Simple lexer for DCPU-16 Assembly
|
22
|
+
|
23
|
+
Check http://0x10c.com/doc/dcpu-16.txt
|
24
|
+
"""
|
25
|
+
name = 'dasm16'
|
26
|
+
aliases = ['DASM16']
|
27
|
+
filenames = ['*.dasm16', '*.dasm']
|
28
|
+
mimetypes = ['text/x-dasm16']
|
29
|
+
|
30
|
+
INSTRUCTIONS = [
|
31
|
+
'SET',
|
32
|
+
'ADD', 'SUB',
|
33
|
+
'MUL', 'MLI',
|
34
|
+
'DIV', 'DVI',
|
35
|
+
'MOD', 'MDI',
|
36
|
+
'AND', 'BOR', 'XOR',
|
37
|
+
'SHR', 'ASR', 'SHL',
|
38
|
+
'IFB', 'IFC', 'IFE', 'IFN', 'IFG', 'IFA', 'IFL', 'IFU',
|
39
|
+
'ADX', 'SBX',
|
40
|
+
'STI', 'STD',
|
41
|
+
'JSR',
|
42
|
+
'INT', 'IAG', 'IAS', 'RFI', 'IAQ', 'HWN', 'HWQ', 'HWI',
|
43
|
+
]
|
44
|
+
|
45
|
+
REGISTERS = [
|
46
|
+
'A', 'B', 'C',
|
47
|
+
'X', 'Y', 'Z',
|
48
|
+
'I', 'J',
|
49
|
+
'SP', 'PC', 'EX',
|
50
|
+
'POP', 'PEEK', 'PUSH'
|
51
|
+
]
|
52
|
+
|
53
|
+
# Regexes yo
|
54
|
+
char = r'[a-zA-Z$._0-9@]'
|
55
|
+
identifier = r'(?:[a-zA-Z$_]' + char + '*|\.' + char + '+)'
|
56
|
+
number = r'[+-]?(?:0[xX][a-zA-Z0-9]+|\d+)'
|
57
|
+
binary_number = r'0b[01_]+'
|
58
|
+
instruction = r'(?i)(' + '|'.join(INSTRUCTIONS) + ')'
|
59
|
+
single_char = r"'\\?" + char + "'"
|
60
|
+
string = r'"(\\"|[^"])*"'
|
61
|
+
|
62
|
+
def guess_identifier(lexer, match):
|
63
|
+
ident = match.group(0)
|
64
|
+
klass = Name.Variable if ident.upper() in lexer.REGISTERS else Name.Label
|
65
|
+
yield match.start(), klass, ident
|
66
|
+
|
67
|
+
tokens = {
|
68
|
+
'root': [
|
69
|
+
include('whitespace'),
|
70
|
+
(':' + identifier, Name.Label),
|
71
|
+
(identifier + ':', Name.Label),
|
72
|
+
(instruction, Name.Function, 'instruction-args'),
|
73
|
+
(r'\.' + identifier, Name.Function, 'data-args'),
|
74
|
+
(r'[\r\n]+', Text)
|
75
|
+
],
|
76
|
+
|
77
|
+
'numeric' : [
|
78
|
+
(binary_number, Number.Integer),
|
79
|
+
(number, Number.Integer),
|
80
|
+
(single_char, String),
|
81
|
+
],
|
82
|
+
|
83
|
+
'arg' : [
|
84
|
+
(identifier, guess_identifier),
|
85
|
+
include('numeric')
|
86
|
+
],
|
87
|
+
|
88
|
+
'deref' : [
|
89
|
+
(r'\+', Punctuation),
|
90
|
+
(r'\]', Punctuation, '#pop'),
|
91
|
+
include('arg'),
|
92
|
+
include('whitespace')
|
93
|
+
],
|
94
|
+
|
95
|
+
'instruction-line' : [
|
96
|
+
(r'[\r\n]+', Text, '#pop'),
|
97
|
+
(r';.*?$', Comment, '#pop'),
|
98
|
+
include('whitespace')
|
99
|
+
],
|
100
|
+
|
101
|
+
'instruction-args': [
|
102
|
+
(r',', Punctuation),
|
103
|
+
(r'\[', Punctuation, 'deref'),
|
104
|
+
include('arg'),
|
105
|
+
include('instruction-line')
|
106
|
+
],
|
107
|
+
|
108
|
+
'data-args' : [
|
109
|
+
(r',', Punctuation),
|
110
|
+
include('numeric'),
|
111
|
+
(string, String),
|
112
|
+
include('instruction-line')
|
113
|
+
],
|
114
|
+
|
115
|
+
'whitespace': [
|
116
|
+
(r'\n', Text),
|
117
|
+
(r'\s+', Text),
|
118
|
+
(r';.*?\n', Comment)
|
119
|
+
],
|
120
|
+
}
|
121
|
+
|
122
|
+
class PuppetLexer(RegexLexer):
|
123
|
+
name = 'Puppet'
|
124
|
+
aliases = ['puppet']
|
125
|
+
filenames = ['*.pp']
|
126
|
+
|
127
|
+
tokens = {
|
128
|
+
'root': [
|
129
|
+
include('puppet'),
|
130
|
+
],
|
131
|
+
'puppet': [
|
132
|
+
include('comments'),
|
133
|
+
(r'(class)(\s*)(\{)', bygroups(Name.Class, Text, Punctuation), ('type', 'namevar')),
|
134
|
+
(r'(class|define)', Keyword.Declaration, ('block','class_name')),
|
135
|
+
(r'node', Keyword.Declaration, ('block', 'node_name')),
|
136
|
+
(r'elsif', Keyword.Reserved, ('block', 'conditional')),
|
137
|
+
(r'if', Keyword.Reserved, ('block', 'conditional')),
|
138
|
+
(r'unless', Keyword.Reserved, ('block', 'conditional')),
|
139
|
+
(r'(else)(\s*)(\{)', bygroups(Keyword.Reserved, Text, Punctuation), 'block'),
|
140
|
+
(r'case', Keyword.Reserved, ('case', 'conditional')),
|
141
|
+
(r'(::)?([A-Z][\w:]+)+(\s*)(<{1,2}\|)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'spaceinvader'),
|
142
|
+
(r'(::)?([A-Z][\w:]+)+(\s*)(\{)', bygroups(Name.Class, Name.Class, Text, Punctuation), 'type'),
|
143
|
+
(r'(::)?([A-Z][\w:]+)+(\s*)(\[)', bygroups(Name.Class, Name.Class, Text, Punctuation), ('type', 'override_name')),
|
144
|
+
(r'(@{0,2}[\w:]+)(\s*)(\{)(\s*)', bygroups(Name.Class, Text, Punctuation, Text), ('type', 'namevar')),
|
145
|
+
(r'\$(::)?(\w+::)*\w+', Name.Variable, 'var_assign'),
|
146
|
+
(r'(include|require)', Keyword.Namespace, 'include'),
|
147
|
+
(r'import', Keyword.Namespace, 'import'),
|
148
|
+
(r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
|
149
|
+
(r'\s', Text),
|
150
|
+
],
|
151
|
+
'block': [
|
152
|
+
include('puppet'),
|
153
|
+
(r'\}', Text, '#pop'),
|
154
|
+
],
|
155
|
+
'override_name': [
|
156
|
+
include('strings'),
|
157
|
+
include('variables'),
|
158
|
+
(r'\]', Punctuation),
|
159
|
+
(r'\s', Text),
|
160
|
+
(r'\{', Punctuation, '#pop'),
|
161
|
+
],
|
162
|
+
'node_name': [
|
163
|
+
(r'inherits', Keyword.Declaration),
|
164
|
+
(r'[\w\.]+', String),
|
165
|
+
include('strings'),
|
166
|
+
include('variables'),
|
167
|
+
(r',', Punctuation),
|
168
|
+
(r'\s', Text),
|
169
|
+
(r'\{', Punctuation, '#pop'),
|
170
|
+
],
|
171
|
+
'class_name': [
|
172
|
+
(r'inherits', Keyword.Declaration),
|
173
|
+
(r'[\w:]+', Name.Class),
|
174
|
+
(r'\s', Text),
|
175
|
+
(r'\{', Punctuation, '#pop'),
|
176
|
+
(r'\(', Punctuation, 'paramlist'),
|
177
|
+
],
|
178
|
+
'include': [
|
179
|
+
(r'\n', Text, '#pop'),
|
180
|
+
(r'[\w:-]+', Name.Class),
|
181
|
+
include('value'),
|
182
|
+
(r'\s', Text),
|
183
|
+
],
|
184
|
+
'import': [
|
185
|
+
(r'\n', Text, '#pop'),
|
186
|
+
(r'[\/\w\.]+', String),
|
187
|
+
include('value'),
|
188
|
+
(r'\s', Text),
|
189
|
+
],
|
190
|
+
'case': [
|
191
|
+
(r'(default)(:)(\s*)(\{)', bygroups(Keyword.Reserved, Punctuation, Text, Punctuation), 'block'),
|
192
|
+
include('case_values'),
|
193
|
+
(r'(:)(\s*)(\{)', bygroups(Punctuation, Text, Punctuation), 'block'),
|
194
|
+
(r'\s', Text),
|
195
|
+
(r'\}', Punctuation, '#pop'),
|
196
|
+
],
|
197
|
+
'case_values': [
|
198
|
+
include('value'),
|
199
|
+
(r',', Punctuation),
|
200
|
+
],
|
201
|
+
'comments': [
|
202
|
+
(r'\s*#.*\n', Comment.Singleline),
|
203
|
+
],
|
204
|
+
'strings': [
|
205
|
+
(r"'.*?'", String.Single),
|
206
|
+
(r'\w+', String.Symbol),
|
207
|
+
(r'"', String.Double, 'dblstring'),
|
208
|
+
(r'\/.+?\/', String.Regex),
|
209
|
+
],
|
210
|
+
'dblstring': [
|
211
|
+
(r'\$\{.+?\}', String.Interpol),
|
212
|
+
(r'(?:\\(?:[bdefnrstv\'"\$\\/]|[0-7][0-7]?[0-7]?|\^[a-zA-Z]))', String.Escape),
|
213
|
+
(r'[^"\\\$]+', String.Double),
|
214
|
+
(r'\$', String.Double),
|
215
|
+
(r'"', String.Double, '#pop'),
|
216
|
+
],
|
217
|
+
'variables': [
|
218
|
+
(r'\$(::)?(\w+::)*\w+', Name.Variable),
|
219
|
+
],
|
220
|
+
'var_assign': [
|
221
|
+
(r'\[', Punctuation, ('#pop', 'array')),
|
222
|
+
(r'\{', Punctuation, ('#pop', 'hash')),
|
223
|
+
(r'(\s*)(=)(\s*)', bygroups(Text, Operator, Text)),
|
224
|
+
(r'(\(|\))', Punctuation),
|
225
|
+
include('operators'),
|
226
|
+
include('value'),
|
227
|
+
(r'\s', Text, '#pop'),
|
228
|
+
],
|
229
|
+
'booleans': [
|
230
|
+
(r'(true|false)', Literal),
|
231
|
+
],
|
232
|
+
'operators': [
|
233
|
+
(r'(\s*)(==|=~|\*|-|\+|<<|>>|!=|!~|!|>=|<=|<|>|and|or|in)(\s*)', bygroups(Text, Operator, Text)),
|
234
|
+
],
|
235
|
+
'conditional': [
|
236
|
+
include('operators'),
|
237
|
+
include('strings'),
|
238
|
+
include('variables'),
|
239
|
+
(r'\[', Punctuation, 'array'),
|
240
|
+
(r'\(', Punctuation, 'conditional'),
|
241
|
+
(r'\{', Punctuation, '#pop'),
|
242
|
+
(r'\)', Punctuation, '#pop'),
|
243
|
+
(r'\s', Text),
|
244
|
+
],
|
245
|
+
'spaceinvader': [
|
246
|
+
include('operators'),
|
247
|
+
include('strings'),
|
248
|
+
include('variables'),
|
249
|
+
(r'\[', Punctuation, 'array'),
|
250
|
+
(r'\(', Punctuation, 'conditional'),
|
251
|
+
(r'\s', Text),
|
252
|
+
(r'\|>{1,2}', Punctuation, '#pop'),
|
253
|
+
],
|
254
|
+
'namevar': [
|
255
|
+
include('value'),
|
256
|
+
(r'\[', Punctuation, 'array'),
|
257
|
+
(r'\s', Text),
|
258
|
+
(r':', Punctuation, '#pop'),
|
259
|
+
(r'\}', Punctuation, '#pop'),
|
260
|
+
],
|
261
|
+
'function': [
|
262
|
+
(r'\[', Punctuation, 'array'),
|
263
|
+
include('value'),
|
264
|
+
(r',', Punctuation),
|
265
|
+
(r'\s', Text),
|
266
|
+
(r'\)', Punctuation, '#pop'),
|
267
|
+
],
|
268
|
+
'paramlist': [
|
269
|
+
include('value'),
|
270
|
+
(r'=', Punctuation),
|
271
|
+
(r',', Punctuation),
|
272
|
+
(r'\s', Text),
|
273
|
+
(r'\[', Punctuation, 'array'),
|
274
|
+
(r'\)', Punctuation, '#pop'),
|
275
|
+
],
|
276
|
+
'type': [
|
277
|
+
(r'(\w+)(\s*)(=>)(\s*)', bygroups(Name.Tag, Text, Punctuation, Text), 'param_value'),
|
278
|
+
(r'\}', Punctuation, '#pop'),
|
279
|
+
(r'\s', Text),
|
280
|
+
include('comments'),
|
281
|
+
(r'', Text, 'namevar'),
|
282
|
+
],
|
283
|
+
'value': [
|
284
|
+
(r'[\d\.]', Number),
|
285
|
+
(r'([A-Z][\w:]+)+(\[)', bygroups(Name.Class, Punctuation), 'array'),
|
286
|
+
(r'(\w+)(\()', bygroups(Name.Function, Punctuation), 'function'),
|
287
|
+
include('strings'),
|
288
|
+
include('variables'),
|
289
|
+
include('comments'),
|
290
|
+
include('booleans'),
|
291
|
+
(r'(\s*)(\?)(\s*)(\{)', bygroups(Text, Punctuation, Text, Punctuation), 'selector'),
|
292
|
+
(r'\{', Punctuation, 'hash'),
|
293
|
+
],
|
294
|
+
'selector': [
|
295
|
+
(r'default', Keyword.Reserved),
|
296
|
+
include('value'),
|
297
|
+
(r'=>', Punctuation),
|
298
|
+
(r',', Punctuation),
|
299
|
+
(r'\s', Text),
|
300
|
+
(r'\}', Punctuation, '#pop'),
|
301
|
+
],
|
302
|
+
'param_value': [
|
303
|
+
include('value'),
|
304
|
+
(r'\[', Punctuation, 'array'),
|
305
|
+
(r',', Punctuation, '#pop'),
|
306
|
+
(r';', Punctuation, '#pop'),
|
307
|
+
(r'\s', Text, '#pop'),
|
308
|
+
(r'', Text, '#pop'),
|
309
|
+
],
|
310
|
+
'array': [
|
311
|
+
include('value'),
|
312
|
+
(r'\[', Punctuation, 'array'),
|
313
|
+
(r',', Punctuation),
|
314
|
+
(r'\s', Text),
|
315
|
+
(r'\]', Punctuation, '#pop'),
|
316
|
+
],
|
317
|
+
'hash': [
|
318
|
+
include('value'),
|
319
|
+
(r'\s', Text),
|
320
|
+
(r'=>', Punctuation),
|
321
|
+
(r',', Punctuation),
|
322
|
+
(r'\}', Punctuation, '#pop'),
|
323
|
+
],
|
324
|
+
}
|
325
|
+
|
326
|
+
class AugeasLexer(RegexLexer):
|
327
|
+
name = 'Augeas'
|
328
|
+
aliases = ['augeas']
|
329
|
+
filenames = ['*.aug']
|
330
|
+
|
331
|
+
tokens = {
|
332
|
+
'root': [
|
333
|
+
(r'(module)(\s*)([^\s=]+)', bygroups(Keyword.Namespace, Text, Name.Namespace)),
|
334
|
+
(r'(let)(\s*)([^\s=]+)', bygroups(Keyword.Declaration, Text, Name.Variable)),
|
335
|
+
(r'(del|store|value|counter|seq|key|label|autoload|incl|excl|transform|test|get|put)(\s+)', bygroups(Name.Builtin, Text)),
|
336
|
+
(r'(\()([^\:]+)(\:)(unit|string|regexp|lens|tree|filter)(\))', bygroups(Punctuation, Name.Variable, Punctuation, Keyword.Type, Punctuation)),
|
337
|
+
(r'\(\*', Comment.Multiline, 'comment'),
|
338
|
+
(r'[\+=\|\.\*\;\?-]', Operator),
|
339
|
+
(r'[\[\]\(\)\{\}]', Operator),
|
340
|
+
(r'"', String.Double, 'string'),
|
341
|
+
(r'\/', String.Regex, 'regex'),
|
342
|
+
(r'([A-Z]\w*)(\.)(\w+)', bygroups(Name.Namespace, Punctuation, Name.Variable)),
|
343
|
+
(r'.', Name.Variable),
|
344
|
+
(r'\s', Text),
|
345
|
+
],
|
346
|
+
'string': [
|
347
|
+
(r'\\.', String.Escape),
|
348
|
+
(r'[^"]', String.Double),
|
349
|
+
(r'"', String.Double, '#pop'),
|
350
|
+
],
|
351
|
+
'regex': [
|
352
|
+
(r'\\.', String.Escape),
|
353
|
+
(r'[^\/]', String.Regex),
|
354
|
+
(r'\/', String.Regex, '#pop'),
|
355
|
+
],
|
356
|
+
'comment': [
|
357
|
+
(r'[^*\)]', Comment.Multiline),
|
358
|
+
(r'\(\*', Comment.Multiline, '#push'),
|
359
|
+
(r'\*\)', Comment.Multiline, '#pop'),
|
360
|
+
(r'[\*\)]', Comment.Multiline)
|
361
|
+
],
|
362
|
+
}
|