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,1072 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
pygments.lexers.math
|
4
|
+
~~~~~~~~~~~~~~~~~~~~
|
5
|
+
|
6
|
+
Lexers for math languages.
|
7
|
+
|
8
|
+
:copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS.
|
9
|
+
:license: BSD, see LICENSE for details.
|
10
|
+
"""
|
11
|
+
|
12
|
+
import re
|
13
|
+
|
14
|
+
from pygments.lexer import Lexer, RegexLexer, bygroups, include, \
|
15
|
+
combined, do_insertions
|
16
|
+
from pygments.token import Comment, String, Punctuation, Keyword, Name, \
|
17
|
+
Operator, Number, Text, Generic
|
18
|
+
|
19
|
+
from pygments.lexers.agile import PythonLexer
|
20
|
+
from pygments.lexers import _scilab_builtins
|
21
|
+
|
22
|
+
__all__ = ['JuliaLexer', 'JuliaConsoleLexer', 'MuPADLexer', 'MatlabLexer',
|
23
|
+
'MatlabSessionLexer', 'OctaveLexer', 'ScilabLexer', 'NumPyLexer',
|
24
|
+
'RConsoleLexer', 'SLexer']
|
25
|
+
|
26
|
+
|
27
|
+
class JuliaLexer(RegexLexer):
|
28
|
+
name = 'Julia'
|
29
|
+
aliases = ['julia','jl']
|
30
|
+
filenames = ['*.jl']
|
31
|
+
mimetypes = ['text/x-julia','application/x-julia']
|
32
|
+
|
33
|
+
builtins = [
|
34
|
+
'exit','whos','edit','load','is','isa','isequal','typeof','tuple',
|
35
|
+
'ntuple','uid','hash','finalizer','convert','promote','subtype',
|
36
|
+
'typemin','typemax','realmin','realmax','sizeof','eps','promote_type',
|
37
|
+
'method_exists','applicable','invoke','dlopen','dlsym','system',
|
38
|
+
'error','throw','assert','new','Inf','Nan','pi','im',
|
39
|
+
]
|
40
|
+
|
41
|
+
tokens = {
|
42
|
+
'root': [
|
43
|
+
(r'\n', Text),
|
44
|
+
(r'[^\S\n]+', Text),
|
45
|
+
(r'#.*$', Comment),
|
46
|
+
(r'[]{}:(),;[@]', Punctuation),
|
47
|
+
(r'\\\n', Text),
|
48
|
+
(r'\\', Text),
|
49
|
+
|
50
|
+
# keywords
|
51
|
+
(r'(begin|while|for|in|return|break|continue|'
|
52
|
+
r'macro|quote|let|if|elseif|else|try|catch|end|'
|
53
|
+
r'bitstype|ccall|do)\b', Keyword),
|
54
|
+
(r'(local|global|const)\b', Keyword.Declaration),
|
55
|
+
(r'(module|import|export)\b', Keyword.Reserved),
|
56
|
+
(r'(Bool|Int|Int8|Int16|Int32|Int64|Uint|Uint8|Uint16|Uint32|Uint64'
|
57
|
+
r'|Float32|Float64|Complex64|Complex128|Any|Nothing|None)\b',
|
58
|
+
Keyword.Type),
|
59
|
+
|
60
|
+
# functions
|
61
|
+
(r'(function)((?:\s|\\\s)+)',
|
62
|
+
bygroups(Keyword,Name.Function), 'funcname'),
|
63
|
+
|
64
|
+
# types
|
65
|
+
(r'(type|typealias|abstract)((?:\s|\\\s)+)',
|
66
|
+
bygroups(Keyword,Name.Class), 'typename'),
|
67
|
+
|
68
|
+
# operators
|
69
|
+
(r'==|!=|<=|>=|->|&&|\|\||::|<:|[-~+/*%=<>&^|.?!$]', Operator),
|
70
|
+
(r'\.\*|\.\^|\.\\|\.\/|\\', Operator),
|
71
|
+
|
72
|
+
# builtins
|
73
|
+
('(' + '|'.join(builtins) + r')\b', Name.Builtin),
|
74
|
+
|
75
|
+
# backticks
|
76
|
+
(r'`(?s).*?`', String.Backtick),
|
77
|
+
|
78
|
+
# chars
|
79
|
+
(r"'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'", String.Char),
|
80
|
+
|
81
|
+
# try to match trailing transpose
|
82
|
+
(r'(?<=[.\w\)\]])\'', Operator),
|
83
|
+
|
84
|
+
# strings
|
85
|
+
(r'(?:[IL])"', String, 'string'),
|
86
|
+
(r'[E]?"', String, combined('stringescape', 'string')),
|
87
|
+
|
88
|
+
# names
|
89
|
+
(r'@[a-zA-Z0-9_.]+', Name.Decorator),
|
90
|
+
(r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
91
|
+
|
92
|
+
# numbers
|
93
|
+
(r'(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
|
94
|
+
(r'\d+[eE][+-]?[0-9]+', Number.Float),
|
95
|
+
(r'0[0-7]+', Number.Oct),
|
96
|
+
(r'0[xX][a-fA-F0-9]+', Number.Hex),
|
97
|
+
(r'\d+', Number.Integer)
|
98
|
+
],
|
99
|
+
|
100
|
+
'funcname': [
|
101
|
+
('[a-zA-Z_][a-zA-Z0-9_]*', Name.Function, '#pop'),
|
102
|
+
('\([^\s\w{]{1,2}\)', Operator, '#pop'),
|
103
|
+
('[^\s\w{]{1,2}', Operator, '#pop'),
|
104
|
+
],
|
105
|
+
|
106
|
+
'typename': [
|
107
|
+
('[a-zA-Z_][a-zA-Z0-9_]*', Name.Class, '#pop')
|
108
|
+
],
|
109
|
+
|
110
|
+
'stringescape': [
|
111
|
+
(r'\\([\\abfnrtv"\']|\n|N{.*?}|u[a-fA-F0-9]{4}|'
|
112
|
+
r'U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})', String.Escape)
|
113
|
+
],
|
114
|
+
|
115
|
+
'string': [
|
116
|
+
(r'"', String, '#pop'),
|
117
|
+
(r'\\\\|\\"|\\\n', String.Escape), # included here for raw strings
|
118
|
+
(r'\$(\([a-zA-Z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?',
|
119
|
+
String.Interpol),
|
120
|
+
(r'[^\\"$]+', String),
|
121
|
+
# quotes, dollar signs, and backslashes must be parsed one at a time
|
122
|
+
(r'["\\]', String),
|
123
|
+
# unhandled string formatting sign
|
124
|
+
(r'\$', String)
|
125
|
+
],
|
126
|
+
}
|
127
|
+
|
128
|
+
def analyse_text(text):
|
129
|
+
return shebang_matches(text, r'julia')
|
130
|
+
|
131
|
+
|
132
|
+
line_re = re.compile('.*?\n')
|
133
|
+
|
134
|
+
class JuliaConsoleLexer(Lexer):
|
135
|
+
"""
|
136
|
+
For Julia console sessions. Modeled after MatlabSessionLexer.
|
137
|
+
"""
|
138
|
+
name = 'Julia console'
|
139
|
+
aliases = ['jlcon']
|
140
|
+
|
141
|
+
def get_tokens_unprocessed(self, text):
|
142
|
+
jllexer = JuliaLexer(**self.options)
|
143
|
+
|
144
|
+
curcode = ''
|
145
|
+
insertions = []
|
146
|
+
|
147
|
+
for match in line_re.finditer(text):
|
148
|
+
line = match.group()
|
149
|
+
|
150
|
+
if line.startswith('julia>'):
|
151
|
+
insertions.append((len(curcode),
|
152
|
+
[(0, Generic.Prompt, line[:3])]))
|
153
|
+
curcode += line[3:]
|
154
|
+
|
155
|
+
elif line.startswith(' '):
|
156
|
+
|
157
|
+
idx = len(curcode)
|
158
|
+
|
159
|
+
# without is showing error on same line as before...?
|
160
|
+
line = "\n" + line
|
161
|
+
token = (0, Generic.Traceback, line)
|
162
|
+
insertions.append((idx, [token]))
|
163
|
+
|
164
|
+
else:
|
165
|
+
if curcode:
|
166
|
+
for item in do_insertions(
|
167
|
+
insertions, jllexer.get_tokens_unprocessed(curcode)):
|
168
|
+
yield item
|
169
|
+
curcode = ''
|
170
|
+
insertions = []
|
171
|
+
|
172
|
+
yield match.start(), Generic.Output, line
|
173
|
+
|
174
|
+
if curcode: # or item:
|
175
|
+
for item in do_insertions(
|
176
|
+
insertions, jllexer.get_tokens_unprocessed(curcode)):
|
177
|
+
yield item
|
178
|
+
|
179
|
+
|
180
|
+
class MuPADLexer(RegexLexer):
|
181
|
+
"""
|
182
|
+
A `MuPAD <http://www.mupad.com>`_ lexer.
|
183
|
+
Contributed by Christopher Creutzig <christopher@creutzig.de>.
|
184
|
+
|
185
|
+
*New in Pygments 0.8.*
|
186
|
+
"""
|
187
|
+
name = 'MuPAD'
|
188
|
+
aliases = ['mupad']
|
189
|
+
filenames = ['*.mu']
|
190
|
+
|
191
|
+
tokens = {
|
192
|
+
'root' : [
|
193
|
+
(r'//.*?$', Comment.Single),
|
194
|
+
(r'/\*', Comment.Multiline, 'comment'),
|
195
|
+
(r'"(?:[^"\\]|\\.)*"', String),
|
196
|
+
(r'\(|\)|\[|\]|\{|\}', Punctuation),
|
197
|
+
(r'''(?x)\b(?:
|
198
|
+
next|break|end|
|
199
|
+
axiom|end_axiom|category|end_category|domain|end_domain|inherits|
|
200
|
+
if|%if|then|elif|else|end_if|
|
201
|
+
case|of|do|otherwise|end_case|
|
202
|
+
while|end_while|
|
203
|
+
repeat|until|end_repeat|
|
204
|
+
for|from|to|downto|step|end_for|
|
205
|
+
proc|local|option|save|begin|end_proc|
|
206
|
+
delete|frame
|
207
|
+
)\b''', Keyword),
|
208
|
+
(r'''(?x)\b(?:
|
209
|
+
DOM_ARRAY|DOM_BOOL|DOM_COMPLEX|DOM_DOMAIN|DOM_EXEC|DOM_EXPR|
|
210
|
+
DOM_FAIL|DOM_FLOAT|DOM_FRAME|DOM_FUNC_ENV|DOM_HFARRAY|DOM_IDENT|
|
211
|
+
DOM_INT|DOM_INTERVAL|DOM_LIST|DOM_NIL|DOM_NULL|DOM_POLY|DOM_PROC|
|
212
|
+
DOM_PROC_ENV|DOM_RAT|DOM_SET|DOM_STRING|DOM_TABLE|DOM_VAR
|
213
|
+
)\b''', Name.Class),
|
214
|
+
(r'''(?x)\b(?:
|
215
|
+
PI|EULER|E|CATALAN|
|
216
|
+
NIL|FAIL|undefined|infinity|
|
217
|
+
TRUE|FALSE|UNKNOWN
|
218
|
+
)\b''',
|
219
|
+
Name.Constant),
|
220
|
+
(r'\b(?:dom|procname)\b', Name.Builtin.Pseudo),
|
221
|
+
(r'\.|,|:|;|=|\+|-|\*|/|\^|@|>|<|\$|\||!|\'|%|~=', Operator),
|
222
|
+
(r'''(?x)\b(?:
|
223
|
+
and|or|not|xor|
|
224
|
+
assuming|
|
225
|
+
div|mod|
|
226
|
+
union|minus|intersect|in|subset
|
227
|
+
)\b''',
|
228
|
+
Operator.Word),
|
229
|
+
(r'\b(?:I|RDN_INF|RD_NINF|RD_NAN)\b', Number),
|
230
|
+
#(r'\b(?:adt|linalg|newDomain|hold)\b', Name.Builtin),
|
231
|
+
(r'''(?x)
|
232
|
+
((?:[a-zA-Z_#][a-zA-Z_#0-9]*|`[^`]*`)
|
233
|
+
(?:::[a-zA-Z_#][a-zA-Z_#0-9]*|`[^`]*`)*)(\s*)([(])''',
|
234
|
+
bygroups(Name.Function, Text, Punctuation)),
|
235
|
+
(r'''(?x)
|
236
|
+
(?:[a-zA-Z_#][a-zA-Z_#0-9]*|`[^`]*`)
|
237
|
+
(?:::[a-zA-Z_#][a-zA-Z_#0-9]*|`[^`]*`)*''', Name.Variable),
|
238
|
+
(r'[0-9]+(?:\.[0-9]*)?(?:e[0-9]+)?', Number),
|
239
|
+
(r'\.[0-9]+(?:e[0-9]+)?', Number),
|
240
|
+
(r'.', Text)
|
241
|
+
],
|
242
|
+
'comment' : [
|
243
|
+
(r'[^*/]', Comment.Multiline),
|
244
|
+
(r'/\*', Comment.Multiline, '#push'),
|
245
|
+
(r'\*/', Comment.Multiline, '#pop'),
|
246
|
+
(r'[*/]', Comment.Multiline)
|
247
|
+
]
|
248
|
+
}
|
249
|
+
|
250
|
+
|
251
|
+
class MatlabLexer(RegexLexer):
|
252
|
+
"""
|
253
|
+
For Matlab source code.
|
254
|
+
Contributed by Ken Schutte <kschutte@csail.mit.edu>.
|
255
|
+
|
256
|
+
*New in Pygments 0.10.*
|
257
|
+
"""
|
258
|
+
name = 'Matlab'
|
259
|
+
aliases = ['matlab']
|
260
|
+
filenames = ['*.m']
|
261
|
+
mimetypes = ['text/matlab']
|
262
|
+
|
263
|
+
#
|
264
|
+
# These lists are generated automatically.
|
265
|
+
# Run the following in bash shell:
|
266
|
+
#
|
267
|
+
# for f in elfun specfun elmat; do
|
268
|
+
# echo -n "$f = "
|
269
|
+
# matlab -nojvm -r "help $f;exit;" | perl -ne \
|
270
|
+
# 'push(@c,$1) if /^ (\w+)\s+-/; END {print q{["}.join(q{","},@c).qq{"]\n};}'
|
271
|
+
# done
|
272
|
+
#
|
273
|
+
# elfun: Elementary math functions
|
274
|
+
# specfun: Special Math functions
|
275
|
+
# elmat: Elementary matrices and matrix manipulation
|
276
|
+
#
|
277
|
+
# taken from Matlab version 7.4.0.336 (R2007a)
|
278
|
+
#
|
279
|
+
elfun = ["sin","sind","sinh","asin","asind","asinh","cos","cosd","cosh",
|
280
|
+
"acos","acosd","acosh","tan","tand","tanh","atan","atand","atan2",
|
281
|
+
"atanh","sec","secd","sech","asec","asecd","asech","csc","cscd",
|
282
|
+
"csch","acsc","acscd","acsch","cot","cotd","coth","acot","acotd",
|
283
|
+
"acoth","hypot","exp","expm1","log","log1p","log10","log2","pow2",
|
284
|
+
"realpow","reallog","realsqrt","sqrt","nthroot","nextpow2","abs",
|
285
|
+
"angle","complex","conj","imag","real","unwrap","isreal","cplxpair",
|
286
|
+
"fix","floor","ceil","round","mod","rem","sign"]
|
287
|
+
specfun = ["airy","besselj","bessely","besselh","besseli","besselk","beta",
|
288
|
+
"betainc","betaln","ellipj","ellipke","erf","erfc","erfcx",
|
289
|
+
"erfinv","expint","gamma","gammainc","gammaln","psi","legendre",
|
290
|
+
"cross","dot","factor","isprime","primes","gcd","lcm","rat",
|
291
|
+
"rats","perms","nchoosek","factorial","cart2sph","cart2pol",
|
292
|
+
"pol2cart","sph2cart","hsv2rgb","rgb2hsv"]
|
293
|
+
elmat = ["zeros","ones","eye","repmat","rand","randn","linspace","logspace",
|
294
|
+
"freqspace","meshgrid","accumarray","size","length","ndims","numel",
|
295
|
+
"disp","isempty","isequal","isequalwithequalnans","cat","reshape",
|
296
|
+
"diag","blkdiag","tril","triu","fliplr","flipud","flipdim","rot90",
|
297
|
+
"find","end","sub2ind","ind2sub","bsxfun","ndgrid","permute",
|
298
|
+
"ipermute","shiftdim","circshift","squeeze","isscalar","isvector",
|
299
|
+
"ans","eps","realmax","realmin","pi","i","inf","nan","isnan",
|
300
|
+
"isinf","isfinite","j","why","compan","gallery","hadamard","hankel",
|
301
|
+
"hilb","invhilb","magic","pascal","rosser","toeplitz","vander",
|
302
|
+
"wilkinson"]
|
303
|
+
|
304
|
+
tokens = {
|
305
|
+
'root': [
|
306
|
+
# line starting with '!' is sent as a system command. not sure what
|
307
|
+
# label to use...
|
308
|
+
(r'^!.*', String.Other),
|
309
|
+
(r'%.*$', Comment),
|
310
|
+
(r'^\s*function', Keyword, 'deffunc'),
|
311
|
+
|
312
|
+
# from 'iskeyword' on version 7.11 (R2010):
|
313
|
+
(r'(break|case|catch|classdef|continue|else|elseif|end|enumerated|'
|
314
|
+
r'events|for|function|global|if|methods|otherwise|parfor|'
|
315
|
+
r'persistent|properties|return|spmd|switch|try|while)\b', Keyword),
|
316
|
+
|
317
|
+
("(" + "|".join(elfun+specfun+elmat) + r')\b', Name.Builtin),
|
318
|
+
|
319
|
+
# operators:
|
320
|
+
(r'-|==|~=|<|>|<=|>=|&&|&|~|\|\|?', Operator),
|
321
|
+
# operators requiring escape for re:
|
322
|
+
(r'\.\*|\*|\+|\.\^|\.\\|\.\/|\/|\\', Operator),
|
323
|
+
|
324
|
+
# punctuation:
|
325
|
+
(r'\[|\]|\(|\)|\{|\}|:|@|\.|,', Punctuation),
|
326
|
+
(r'=|:|;', Punctuation),
|
327
|
+
|
328
|
+
# quote can be transpose, instead of string:
|
329
|
+
# (not great, but handles common cases...)
|
330
|
+
(r'(?<=[\w\)\]])\'', Operator),
|
331
|
+
|
332
|
+
(r'(?<![\w\)\]])\'', String, 'string'),
|
333
|
+
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
334
|
+
(r'.', Text),
|
335
|
+
],
|
336
|
+
'string': [
|
337
|
+
(r'[^\']*\'', String, '#pop')
|
338
|
+
],
|
339
|
+
'deffunc': [
|
340
|
+
(r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
341
|
+
bygroups(Text.Whitespace, Text, Text.Whitespace, Punctuation,
|
342
|
+
Text.Whitespace, Name.Function, Punctuation, Text,
|
343
|
+
Punctuation, Text.Whitespace), '#pop'),
|
344
|
+
],
|
345
|
+
}
|
346
|
+
|
347
|
+
def analyse_text(text):
|
348
|
+
if re.match('^\s*%', text, re.M): # comment
|
349
|
+
return 0.9
|
350
|
+
elif re.match('^!\w+', text, re.M): # system cmd
|
351
|
+
return 0.9
|
352
|
+
return 0.1
|
353
|
+
|
354
|
+
|
355
|
+
line_re = re.compile('.*?\n')
|
356
|
+
|
357
|
+
class MatlabSessionLexer(Lexer):
|
358
|
+
"""
|
359
|
+
For Matlab sessions. Modeled after PythonConsoleLexer.
|
360
|
+
Contributed by Ken Schutte <kschutte@csail.mit.edu>.
|
361
|
+
|
362
|
+
*New in Pygments 0.10.*
|
363
|
+
"""
|
364
|
+
name = 'Matlab session'
|
365
|
+
aliases = ['matlabsession']
|
366
|
+
|
367
|
+
def get_tokens_unprocessed(self, text):
|
368
|
+
mlexer = MatlabLexer(**self.options)
|
369
|
+
|
370
|
+
curcode = ''
|
371
|
+
insertions = []
|
372
|
+
|
373
|
+
for match in line_re.finditer(text):
|
374
|
+
line = match.group()
|
375
|
+
|
376
|
+
if line.startswith('>>'):
|
377
|
+
insertions.append((len(curcode),
|
378
|
+
[(0, Generic.Prompt, line[:3])]))
|
379
|
+
curcode += line[3:]
|
380
|
+
|
381
|
+
elif line.startswith('???'):
|
382
|
+
|
383
|
+
idx = len(curcode)
|
384
|
+
|
385
|
+
# without is showing error on same line as before...?
|
386
|
+
line = "\n" + line
|
387
|
+
token = (0, Generic.Traceback, line)
|
388
|
+
insertions.append((idx, [token]))
|
389
|
+
|
390
|
+
else:
|
391
|
+
if curcode:
|
392
|
+
for item in do_insertions(
|
393
|
+
insertions, mlexer.get_tokens_unprocessed(curcode)):
|
394
|
+
yield item
|
395
|
+
curcode = ''
|
396
|
+
insertions = []
|
397
|
+
|
398
|
+
yield match.start(), Generic.Output, line
|
399
|
+
|
400
|
+
if curcode: # or item:
|
401
|
+
for item in do_insertions(
|
402
|
+
insertions, mlexer.get_tokens_unprocessed(curcode)):
|
403
|
+
yield item
|
404
|
+
|
405
|
+
|
406
|
+
class OctaveLexer(RegexLexer):
|
407
|
+
"""
|
408
|
+
For GNU Octave source code.
|
409
|
+
|
410
|
+
*New in Pygments 1.5.*
|
411
|
+
"""
|
412
|
+
name = 'Octave'
|
413
|
+
aliases = ['octave']
|
414
|
+
filenames = ['*.m']
|
415
|
+
mimetypes = ['text/octave']
|
416
|
+
|
417
|
+
# These lists are generated automatically.
|
418
|
+
# Run the following in bash shell:
|
419
|
+
#
|
420
|
+
# First dump all of the Octave manual into a plain text file:
|
421
|
+
#
|
422
|
+
# $ info octave --subnodes -o octave-manual
|
423
|
+
#
|
424
|
+
# Now grep through it:
|
425
|
+
|
426
|
+
# for i in \
|
427
|
+
# "Built-in Function" "Command" "Function File" \
|
428
|
+
# "Loadable Function" "Mapping Function";
|
429
|
+
# do
|
430
|
+
# perl -e '@name = qw('"$i"');
|
431
|
+
# print lc($name[0]),"_kw = [\n"';
|
432
|
+
#
|
433
|
+
# perl -n -e 'print "\"$1\",\n" if /-- '"$i"': .* (\w*) \(/;' \
|
434
|
+
# octave-manual | sort | uniq ;
|
435
|
+
# echo "]" ;
|
436
|
+
# echo;
|
437
|
+
# done
|
438
|
+
|
439
|
+
# taken from Octave Mercurial changeset 8cc154f45e37 (30-jan-2011)
|
440
|
+
|
441
|
+
builtin_kw = [ "addlistener", "addpath", "addproperty", "all",
|
442
|
+
"and", "any", "argnames", "argv", "assignin",
|
443
|
+
"atexit", "autoload",
|
444
|
+
"available_graphics_toolkits", "beep_on_error",
|
445
|
+
"bitand", "bitmax", "bitor", "bitshift", "bitxor",
|
446
|
+
"cat", "cell", "cellstr", "char", "class", "clc",
|
447
|
+
"columns", "command_line_path",
|
448
|
+
"completion_append_char", "completion_matches",
|
449
|
+
"complex", "confirm_recursive_rmdir", "cputime",
|
450
|
+
"crash_dumps_octave_core", "ctranspose", "cumprod",
|
451
|
+
"cumsum", "debug_on_error", "debug_on_interrupt",
|
452
|
+
"debug_on_warning", "default_save_options",
|
453
|
+
"dellistener", "diag", "diff", "disp",
|
454
|
+
"doc_cache_file", "do_string_escapes", "double",
|
455
|
+
"drawnow", "e", "echo_executing_commands", "eps",
|
456
|
+
"eq", "errno", "errno_list", "error", "eval",
|
457
|
+
"evalin", "exec", "exist", "exit", "eye", "false",
|
458
|
+
"fclear", "fclose", "fcntl", "fdisp", "feof",
|
459
|
+
"ferror", "feval", "fflush", "fgetl", "fgets",
|
460
|
+
"fieldnames", "file_in_loadpath", "file_in_path",
|
461
|
+
"filemarker", "filesep", "find_dir_in_path",
|
462
|
+
"fixed_point_format", "fnmatch", "fopen", "fork",
|
463
|
+
"formula", "fprintf", "fputs", "fread", "freport",
|
464
|
+
"frewind", "fscanf", "fseek", "fskipl", "ftell",
|
465
|
+
"functions", "fwrite", "ge", "genpath", "get",
|
466
|
+
"getegid", "getenv", "geteuid", "getgid",
|
467
|
+
"getpgrp", "getpid", "getppid", "getuid", "glob",
|
468
|
+
"gt", "gui_mode", "history_control",
|
469
|
+
"history_file", "history_size",
|
470
|
+
"history_timestamp_format_string", "home",
|
471
|
+
"horzcat", "hypot", "ifelse",
|
472
|
+
"ignore_function_time_stamp", "inferiorto",
|
473
|
+
"info_file", "info_program", "inline", "input",
|
474
|
+
"intmax", "intmin", "ipermute",
|
475
|
+
"is_absolute_filename", "isargout", "isbool",
|
476
|
+
"iscell", "iscellstr", "ischar", "iscomplex",
|
477
|
+
"isempty", "isfield", "isfloat", "isglobal",
|
478
|
+
"ishandle", "isieee", "isindex", "isinteger",
|
479
|
+
"islogical", "ismatrix", "ismethod", "isnull",
|
480
|
+
"isnumeric", "isobject", "isreal",
|
481
|
+
"is_rooted_relative_filename", "issorted",
|
482
|
+
"isstruct", "isvarname", "kbhit", "keyboard",
|
483
|
+
"kill", "lasterr", "lasterror", "lastwarn",
|
484
|
+
"ldivide", "le", "length", "link", "linspace",
|
485
|
+
"logical", "lstat", "lt", "make_absolute_filename",
|
486
|
+
"makeinfo_program", "max_recursion_depth", "merge",
|
487
|
+
"methods", "mfilename", "minus", "mislocked",
|
488
|
+
"mkdir", "mkfifo", "mkstemp", "mldivide", "mlock",
|
489
|
+
"mouse_wheel_zoom", "mpower", "mrdivide", "mtimes",
|
490
|
+
"munlock", "nargin", "nargout",
|
491
|
+
"native_float_format", "ndims", "ne", "nfields",
|
492
|
+
"nnz", "norm", "not", "numel", "nzmax",
|
493
|
+
"octave_config_info", "octave_core_file_limit",
|
494
|
+
"octave_core_file_name",
|
495
|
+
"octave_core_file_options", "ones", "or",
|
496
|
+
"output_max_field_width", "output_precision",
|
497
|
+
"page_output_immediately", "page_screen_output",
|
498
|
+
"path", "pathsep", "pause", "pclose", "permute",
|
499
|
+
"pi", "pipe", "plus", "popen", "power",
|
500
|
+
"print_empty_dimensions", "printf",
|
501
|
+
"print_struct_array_contents", "prod",
|
502
|
+
"program_invocation_name", "program_name",
|
503
|
+
"putenv", "puts", "pwd", "quit", "rats", "rdivide",
|
504
|
+
"readdir", "readlink", "read_readline_init_file",
|
505
|
+
"realmax", "realmin", "rehash", "rename",
|
506
|
+
"repelems", "re_read_readline_init_file", "reset",
|
507
|
+
"reshape", "resize", "restoredefaultpath",
|
508
|
+
"rethrow", "rmdir", "rmfield", "rmpath", "rows",
|
509
|
+
"save_header_format_string", "save_precision",
|
510
|
+
"saving_history", "scanf", "set", "setenv",
|
511
|
+
"shell_cmd", "sighup_dumps_octave_core",
|
512
|
+
"sigterm_dumps_octave_core", "silent_functions",
|
513
|
+
"single", "size", "size_equal", "sizemax",
|
514
|
+
"sizeof", "sleep", "source", "sparse_auto_mutate",
|
515
|
+
"split_long_rows", "sprintf", "squeeze", "sscanf",
|
516
|
+
"stat", "stderr", "stdin", "stdout", "strcmp",
|
517
|
+
"strcmpi", "string_fill_char", "strncmp",
|
518
|
+
"strncmpi", "struct", "struct_levels_to_print",
|
519
|
+
"strvcat", "subsasgn", "subsref", "sum", "sumsq",
|
520
|
+
"superiorto", "suppress_verbose_help_message",
|
521
|
+
"symlink", "system", "tic", "tilde_expand",
|
522
|
+
"times", "tmpfile", "tmpnam", "toc", "toupper",
|
523
|
+
"transpose", "true", "typeinfo", "umask", "uminus",
|
524
|
+
"uname", "undo_string_escapes", "unlink", "uplus",
|
525
|
+
"upper", "usage", "usleep", "vec", "vectorize",
|
526
|
+
"vertcat", "waitpid", "warning", "warranty",
|
527
|
+
"whos_line_format", "yes_or_no", "zeros",
|
528
|
+
"inf", "Inf", "nan", "NaN"]
|
529
|
+
|
530
|
+
command_kw = [ "close", "load", "who", "whos", ]
|
531
|
+
|
532
|
+
function_kw = [ "accumarray", "accumdim", "acosd", "acotd",
|
533
|
+
"acscd", "addtodate", "allchild", "ancestor",
|
534
|
+
"anova", "arch_fit", "arch_rnd", "arch_test",
|
535
|
+
"area", "arma_rnd", "arrayfun", "ascii", "asctime",
|
536
|
+
"asecd", "asind", "assert", "atand",
|
537
|
+
"autoreg_matrix", "autumn", "axes", "axis", "bar",
|
538
|
+
"barh", "bartlett", "bartlett_test", "beep",
|
539
|
+
"betacdf", "betainv", "betapdf", "betarnd",
|
540
|
+
"bicgstab", "bicubic", "binary", "binocdf",
|
541
|
+
"binoinv", "binopdf", "binornd", "bitcmp",
|
542
|
+
"bitget", "bitset", "blackman", "blanks",
|
543
|
+
"blkdiag", "bone", "box", "brighten", "calendar",
|
544
|
+
"cast", "cauchy_cdf", "cauchy_inv", "cauchy_pdf",
|
545
|
+
"cauchy_rnd", "caxis", "celldisp", "center", "cgs",
|
546
|
+
"chisquare_test_homogeneity",
|
547
|
+
"chisquare_test_independence", "circshift", "cla",
|
548
|
+
"clabel", "clf", "clock", "cloglog", "closereq",
|
549
|
+
"colon", "colorbar", "colormap", "colperm",
|
550
|
+
"comet", "common_size", "commutation_matrix",
|
551
|
+
"compan", "compare_versions", "compass",
|
552
|
+
"computer", "cond", "condest", "contour",
|
553
|
+
"contourc", "contourf", "contrast", "conv",
|
554
|
+
"convhull", "cool", "copper", "copyfile", "cor",
|
555
|
+
"corrcoef", "cor_test", "cosd", "cotd", "cov",
|
556
|
+
"cplxpair", "cross", "cscd", "cstrcat", "csvread",
|
557
|
+
"csvwrite", "ctime", "cumtrapz", "curl", "cut",
|
558
|
+
"cylinder", "date", "datenum", "datestr",
|
559
|
+
"datetick", "datevec", "dblquad", "deal",
|
560
|
+
"deblank", "deconv", "delaunay", "delaunayn",
|
561
|
+
"delete", "demo", "detrend", "diffpara", "diffuse",
|
562
|
+
"dir", "discrete_cdf", "discrete_inv",
|
563
|
+
"discrete_pdf", "discrete_rnd", "display",
|
564
|
+
"divergence", "dlmwrite", "dos", "dsearch",
|
565
|
+
"dsearchn", "duplication_matrix", "durbinlevinson",
|
566
|
+
"ellipsoid", "empirical_cdf", "empirical_inv",
|
567
|
+
"empirical_pdf", "empirical_rnd", "eomday",
|
568
|
+
"errorbar", "etime", "etreeplot", "example",
|
569
|
+
"expcdf", "expinv", "expm", "exppdf", "exprnd",
|
570
|
+
"ezcontour", "ezcontourf", "ezmesh", "ezmeshc",
|
571
|
+
"ezplot", "ezpolar", "ezsurf", "ezsurfc", "factor",
|
572
|
+
"factorial", "fail", "fcdf", "feather", "fftconv",
|
573
|
+
"fftfilt", "fftshift", "figure", "fileattrib",
|
574
|
+
"fileparts", "fill", "findall", "findobj",
|
575
|
+
"findstr", "finv", "flag", "flipdim", "fliplr",
|
576
|
+
"flipud", "fpdf", "fplot", "fractdiff", "freqz",
|
577
|
+
"freqz_plot", "frnd", "fsolve",
|
578
|
+
"f_test_regression", "ftp", "fullfile", "fzero",
|
579
|
+
"gamcdf", "gaminv", "gampdf", "gamrnd", "gca",
|
580
|
+
"gcbf", "gcbo", "gcf", "genvarname", "geocdf",
|
581
|
+
"geoinv", "geopdf", "geornd", "getfield", "ginput",
|
582
|
+
"glpk", "gls", "gplot", "gradient",
|
583
|
+
"graphics_toolkit", "gray", "grid", "griddata",
|
584
|
+
"griddatan", "gtext", "gunzip", "gzip", "hadamard",
|
585
|
+
"hamming", "hankel", "hanning", "hggroup",
|
586
|
+
"hidden", "hilb", "hist", "histc", "hold", "hot",
|
587
|
+
"hotelling_test", "housh", "hsv", "hurst",
|
588
|
+
"hygecdf", "hygeinv", "hygepdf", "hygernd",
|
589
|
+
"idivide", "ifftshift", "image", "imagesc",
|
590
|
+
"imfinfo", "imread", "imshow", "imwrite", "index",
|
591
|
+
"info", "inpolygon", "inputname", "interpft",
|
592
|
+
"interpn", "intersect", "invhilb", "iqr", "isa",
|
593
|
+
"isdefinite", "isdir", "is_duplicate_entry",
|
594
|
+
"isequal", "isequalwithequalnans", "isfigure",
|
595
|
+
"ishermitian", "ishghandle", "is_leap_year",
|
596
|
+
"isletter", "ismac", "ismember", "ispc", "isprime",
|
597
|
+
"isprop", "isscalar", "issquare", "isstrprop",
|
598
|
+
"issymmetric", "isunix", "is_valid_file_id",
|
599
|
+
"isvector", "jet", "kendall",
|
600
|
+
"kolmogorov_smirnov_cdf",
|
601
|
+
"kolmogorov_smirnov_test", "kruskal_wallis_test",
|
602
|
+
"krylov", "kurtosis", "laplace_cdf", "laplace_inv",
|
603
|
+
"laplace_pdf", "laplace_rnd", "legend", "legendre",
|
604
|
+
"license", "line", "linkprop", "list_primes",
|
605
|
+
"loadaudio", "loadobj", "logistic_cdf",
|
606
|
+
"logistic_inv", "logistic_pdf", "logistic_rnd",
|
607
|
+
"logit", "loglog", "loglogerr", "logm", "logncdf",
|
608
|
+
"logninv", "lognpdf", "lognrnd", "logspace",
|
609
|
+
"lookfor", "ls_command", "lsqnonneg", "magic",
|
610
|
+
"mahalanobis", "manova", "matlabroot",
|
611
|
+
"mcnemar_test", "mean", "meansq", "median", "menu",
|
612
|
+
"mesh", "meshc", "meshgrid", "meshz", "mexext",
|
613
|
+
"mget", "mkpp", "mode", "moment", "movefile",
|
614
|
+
"mpoles", "mput", "namelengthmax", "nargchk",
|
615
|
+
"nargoutchk", "nbincdf", "nbininv", "nbinpdf",
|
616
|
+
"nbinrnd", "nchoosek", "ndgrid", "newplot", "news",
|
617
|
+
"nonzeros", "normcdf", "normest", "norminv",
|
618
|
+
"normpdf", "normrnd", "now", "nthroot", "null",
|
619
|
+
"ocean", "ols", "onenormest", "optimget",
|
620
|
+
"optimset", "orderfields", "orient", "orth",
|
621
|
+
"pack", "pareto", "parseparams", "pascal", "patch",
|
622
|
+
"pathdef", "pcg", "pchip", "pcolor", "pcr",
|
623
|
+
"peaks", "periodogram", "perl", "perms", "pie",
|
624
|
+
"pink", "planerot", "playaudio", "plot",
|
625
|
+
"plotmatrix", "plotyy", "poisscdf", "poissinv",
|
626
|
+
"poisspdf", "poissrnd", "polar", "poly",
|
627
|
+
"polyaffine", "polyarea", "polyderiv", "polyfit",
|
628
|
+
"polygcd", "polyint", "polyout", "polyreduce",
|
629
|
+
"polyval", "polyvalm", "postpad", "powerset",
|
630
|
+
"ppder", "ppint", "ppjumps", "ppplot", "ppval",
|
631
|
+
"pqpnonneg", "prepad", "primes", "print",
|
632
|
+
"print_usage", "prism", "probit", "qp", "qqplot",
|
633
|
+
"quadcc", "quadgk", "quadl", "quadv", "quiver",
|
634
|
+
"qzhess", "rainbow", "randi", "range", "rank",
|
635
|
+
"ranks", "rat", "reallog", "realpow", "realsqrt",
|
636
|
+
"record", "rectangle_lw", "rectangle_sw",
|
637
|
+
"rectint", "refresh", "refreshdata",
|
638
|
+
"regexptranslate", "repmat", "residue", "ribbon",
|
639
|
+
"rindex", "roots", "rose", "rosser", "rotdim",
|
640
|
+
"rref", "run", "run_count", "rundemos", "run_test",
|
641
|
+
"runtests", "saveas", "saveaudio", "saveobj",
|
642
|
+
"savepath", "scatter", "secd", "semilogx",
|
643
|
+
"semilogxerr", "semilogy", "semilogyerr",
|
644
|
+
"setaudio", "setdiff", "setfield", "setxor",
|
645
|
+
"shading", "shift", "shiftdim", "sign_test",
|
646
|
+
"sinc", "sind", "sinetone", "sinewave", "skewness",
|
647
|
+
"slice", "sombrero", "sortrows", "spaugment",
|
648
|
+
"spconvert", "spdiags", "spearman", "spectral_adf",
|
649
|
+
"spectral_xdf", "specular", "speed", "spencer",
|
650
|
+
"speye", "spfun", "sphere", "spinmap", "spline",
|
651
|
+
"spones", "sprand", "sprandn", "sprandsym",
|
652
|
+
"spring", "spstats", "spy", "sqp", "stairs",
|
653
|
+
"statistics", "std", "stdnormal_cdf",
|
654
|
+
"stdnormal_inv", "stdnormal_pdf", "stdnormal_rnd",
|
655
|
+
"stem", "stft", "strcat", "strchr", "strjust",
|
656
|
+
"strmatch", "strread", "strsplit", "strtok",
|
657
|
+
"strtrim", "strtrunc", "structfun", "studentize",
|
658
|
+
"subplot", "subsindex", "subspace", "substr",
|
659
|
+
"substruct", "summer", "surf", "surface", "surfc",
|
660
|
+
"surfl", "surfnorm", "svds", "swapbytes",
|
661
|
+
"sylvester_matrix", "symvar", "synthesis", "table",
|
662
|
+
"tand", "tar", "tcdf", "tempdir", "tempname",
|
663
|
+
"test", "text", "textread", "textscan", "tinv",
|
664
|
+
"title", "toeplitz", "tpdf", "trace", "trapz",
|
665
|
+
"treelayout", "treeplot", "triangle_lw",
|
666
|
+
"triangle_sw", "tril", "trimesh", "triplequad",
|
667
|
+
"triplot", "trisurf", "triu", "trnd", "tsearchn",
|
668
|
+
"t_test", "t_test_regression", "type", "unidcdf",
|
669
|
+
"unidinv", "unidpdf", "unidrnd", "unifcdf",
|
670
|
+
"unifinv", "unifpdf", "unifrnd", "union", "unique",
|
671
|
+
"unix", "unmkpp", "unpack", "untabify", "untar",
|
672
|
+
"unwrap", "unzip", "u_test", "validatestring",
|
673
|
+
"vander", "var", "var_test", "vech", "ver",
|
674
|
+
"version", "view", "voronoi", "voronoin",
|
675
|
+
"waitforbuttonpress", "wavread", "wavwrite",
|
676
|
+
"wblcdf", "wblinv", "wblpdf", "wblrnd", "weekday",
|
677
|
+
"welch_test", "what", "white", "whitebg",
|
678
|
+
"wienrnd", "wilcoxon_test", "wilkinson", "winter",
|
679
|
+
"xlabel", "xlim", "ylabel", "yulewalker", "zip",
|
680
|
+
"zlabel", "z_test", ]
|
681
|
+
|
682
|
+
loadable_kw = [ "airy", "amd", "balance", "besselh", "besseli",
|
683
|
+
"besselj", "besselk", "bessely", "bitpack",
|
684
|
+
"bsxfun", "builtin", "ccolamd", "cellfun",
|
685
|
+
"cellslices", "chol", "choldelete", "cholinsert",
|
686
|
+
"cholinv", "cholshift", "cholupdate", "colamd",
|
687
|
+
"colloc", "convhulln", "convn", "csymamd",
|
688
|
+
"cummax", "cummin", "daspk", "daspk_options",
|
689
|
+
"dasrt", "dasrt_options", "dassl", "dassl_options",
|
690
|
+
"dbclear", "dbdown", "dbstack", "dbstatus",
|
691
|
+
"dbstop", "dbtype", "dbup", "dbwhere", "det",
|
692
|
+
"dlmread", "dmperm", "dot", "eig", "eigs",
|
693
|
+
"endgrent", "endpwent", "etree", "fft", "fftn",
|
694
|
+
"fftw", "filter", "find", "full", "gcd",
|
695
|
+
"getgrent", "getgrgid", "getgrnam", "getpwent",
|
696
|
+
"getpwnam", "getpwuid", "getrusage", "givens",
|
697
|
+
"gmtime", "gnuplot_binary", "hess", "ifft",
|
698
|
+
"ifftn", "inv", "isdebugmode", "issparse", "kron",
|
699
|
+
"localtime", "lookup", "lsode", "lsode_options",
|
700
|
+
"lu", "luinc", "luupdate", "matrix_type", "max",
|
701
|
+
"min", "mktime", "pinv", "qr", "qrdelete",
|
702
|
+
"qrinsert", "qrshift", "qrupdate", "quad",
|
703
|
+
"quad_options", "qz", "rand", "rande", "randg",
|
704
|
+
"randn", "randp", "randperm", "rcond", "regexp",
|
705
|
+
"regexpi", "regexprep", "schur", "setgrent",
|
706
|
+
"setpwent", "sort", "spalloc", "sparse", "spparms",
|
707
|
+
"sprank", "sqrtm", "strfind", "strftime",
|
708
|
+
"strptime", "strrep", "svd", "svd_driver", "syl",
|
709
|
+
"symamd", "symbfact", "symrcm", "time", "tsearch",
|
710
|
+
"typecast", "urlread", "urlwrite", ]
|
711
|
+
|
712
|
+
mapping_kw = [ "abs", "acos", "acosh", "acot", "acoth", "acsc",
|
713
|
+
"acsch", "angle", "arg", "asec", "asech", "asin",
|
714
|
+
"asinh", "atan", "atanh", "beta", "betainc",
|
715
|
+
"betaln", "bincoeff", "cbrt", "ceil", "conj", "cos",
|
716
|
+
"cosh", "cot", "coth", "csc", "csch", "erf", "erfc",
|
717
|
+
"erfcx", "erfinv", "exp", "finite", "fix", "floor",
|
718
|
+
"fmod", "gamma", "gammainc", "gammaln", "imag",
|
719
|
+
"isalnum", "isalpha", "isascii", "iscntrl",
|
720
|
+
"isdigit", "isfinite", "isgraph", "isinf",
|
721
|
+
"islower", "isna", "isnan", "isprint", "ispunct",
|
722
|
+
"isspace", "isupper", "isxdigit", "lcm", "lgamma",
|
723
|
+
"log", "lower", "mod", "real", "rem", "round",
|
724
|
+
"roundb", "sec", "sech", "sign", "sin", "sinh",
|
725
|
+
"sqrt", "tan", "tanh", "toascii", "tolower", "xor",
|
726
|
+
]
|
727
|
+
|
728
|
+
builtin_consts = [ "EDITOR", "EXEC_PATH", "I", "IMAGE_PATH", "NA",
|
729
|
+
"OCTAVE_HOME", "OCTAVE_VERSION", "PAGER",
|
730
|
+
"PAGER_FLAGS", "SEEK_CUR", "SEEK_END", "SEEK_SET",
|
731
|
+
"SIG", "S_ISBLK", "S_ISCHR", "S_ISDIR", "S_ISFIFO",
|
732
|
+
"S_ISLNK", "S_ISREG", "S_ISSOCK", "WCONTINUE",
|
733
|
+
"WCOREDUMP", "WEXITSTATUS", "WIFCONTINUED",
|
734
|
+
"WIFEXITED", "WIFSIGNALED", "WIFSTOPPED", "WNOHANG",
|
735
|
+
"WSTOPSIG", "WTERMSIG", "WUNTRACED", ]
|
736
|
+
|
737
|
+
tokens = {
|
738
|
+
'root': [
|
739
|
+
#We should look into multiline comments
|
740
|
+
(r'[%#].*$', Comment),
|
741
|
+
(r'^\s*function', Keyword, 'deffunc'),
|
742
|
+
|
743
|
+
# from 'iskeyword' on hg changeset 8cc154f45e37
|
744
|
+
(r'(__FILE__|__LINE__|break|case|catch|classdef|continue|do|else|'
|
745
|
+
r'elseif|end|end_try_catch|end_unwind_protect|endclassdef|'
|
746
|
+
r'endevents|endfor|endfunction|endif|endmethods|endproperties|'
|
747
|
+
r'endswitch|endwhile|events|for|function|get|global|if|methods|'
|
748
|
+
r'otherwise|persistent|properties|return|set|static|switch|try|'
|
749
|
+
r'until|unwind_protect|unwind_protect_cleanup|while)\b', Keyword),
|
750
|
+
|
751
|
+
("(" + "|".join( builtin_kw + command_kw
|
752
|
+
+ function_kw + loadable_kw
|
753
|
+
+ mapping_kw) + r')\b', Name.Builtin),
|
754
|
+
|
755
|
+
("(" + "|".join(builtin_consts) + r')\b', Name.Constant),
|
756
|
+
|
757
|
+
# operators in Octave but not Matlab:
|
758
|
+
(r'-=|!=|!|/=|--', Operator),
|
759
|
+
# operators:
|
760
|
+
(r'-|==|~=|<|>|<=|>=|&&|&|~|\|\|?', Operator),
|
761
|
+
# operators in Octave but not Matlab requiring escape for re:
|
762
|
+
(r'\*=|\+=|\^=|\/=|\\=|\*\*|\+\+|\.\*\*',Operator),
|
763
|
+
# operators requiring escape for re:
|
764
|
+
(r'\.\*|\*|\+|\.\^|\.\\|\.\/|\/|\\', Operator),
|
765
|
+
|
766
|
+
|
767
|
+
# punctuation:
|
768
|
+
(r'\[|\]|\(|\)|\{|\}|:|@|\.|,', Punctuation),
|
769
|
+
(r'=|:|;', Punctuation),
|
770
|
+
|
771
|
+
(r'"[^"]*"', String),
|
772
|
+
|
773
|
+
# quote can be transpose, instead of string:
|
774
|
+
# (not great, but handles common cases...)
|
775
|
+
(r'(?<=[\w\)\]])\'', Operator),
|
776
|
+
(r'(?<![\w\)\]])\'', String, 'string'),
|
777
|
+
|
778
|
+
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
779
|
+
(r'.', Text),
|
780
|
+
],
|
781
|
+
'string': [
|
782
|
+
(r"[^']*'", String, '#pop'),
|
783
|
+
],
|
784
|
+
'deffunc': [
|
785
|
+
(r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
786
|
+
bygroups(Text.Whitespace, Text, Text.Whitespace, Punctuation,
|
787
|
+
Text.Whitespace, Name.Function, Punctuation, Text,
|
788
|
+
Punctuation, Text.Whitespace), '#pop'),
|
789
|
+
],
|
790
|
+
}
|
791
|
+
|
792
|
+
def analyse_text(text):
|
793
|
+
if re.match('^\s*[%#]', text, re.M): #Comment
|
794
|
+
return 0.9
|
795
|
+
return 0.1
|
796
|
+
|
797
|
+
|
798
|
+
class ScilabLexer(RegexLexer):
|
799
|
+
"""
|
800
|
+
For Scilab source code.
|
801
|
+
|
802
|
+
*New in Pygments 1.5.*
|
803
|
+
"""
|
804
|
+
name = 'Scilab'
|
805
|
+
aliases = ['scilab']
|
806
|
+
filenames = ['*.sci', '*.sce', '*.tst']
|
807
|
+
mimetypes = ['text/scilab']
|
808
|
+
|
809
|
+
tokens = {
|
810
|
+
'root': [
|
811
|
+
(r'//.*?$', Comment.Single),
|
812
|
+
(r'^\s*function', Keyword, 'deffunc'),
|
813
|
+
|
814
|
+
(r'(__FILE__|__LINE__|break|case|catch|classdef|continue|do|else|'
|
815
|
+
r'elseif|end|end_try_catch|end_unwind_protect|endclassdef|'
|
816
|
+
r'endevents|endfor|endfunction|endif|endmethods|endproperties|'
|
817
|
+
r'endswitch|endwhile|events|for|function|get|global|if|methods|'
|
818
|
+
r'otherwise|persistent|properties|return|set|static|switch|try|'
|
819
|
+
r'until|unwind_protect|unwind_protect_cleanup|while)\b', Keyword),
|
820
|
+
|
821
|
+
("(" + "|".join(_scilab_builtins.functions_kw +
|
822
|
+
_scilab_builtins.commands_kw +
|
823
|
+
_scilab_builtins.macros_kw
|
824
|
+
) + r')\b', Name.Builtin),
|
825
|
+
|
826
|
+
(r'(%s)\b' % "|".join(map(re.escape, _scilab_builtins.builtin_consts)),
|
827
|
+
Name.Constant),
|
828
|
+
|
829
|
+
# operators:
|
830
|
+
(r'-|==|~=|<|>|<=|>=|&&|&|~|\|\|?', Operator),
|
831
|
+
# operators requiring escape for re:
|
832
|
+
(r'\.\*|\*|\+|\.\^|\.\\|\.\/|\/|\\', Operator),
|
833
|
+
|
834
|
+
# punctuation:
|
835
|
+
(r'[\[\](){}@.,=:;]', Punctuation),
|
836
|
+
|
837
|
+
(r'"[^"]*"', String),
|
838
|
+
|
839
|
+
# quote can be transpose, instead of string:
|
840
|
+
# (not great, but handles common cases...)
|
841
|
+
(r'(?<=[\w\)\]])\'', Operator),
|
842
|
+
(r'(?<![\w\)\]])\'', String, 'string'),
|
843
|
+
|
844
|
+
('[a-zA-Z_][a-zA-Z0-9_]*', Name),
|
845
|
+
(r'.', Text),
|
846
|
+
],
|
847
|
+
'string': [
|
848
|
+
(r"[^']*'", String, '#pop'),
|
849
|
+
(r'.', String, '#pop'),
|
850
|
+
],
|
851
|
+
'deffunc': [
|
852
|
+
(r'(\s*)(?:(.+)(\s*)(=)(\s*))?(.+)(\()(.*)(\))(\s*)',
|
853
|
+
bygroups(Text.Whitespace, Text, Text.Whitespace, Punctuation,
|
854
|
+
Text.Whitespace, Name.Function, Punctuation, Text,
|
855
|
+
Punctuation, Text.Whitespace), '#pop'),
|
856
|
+
],
|
857
|
+
}
|
858
|
+
|
859
|
+
|
860
|
+
class NumPyLexer(PythonLexer):
|
861
|
+
"""
|
862
|
+
A Python lexer recognizing Numerical Python builtins.
|
863
|
+
|
864
|
+
*New in Pygments 0.10.*
|
865
|
+
"""
|
866
|
+
|
867
|
+
name = 'NumPy'
|
868
|
+
aliases = ['numpy']
|
869
|
+
|
870
|
+
# override the mimetypes to not inherit them from python
|
871
|
+
mimetypes = []
|
872
|
+
filenames = []
|
873
|
+
|
874
|
+
EXTRA_KEYWORDS = set([
|
875
|
+
'abs', 'absolute', 'accumulate', 'add', 'alen', 'all', 'allclose',
|
876
|
+
'alltrue', 'alterdot', 'amax', 'amin', 'angle', 'any', 'append',
|
877
|
+
'apply_along_axis', 'apply_over_axes', 'arange', 'arccos', 'arccosh',
|
878
|
+
'arcsin', 'arcsinh', 'arctan', 'arctan2', 'arctanh', 'argmax', 'argmin',
|
879
|
+
'argsort', 'argwhere', 'around', 'array', 'array2string', 'array_equal',
|
880
|
+
'array_equiv', 'array_repr', 'array_split', 'array_str', 'arrayrange',
|
881
|
+
'asanyarray', 'asarray', 'asarray_chkfinite', 'ascontiguousarray',
|
882
|
+
'asfarray', 'asfortranarray', 'asmatrix', 'asscalar', 'astype',
|
883
|
+
'atleast_1d', 'atleast_2d', 'atleast_3d', 'average', 'bartlett',
|
884
|
+
'base_repr', 'beta', 'binary_repr', 'bincount', 'binomial',
|
885
|
+
'bitwise_and', 'bitwise_not', 'bitwise_or', 'bitwise_xor', 'blackman',
|
886
|
+
'bmat', 'broadcast', 'byte_bounds', 'bytes', 'byteswap', 'c_',
|
887
|
+
'can_cast', 'ceil', 'choose', 'clip', 'column_stack', 'common_type',
|
888
|
+
'compare_chararrays', 'compress', 'concatenate', 'conj', 'conjugate',
|
889
|
+
'convolve', 'copy', 'corrcoef', 'correlate', 'cos', 'cosh', 'cov',
|
890
|
+
'cross', 'cumprod', 'cumproduct', 'cumsum', 'delete', 'deprecate',
|
891
|
+
'diag', 'diagflat', 'diagonal', 'diff', 'digitize', 'disp', 'divide',
|
892
|
+
'dot', 'dsplit', 'dstack', 'dtype', 'dump', 'dumps', 'ediff1d', 'empty',
|
893
|
+
'empty_like', 'equal', 'exp', 'expand_dims', 'expm1', 'extract', 'eye',
|
894
|
+
'fabs', 'fastCopyAndTranspose', 'fft', 'fftfreq', 'fftshift', 'fill',
|
895
|
+
'finfo', 'fix', 'flat', 'flatnonzero', 'flatten', 'fliplr', 'flipud',
|
896
|
+
'floor', 'floor_divide', 'fmod', 'frexp', 'fromarrays', 'frombuffer',
|
897
|
+
'fromfile', 'fromfunction', 'fromiter', 'frompyfunc', 'fromstring',
|
898
|
+
'generic', 'get_array_wrap', 'get_include', 'get_numarray_include',
|
899
|
+
'get_numpy_include', 'get_printoptions', 'getbuffer', 'getbufsize',
|
900
|
+
'geterr', 'geterrcall', 'geterrobj', 'getfield', 'gradient', 'greater',
|
901
|
+
'greater_equal', 'gumbel', 'hamming', 'hanning', 'histogram',
|
902
|
+
'histogram2d', 'histogramdd', 'hsplit', 'hstack', 'hypot', 'i0',
|
903
|
+
'identity', 'ifft', 'imag', 'index_exp', 'indices', 'inf', 'info',
|
904
|
+
'inner', 'insert', 'int_asbuffer', 'interp', 'intersect1d',
|
905
|
+
'intersect1d_nu', 'inv', 'invert', 'iscomplex', 'iscomplexobj',
|
906
|
+
'isfinite', 'isfortran', 'isinf', 'isnan', 'isneginf', 'isposinf',
|
907
|
+
'isreal', 'isrealobj', 'isscalar', 'issctype', 'issubclass_',
|
908
|
+
'issubdtype', 'issubsctype', 'item', 'itemset', 'iterable', 'ix_',
|
909
|
+
'kaiser', 'kron', 'ldexp', 'left_shift', 'less', 'less_equal', 'lexsort',
|
910
|
+
'linspace', 'load', 'loads', 'loadtxt', 'log', 'log10', 'log1p', 'log2',
|
911
|
+
'logical_and', 'logical_not', 'logical_or', 'logical_xor', 'logspace',
|
912
|
+
'lstsq', 'mat', 'matrix', 'max', 'maximum', 'maximum_sctype',
|
913
|
+
'may_share_memory', 'mean', 'median', 'meshgrid', 'mgrid', 'min',
|
914
|
+
'minimum', 'mintypecode', 'mod', 'modf', 'msort', 'multiply', 'nan',
|
915
|
+
'nan_to_num', 'nanargmax', 'nanargmin', 'nanmax', 'nanmin', 'nansum',
|
916
|
+
'ndenumerate', 'ndim', 'ndindex', 'negative', 'newaxis', 'newbuffer',
|
917
|
+
'newbyteorder', 'nonzero', 'not_equal', 'obj2sctype', 'ogrid', 'ones',
|
918
|
+
'ones_like', 'outer', 'permutation', 'piecewise', 'pinv', 'pkgload',
|
919
|
+
'place', 'poisson', 'poly', 'poly1d', 'polyadd', 'polyder', 'polydiv',
|
920
|
+
'polyfit', 'polyint', 'polymul', 'polysub', 'polyval', 'power', 'prod',
|
921
|
+
'product', 'ptp', 'put', 'putmask', 'r_', 'randint', 'random_integers',
|
922
|
+
'random_sample', 'ranf', 'rank', 'ravel', 'real', 'real_if_close',
|
923
|
+
'recarray', 'reciprocal', 'reduce', 'remainder', 'repeat', 'require',
|
924
|
+
'reshape', 'resize', 'restoredot', 'right_shift', 'rint', 'roll',
|
925
|
+
'rollaxis', 'roots', 'rot90', 'round', 'round_', 'row_stack', 's_',
|
926
|
+
'sample', 'savetxt', 'sctype2char', 'searchsorted', 'seed', 'select',
|
927
|
+
'set_numeric_ops', 'set_printoptions', 'set_string_function',
|
928
|
+
'setbufsize', 'setdiff1d', 'seterr', 'seterrcall', 'seterrobj',
|
929
|
+
'setfield', 'setflags', 'setmember1d', 'setxor1d', 'shape',
|
930
|
+
'show_config', 'shuffle', 'sign', 'signbit', 'sin', 'sinc', 'sinh',
|
931
|
+
'size', 'slice', 'solve', 'sometrue', 'sort', 'sort_complex', 'source',
|
932
|
+
'split', 'sqrt', 'square', 'squeeze', 'standard_normal', 'std',
|
933
|
+
'subtract', 'sum', 'svd', 'swapaxes', 'take', 'tan', 'tanh', 'tensordot',
|
934
|
+
'test', 'tile', 'tofile', 'tolist', 'tostring', 'trace', 'transpose',
|
935
|
+
'trapz', 'tri', 'tril', 'trim_zeros', 'triu', 'true_divide', 'typeDict',
|
936
|
+
'typename', 'uniform', 'union1d', 'unique', 'unique1d', 'unravel_index',
|
937
|
+
'unwrap', 'vander', 'var', 'vdot', 'vectorize', 'view', 'vonmises',
|
938
|
+
'vsplit', 'vstack', 'weibull', 'where', 'who', 'zeros', 'zeros_like'
|
939
|
+
])
|
940
|
+
|
941
|
+
def get_tokens_unprocessed(self, text):
|
942
|
+
for index, token, value in \
|
943
|
+
PythonLexer.get_tokens_unprocessed(self, text):
|
944
|
+
if token is Name and value in self.EXTRA_KEYWORDS:
|
945
|
+
yield index, Keyword.Pseudo, value
|
946
|
+
else:
|
947
|
+
yield index, token, value
|
948
|
+
|
949
|
+
|
950
|
+
class RConsoleLexer(Lexer):
|
951
|
+
"""
|
952
|
+
For R console transcripts or R CMD BATCH output files.
|
953
|
+
"""
|
954
|
+
|
955
|
+
name = 'RConsole'
|
956
|
+
aliases = ['rconsole', 'rout']
|
957
|
+
filenames = ['*.Rout']
|
958
|
+
|
959
|
+
def get_tokens_unprocessed(self, text):
|
960
|
+
slexer = SLexer(**self.options)
|
961
|
+
|
962
|
+
current_code_block = ''
|
963
|
+
insertions = []
|
964
|
+
|
965
|
+
for match in line_re.finditer(text):
|
966
|
+
line = match.group()
|
967
|
+
if line.startswith('>') or line.startswith('+'):
|
968
|
+
# Colorize the prompt as such,
|
969
|
+
# then put rest of line into current_code_block
|
970
|
+
insertions.append((len(current_code_block),
|
971
|
+
[(0, Generic.Prompt, line[:2])]))
|
972
|
+
current_code_block += line[2:]
|
973
|
+
else:
|
974
|
+
# We have reached a non-prompt line!
|
975
|
+
# If we have stored prompt lines, need to process them first.
|
976
|
+
if current_code_block:
|
977
|
+
# Weave together the prompts and highlight code.
|
978
|
+
for item in do_insertions(insertions,
|
979
|
+
slexer.get_tokens_unprocessed(current_code_block)):
|
980
|
+
yield item
|
981
|
+
# Reset vars for next code block.
|
982
|
+
current_code_block = ''
|
983
|
+
insertions = []
|
984
|
+
# Now process the actual line itself, this is output from R.
|
985
|
+
yield match.start(), Generic.Output, line
|
986
|
+
|
987
|
+
# If we happen to end on a code block with nothing after it, need to
|
988
|
+
# process the last code block. This is neither elegant nor DRY so
|
989
|
+
# should be changed.
|
990
|
+
if current_code_block:
|
991
|
+
for item in do_insertions(insertions,
|
992
|
+
slexer.get_tokens_unprocessed(current_code_block)):
|
993
|
+
yield item
|
994
|
+
|
995
|
+
|
996
|
+
class SLexer(RegexLexer):
|
997
|
+
"""
|
998
|
+
For S, S-plus, and R source code.
|
999
|
+
|
1000
|
+
*New in Pygments 0.10.*
|
1001
|
+
"""
|
1002
|
+
|
1003
|
+
name = 'S'
|
1004
|
+
aliases = ['splus', 's', 'r']
|
1005
|
+
filenames = ['*.S', '*.R']
|
1006
|
+
mimetypes = ['text/S-plus', 'text/S', 'text/R']
|
1007
|
+
|
1008
|
+
tokens = {
|
1009
|
+
'comments': [
|
1010
|
+
(r'#.*$', Comment.Single),
|
1011
|
+
],
|
1012
|
+
'valid_name': [
|
1013
|
+
(r'[a-zA-Z][0-9a-zA-Z\._]+', Text),
|
1014
|
+
(r'`.+`', String.Backtick),
|
1015
|
+
],
|
1016
|
+
'punctuation': [
|
1017
|
+
(r'\[|\]|\[\[|\]\]|\$|\(|\)|@|:::?|;|,', Punctuation),
|
1018
|
+
],
|
1019
|
+
'keywords': [
|
1020
|
+
(r'for(?=\s*\()|while(?=\s*\()|if(?=\s*\()|(?<=\s)else|'
|
1021
|
+
r'(?<=\s)break(?=;|$)|return(?=\s*\()|function(?=\s*\()',
|
1022
|
+
Keyword.Reserved)
|
1023
|
+
],
|
1024
|
+
'operators': [
|
1025
|
+
(r'<-|-|==|<=|>=|<|>|&&|&|!=|\|\|?', Operator),
|
1026
|
+
(r'\*|\+|\^|/|%%|%/%|=', Operator),
|
1027
|
+
(r'%in%|%*%', Operator)
|
1028
|
+
],
|
1029
|
+
'builtin_symbols': [
|
1030
|
+
(r'(NULL|NA|TRUE|FALSE|NaN)\b', Keyword.Constant),
|
1031
|
+
(r'(T|F)\b', Keyword.Variable),
|
1032
|
+
],
|
1033
|
+
'numbers': [
|
1034
|
+
(r'(?<![0-9a-zA-Z\)\}\]`\"])(?=\s*)[-\+]?[0-9]+'
|
1035
|
+
r'(\.[0-9]*)?(E[0-9][-\+]?(\.[0-9]*)?)?', Number),
|
1036
|
+
(r'\.[0-9]*(E[0-9][-\+]?(\.[0-9]*)?)?', Number),
|
1037
|
+
],
|
1038
|
+
'statements': [
|
1039
|
+
include('comments'),
|
1040
|
+
# whitespaces
|
1041
|
+
(r'\s+', Text),
|
1042
|
+
(r'\'', String, 'string_squote'),
|
1043
|
+
(r'\"', String, 'string_dquote'),
|
1044
|
+
include('builtin_symbols'),
|
1045
|
+
include('numbers'),
|
1046
|
+
include('keywords'),
|
1047
|
+
include('punctuation'),
|
1048
|
+
include('operators'),
|
1049
|
+
include('valid_name'),
|
1050
|
+
],
|
1051
|
+
'root': [
|
1052
|
+
include('statements'),
|
1053
|
+
# blocks:
|
1054
|
+
(r'\{|\}', Punctuation),
|
1055
|
+
#(r'\{', Punctuation, 'block'),
|
1056
|
+
(r'.', Text),
|
1057
|
+
],
|
1058
|
+
#'block': [
|
1059
|
+
# include('statements'),
|
1060
|
+
# ('\{', Punctuation, '#push'),
|
1061
|
+
# ('\}', Punctuation, '#pop')
|
1062
|
+
#],
|
1063
|
+
'string_squote': [
|
1064
|
+
(r'[^\']*\'', String, '#pop'),
|
1065
|
+
],
|
1066
|
+
'string_dquote': [
|
1067
|
+
(r'[^\"]*\"', String, '#pop'),
|
1068
|
+
],
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
def analyse_text(text):
|
1072
|
+
return '<-' in text
|