gitlab-pygments.rb 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. data/.gitignore +6 -0
  2. data/Gemfile +2 -0
  3. data/README.md +91 -0
  4. data/Rakefile +78 -0
  5. data/bench.rb +22 -0
  6. data/cache-lexers.rb +8 -0
  7. data/lexers +0 -0
  8. data/lib/pygments/lexer.rb +148 -0
  9. data/lib/pygments/mentos.py +344 -0
  10. data/lib/pygments/popen.rb +389 -0
  11. data/lib/pygments/version.rb +3 -0
  12. data/lib/pygments.rb +8 -0
  13. data/pygments.rb.gemspec +24 -0
  14. data/test/test_data.c +2581 -0
  15. data/test/test_data.py +514 -0
  16. data/test/test_data_generated +2582 -0
  17. data/test/test_pygments.rb +276 -0
  18. data/vendor/custom_formatters/gitlab.py +171 -0
  19. data/vendor/custom_lexers/github.py +362 -0
  20. data/vendor/pygments-main/AUTHORS +115 -0
  21. data/vendor/pygments-main/CHANGES +762 -0
  22. data/vendor/pygments-main/LICENSE +25 -0
  23. data/vendor/pygments-main/MANIFEST.in +6 -0
  24. data/vendor/pygments-main/Makefile +59 -0
  25. data/vendor/pygments-main/REVISION +1 -0
  26. data/vendor/pygments-main/TODO +15 -0
  27. data/vendor/pygments-main/docs/generate.py +472 -0
  28. data/vendor/pygments-main/docs/pygmentize.1 +94 -0
  29. data/vendor/pygments-main/docs/src/api.txt +270 -0
  30. data/vendor/pygments-main/docs/src/authors.txt +5 -0
  31. data/vendor/pygments-main/docs/src/changelog.txt +5 -0
  32. data/vendor/pygments-main/docs/src/cmdline.txt +147 -0
  33. data/vendor/pygments-main/docs/src/filterdevelopment.txt +70 -0
  34. data/vendor/pygments-main/docs/src/filters.txt +42 -0
  35. data/vendor/pygments-main/docs/src/formatterdevelopment.txt +169 -0
  36. data/vendor/pygments-main/docs/src/formatters.txt +48 -0
  37. data/vendor/pygments-main/docs/src/index.txt +69 -0
  38. data/vendor/pygments-main/docs/src/installation.txt +71 -0
  39. data/vendor/pygments-main/docs/src/integrate.txt +43 -0
  40. data/vendor/pygments-main/docs/src/lexerdevelopment.txt +551 -0
  41. data/vendor/pygments-main/docs/src/lexers.txt +67 -0
  42. data/vendor/pygments-main/docs/src/moinmoin.txt +39 -0
  43. data/vendor/pygments-main/docs/src/plugins.txt +93 -0
  44. data/vendor/pygments-main/docs/src/quickstart.txt +202 -0
  45. data/vendor/pygments-main/docs/src/rstdirective.txt +22 -0
  46. data/vendor/pygments-main/docs/src/styles.txt +143 -0
  47. data/vendor/pygments-main/docs/src/tokens.txt +349 -0
  48. data/vendor/pygments-main/docs/src/unicode.txt +49 -0
  49. data/vendor/pygments-main/external/markdown-processor.py +67 -0
  50. data/vendor/pygments-main/external/moin-parser.py +112 -0
  51. data/vendor/pygments-main/external/pygments.bashcomp +38 -0
  52. data/vendor/pygments-main/external/rst-directive-old.py +77 -0
  53. data/vendor/pygments-main/external/rst-directive.py +83 -0
  54. data/vendor/pygments-main/ez_setup.py +276 -0
  55. data/vendor/pygments-main/pygmentize +7 -0
  56. data/vendor/pygments-main/pygments/__init__.py +91 -0
  57. data/vendor/pygments-main/pygments/cmdline.py +433 -0
  58. data/vendor/pygments-main/pygments/console.py +74 -0
  59. data/vendor/pygments-main/pygments/filter.py +74 -0
  60. data/vendor/pygments-main/pygments/filters/__init__.py +357 -0
  61. data/vendor/pygments-main/pygments/formatter.py +92 -0
  62. data/vendor/pygments-main/pygments/formatters/__init__.py +68 -0
  63. data/vendor/pygments-main/pygments/formatters/_mapping.py +94 -0
  64. data/vendor/pygments-main/pygments/formatters/bbcode.py +109 -0
  65. data/vendor/pygments-main/pygments/formatters/gitlab.py +171 -0
  66. data/vendor/pygments-main/pygments/formatters/html.py +750 -0
  67. data/vendor/pygments-main/pygments/formatters/img.py +553 -0
  68. data/vendor/pygments-main/pygments/formatters/latex.py +378 -0
  69. data/vendor/pygments-main/pygments/formatters/other.py +117 -0
  70. data/vendor/pygments-main/pygments/formatters/rtf.py +136 -0
  71. data/vendor/pygments-main/pygments/formatters/svg.py +154 -0
  72. data/vendor/pygments-main/pygments/formatters/terminal.py +112 -0
  73. data/vendor/pygments-main/pygments/formatters/terminal256.py +222 -0
  74. data/vendor/pygments-main/pygments/lexer.py +697 -0
  75. data/vendor/pygments-main/pygments/lexers/__init__.py +229 -0
  76. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1645 -0
  77. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +232 -0
  78. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +249 -0
  79. data/vendor/pygments-main/pygments/lexers/_mapping.py +298 -0
  80. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +3787 -0
  81. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +232 -0
  82. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +29 -0
  83. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +3 -0
  84. data/vendor/pygments-main/pygments/lexers/agile.py +1803 -0
  85. data/vendor/pygments-main/pygments/lexers/asm.py +360 -0
  86. data/vendor/pygments-main/pygments/lexers/compiled.py +2891 -0
  87. data/vendor/pygments-main/pygments/lexers/dotnet.py +636 -0
  88. data/vendor/pygments-main/pygments/lexers/functional.py +1832 -0
  89. data/vendor/pygments-main/pygments/lexers/github.py +362 -0
  90. data/vendor/pygments-main/pygments/lexers/hdl.py +356 -0
  91. data/vendor/pygments-main/pygments/lexers/jvm.py +847 -0
  92. data/vendor/pygments-main/pygments/lexers/math.py +1072 -0
  93. data/vendor/pygments-main/pygments/lexers/other.py +3339 -0
  94. data/vendor/pygments-main/pygments/lexers/parsers.py +695 -0
  95. data/vendor/pygments-main/pygments/lexers/shell.py +361 -0
  96. data/vendor/pygments-main/pygments/lexers/special.py +100 -0
  97. data/vendor/pygments-main/pygments/lexers/sql.py +559 -0
  98. data/vendor/pygments-main/pygments/lexers/templates.py +1631 -0
  99. data/vendor/pygments-main/pygments/lexers/text.py +1753 -0
  100. data/vendor/pygments-main/pygments/lexers/web.py +2864 -0
  101. data/vendor/pygments-main/pygments/plugin.py +74 -0
  102. data/vendor/pygments-main/pygments/scanner.py +104 -0
  103. data/vendor/pygments-main/pygments/style.py +117 -0
  104. data/vendor/pygments-main/pygments/styles/__init__.py +70 -0
  105. data/vendor/pygments-main/pygments/styles/autumn.py +65 -0
  106. data/vendor/pygments-main/pygments/styles/borland.py +51 -0
  107. data/vendor/pygments-main/pygments/styles/bw.py +49 -0
  108. data/vendor/pygments-main/pygments/styles/colorful.py +81 -0
  109. data/vendor/pygments-main/pygments/styles/default.py +73 -0
  110. data/vendor/pygments-main/pygments/styles/emacs.py +72 -0
  111. data/vendor/pygments-main/pygments/styles/friendly.py +72 -0
  112. data/vendor/pygments-main/pygments/styles/fruity.py +42 -0
  113. data/vendor/pygments-main/pygments/styles/manni.py +75 -0
  114. data/vendor/pygments-main/pygments/styles/monokai.py +106 -0
  115. data/vendor/pygments-main/pygments/styles/murphy.py +80 -0
  116. data/vendor/pygments-main/pygments/styles/native.py +65 -0
  117. data/vendor/pygments-main/pygments/styles/pastie.py +75 -0
  118. data/vendor/pygments-main/pygments/styles/perldoc.py +69 -0
  119. data/vendor/pygments-main/pygments/styles/rrt.py +33 -0
  120. data/vendor/pygments-main/pygments/styles/tango.py +141 -0
  121. data/vendor/pygments-main/pygments/styles/trac.py +63 -0
  122. data/vendor/pygments-main/pygments/styles/vim.py +63 -0
  123. data/vendor/pygments-main/pygments/styles/vs.py +38 -0
  124. data/vendor/pygments-main/pygments/token.py +195 -0
  125. data/vendor/pygments-main/pygments/unistring.py +130 -0
  126. data/vendor/pygments-main/pygments/util.py +232 -0
  127. data/vendor/pygments-main/scripts/check_sources.py +242 -0
  128. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +30 -0
  129. data/vendor/pygments-main/scripts/epydoc.css +280 -0
  130. data/vendor/pygments-main/scripts/find_codetags.py +205 -0
  131. data/vendor/pygments-main/scripts/find_error.py +171 -0
  132. data/vendor/pygments-main/scripts/get_vimkw.py +43 -0
  133. data/vendor/pygments-main/scripts/pylintrc +301 -0
  134. data/vendor/pygments-main/scripts/reindent.py +291 -0
  135. data/vendor/pygments-main/scripts/vim2pygments.py +933 -0
  136. data/vendor/pygments-main/setup.cfg +6 -0
  137. data/vendor/pygments-main/setup.py +88 -0
  138. data/vendor/pygments-main/tests/dtds/HTML4-f.dtd +37 -0
  139. data/vendor/pygments-main/tests/dtds/HTML4-s.dtd +869 -0
  140. data/vendor/pygments-main/tests/dtds/HTML4.dcl +88 -0
  141. data/vendor/pygments-main/tests/dtds/HTML4.dtd +1092 -0
  142. data/vendor/pygments-main/tests/dtds/HTML4.soc +9 -0
  143. data/vendor/pygments-main/tests/dtds/HTMLlat1.ent +195 -0
  144. data/vendor/pygments-main/tests/dtds/HTMLspec.ent +77 -0
  145. data/vendor/pygments-main/tests/dtds/HTMLsym.ent +241 -0
  146. data/vendor/pygments-main/tests/examplefiles/ANTLRv3.g +608 -0
  147. data/vendor/pygments-main/tests/examplefiles/AcidStateAdvanced.hs +209 -0
  148. data/vendor/pygments-main/tests/examplefiles/AlternatingGroup.mu +102 -0
  149. data/vendor/pygments-main/tests/examplefiles/CPDictionary.j +611 -0
  150. data/vendor/pygments-main/tests/examplefiles/Constants.mo +158 -0
  151. data/vendor/pygments-main/tests/examplefiles/DancingSudoku.lhs +411 -0
  152. data/vendor/pygments-main/tests/examplefiles/Errors.scala +18 -0
  153. data/vendor/pygments-main/tests/examplefiles/File.hy +174 -0
  154. data/vendor/pygments-main/tests/examplefiles/Intro.java +1660 -0
  155. data/vendor/pygments-main/tests/examplefiles/Makefile +1131 -0
  156. data/vendor/pygments-main/tests/examplefiles/Object.st +4394 -0
  157. data/vendor/pygments-main/tests/examplefiles/OrderedMap.hx +584 -0
  158. data/vendor/pygments-main/tests/examplefiles/SmallCheck.hs +378 -0
  159. data/vendor/pygments-main/tests/examplefiles/Sorting.mod +470 -0
  160. data/vendor/pygments-main/tests/examplefiles/Sudoku.lhs +382 -0
  161. data/vendor/pygments-main/tests/examplefiles/addressbook.proto +30 -0
  162. data/vendor/pygments-main/tests/examplefiles/antlr_throws +1 -0
  163. data/vendor/pygments-main/tests/examplefiles/apache2.conf +393 -0
  164. data/vendor/pygments-main/tests/examplefiles/as3_test.as +143 -0
  165. data/vendor/pygments-main/tests/examplefiles/as3_test2.as +46 -0
  166. data/vendor/pygments-main/tests/examplefiles/as3_test3.as +3 -0
  167. data/vendor/pygments-main/tests/examplefiles/aspx-cs_example +27 -0
  168. data/vendor/pygments-main/tests/examplefiles/badcase.java +2 -0
  169. data/vendor/pygments-main/tests/examplefiles/batchfile.bat +49 -0
  170. data/vendor/pygments-main/tests/examplefiles/boot-9.scm +1557 -0
  171. data/vendor/pygments-main/tests/examplefiles/cells.ps +515 -0
  172. data/vendor/pygments-main/tests/examplefiles/ceval.c +2604 -0
  173. data/vendor/pygments-main/tests/examplefiles/cheetah_example.html +13 -0
  174. data/vendor/pygments-main/tests/examplefiles/classes.dylan +40 -0
  175. data/vendor/pygments-main/tests/examplefiles/condensed_ruby.rb +10 -0
  176. data/vendor/pygments-main/tests/examplefiles/coq_RelationClasses +447 -0
  177. data/vendor/pygments-main/tests/examplefiles/database.pytb +20 -0
  178. data/vendor/pygments-main/tests/examplefiles/de.MoinMoin.po +2461 -0
  179. data/vendor/pygments-main/tests/examplefiles/demo.ahk +181 -0
  180. data/vendor/pygments-main/tests/examplefiles/demo.cfm +38 -0
  181. data/vendor/pygments-main/tests/examplefiles/django_sample.html+django +68 -0
  182. data/vendor/pygments-main/tests/examplefiles/dwarf.cw +17 -0
  183. data/vendor/pygments-main/tests/examplefiles/erl_session +10 -0
  184. data/vendor/pygments-main/tests/examplefiles/escape_semicolon.clj +1 -0
  185. data/vendor/pygments-main/tests/examplefiles/evil_regex.js +48 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.c +2080 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.cls +15 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.cpp +2363 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.gs +106 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.gst +7 -0
  191. data/vendor/pygments-main/tests/examplefiles/example.kt +47 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.lua +250 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.moo +26 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.moon +629 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.nim +1010 -0
  196. data/vendor/pygments-main/tests/examplefiles/example.ns2 +69 -0
  197. data/vendor/pygments-main/tests/examplefiles/example.p +34 -0
  198. data/vendor/pygments-main/tests/examplefiles/example.pas +2708 -0
  199. data/vendor/pygments-main/tests/examplefiles/example.rb +1852 -0
  200. data/vendor/pygments-main/tests/examplefiles/example.rhtml +561 -0
  201. data/vendor/pygments-main/tests/examplefiles/example.sh-session +19 -0
  202. data/vendor/pygments-main/tests/examplefiles/example.sml +156 -0
  203. data/vendor/pygments-main/tests/examplefiles/example.snobol +15 -0
  204. data/vendor/pygments-main/tests/examplefiles/example.tea +34 -0
  205. data/vendor/pygments-main/tests/examplefiles/example.u +548 -0
  206. data/vendor/pygments-main/tests/examplefiles/example.weechatlog +9 -0
  207. data/vendor/pygments-main/tests/examplefiles/example.xhtml +376 -0
  208. data/vendor/pygments-main/tests/examplefiles/example.yaml +302 -0
  209. data/vendor/pygments-main/tests/examplefiles/example2.aspx +29 -0
  210. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +363 -0
  211. data/vendor/pygments-main/tests/examplefiles/example_file.fy +128 -0
  212. data/vendor/pygments-main/tests/examplefiles/firefox.mak +586 -0
  213. data/vendor/pygments-main/tests/examplefiles/flipflop.sv +19 -0
  214. data/vendor/pygments-main/tests/examplefiles/foo.sce +6 -0
  215. data/vendor/pygments-main/tests/examplefiles/format.ml +1213 -0
  216. data/vendor/pygments-main/tests/examplefiles/fucked_up.rb +77 -0
  217. data/vendor/pygments-main/tests/examplefiles/function.mu +1 -0
  218. data/vendor/pygments-main/tests/examplefiles/functional.rst +1472 -0
  219. data/vendor/pygments-main/tests/examplefiles/genclass.clj +510 -0
  220. data/vendor/pygments-main/tests/examplefiles/genshi_example.xml+genshi +193 -0
  221. data/vendor/pygments-main/tests/examplefiles/genshitext_example.genshitext +33 -0
  222. data/vendor/pygments-main/tests/examplefiles/glsl.frag +7 -0
  223. data/vendor/pygments-main/tests/examplefiles/glsl.vert +13 -0
  224. data/vendor/pygments-main/tests/examplefiles/html+php_faulty.php +1 -0
  225. data/vendor/pygments-main/tests/examplefiles/http_request_example +14 -0
  226. data/vendor/pygments-main/tests/examplefiles/http_response_example +27 -0
  227. data/vendor/pygments-main/tests/examplefiles/import.hs +4 -0
  228. data/vendor/pygments-main/tests/examplefiles/intro.ik +24 -0
  229. data/vendor/pygments-main/tests/examplefiles/ints.php +10 -0
  230. data/vendor/pygments-main/tests/examplefiles/intsyn.fun +675 -0
  231. data/vendor/pygments-main/tests/examplefiles/intsyn.sig +286 -0
  232. data/vendor/pygments-main/tests/examplefiles/irb_heredoc +8 -0
  233. data/vendor/pygments-main/tests/examplefiles/irc.lsp +214 -0
  234. data/vendor/pygments-main/tests/examplefiles/java.properties +16 -0
  235. data/vendor/pygments-main/tests/examplefiles/jbst_example1.jbst +28 -0
  236. data/vendor/pygments-main/tests/examplefiles/jbst_example2.jbst +45 -0
  237. data/vendor/pygments-main/tests/examplefiles/jinjadesignerdoc.rst +713 -0
  238. data/vendor/pygments-main/tests/examplefiles/lighttpd_config.conf +13 -0
  239. data/vendor/pygments-main/tests/examplefiles/linecontinuation.py +47 -0
  240. data/vendor/pygments-main/tests/examplefiles/ltmain.sh +2849 -0
  241. data/vendor/pygments-main/tests/examplefiles/main.cmake +42 -0
  242. data/vendor/pygments-main/tests/examplefiles/markdown.lsp +679 -0
  243. data/vendor/pygments-main/tests/examplefiles/matlab_noreturn +3 -0
  244. data/vendor/pygments-main/tests/examplefiles/matlab_sample +27 -0
  245. data/vendor/pygments-main/tests/examplefiles/matlabsession_sample.txt +37 -0
  246. data/vendor/pygments-main/tests/examplefiles/minimal.ns2 +4 -0
  247. data/vendor/pygments-main/tests/examplefiles/moin_SyntaxReference.txt +340 -0
  248. data/vendor/pygments-main/tests/examplefiles/multiline_regexes.rb +38 -0
  249. data/vendor/pygments-main/tests/examplefiles/nasm_aoutso.asm +96 -0
  250. data/vendor/pygments-main/tests/examplefiles/nasm_objexe.asm +30 -0
  251. data/vendor/pygments-main/tests/examplefiles/nemerle_sample.n +87 -0
  252. data/vendor/pygments-main/tests/examplefiles/nginx_nginx.conf +118 -0
  253. data/vendor/pygments-main/tests/examplefiles/numbers.c +12 -0
  254. data/vendor/pygments-main/tests/examplefiles/objc_example.m +25 -0
  255. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +24 -0
  256. data/vendor/pygments-main/tests/examplefiles/perl_misc +62 -0
  257. data/vendor/pygments-main/tests/examplefiles/perl_perl5db +998 -0
  258. data/vendor/pygments-main/tests/examplefiles/perl_regex-delims +120 -0
  259. data/vendor/pygments-main/tests/examplefiles/perlfunc.1 +856 -0
  260. data/vendor/pygments-main/tests/examplefiles/phpcomplete.vim +567 -0
  261. data/vendor/pygments-main/tests/examplefiles/pleac.in.rb +1223 -0
  262. data/vendor/pygments-main/tests/examplefiles/postgresql_test.txt +47 -0
  263. data/vendor/pygments-main/tests/examplefiles/pppoe.applescript +10 -0
  264. data/vendor/pygments-main/tests/examplefiles/psql_session.txt +122 -0
  265. data/vendor/pygments-main/tests/examplefiles/py3_test.txt +2 -0
  266. data/vendor/pygments-main/tests/examplefiles/pycon_test.pycon +14 -0
  267. data/vendor/pygments-main/tests/examplefiles/pytb_test2.pytb +2 -0
  268. data/vendor/pygments-main/tests/examplefiles/python25-bsd.mak +234 -0
  269. data/vendor/pygments-main/tests/examplefiles/qsort.prolog +13 -0
  270. data/vendor/pygments-main/tests/examplefiles/r-console-transcript.Rout +38 -0
  271. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_rlscan +280 -0
  272. data/vendor/pygments-main/tests/examplefiles/ragel-cpp_snippet +2 -0
  273. data/vendor/pygments-main/tests/examplefiles/regex.js +22 -0
  274. data/vendor/pygments-main/tests/examplefiles/reversi.lsp +427 -0
  275. data/vendor/pygments-main/tests/examplefiles/ruby_func_def.rb +11 -0
  276. data/vendor/pygments-main/tests/examplefiles/scilab.sci +30 -0
  277. data/vendor/pygments-main/tests/examplefiles/sibling.prolog +19 -0
  278. data/vendor/pygments-main/tests/examplefiles/simple.md +747 -0
  279. data/vendor/pygments-main/tests/examplefiles/smarty_example.html +209 -0
  280. data/vendor/pygments-main/tests/examplefiles/source.lgt +343 -0
  281. data/vendor/pygments-main/tests/examplefiles/sources.list +62 -0
  282. data/vendor/pygments-main/tests/examplefiles/sphere.pov +18 -0
  283. data/vendor/pygments-main/tests/examplefiles/sqlite3.sqlite3-console +27 -0
  284. data/vendor/pygments-main/tests/examplefiles/squid.conf +30 -0
  285. data/vendor/pygments-main/tests/examplefiles/string.jl +1031 -0
  286. data/vendor/pygments-main/tests/examplefiles/string_delimiters.d +21 -0
  287. data/vendor/pygments-main/tests/examplefiles/stripheredoc.sh +3 -0
  288. data/vendor/pygments-main/tests/examplefiles/test.R +119 -0
  289. data/vendor/pygments-main/tests/examplefiles/test.adb +211 -0
  290. data/vendor/pygments-main/tests/examplefiles/test.asy +131 -0
  291. data/vendor/pygments-main/tests/examplefiles/test.awk +121 -0
  292. data/vendor/pygments-main/tests/examplefiles/test.bas +29 -0
  293. data/vendor/pygments-main/tests/examplefiles/test.bmx +145 -0
  294. data/vendor/pygments-main/tests/examplefiles/test.boo +39 -0
  295. data/vendor/pygments-main/tests/examplefiles/test.bro +250 -0
  296. data/vendor/pygments-main/tests/examplefiles/test.cs +374 -0
  297. data/vendor/pygments-main/tests/examplefiles/test.css +54 -0
  298. data/vendor/pygments-main/tests/examplefiles/test.d +135 -0
  299. data/vendor/pygments-main/tests/examplefiles/test.dart +23 -0
  300. data/vendor/pygments-main/tests/examplefiles/test.dtd +89 -0
  301. data/vendor/pygments-main/tests/examplefiles/test.ec +605 -0
  302. data/vendor/pygments-main/tests/examplefiles/test.ecl +58 -0
  303. data/vendor/pygments-main/tests/examplefiles/test.eh +315 -0
  304. data/vendor/pygments-main/tests/examplefiles/test.erl +169 -0
  305. data/vendor/pygments-main/tests/examplefiles/test.evoque +33 -0
  306. data/vendor/pygments-main/tests/examplefiles/test.fan +818 -0
  307. data/vendor/pygments-main/tests/examplefiles/test.flx +57 -0
  308. data/vendor/pygments-main/tests/examplefiles/test.gdc +13 -0
  309. data/vendor/pygments-main/tests/examplefiles/test.groovy +97 -0
  310. data/vendor/pygments-main/tests/examplefiles/test.html +339 -0
  311. data/vendor/pygments-main/tests/examplefiles/test.ini +10 -0
  312. data/vendor/pygments-main/tests/examplefiles/test.java +653 -0
  313. data/vendor/pygments-main/tests/examplefiles/test.jsp +24 -0
  314. data/vendor/pygments-main/tests/examplefiles/test.maql +45 -0
  315. data/vendor/pygments-main/tests/examplefiles/test.mod +374 -0
  316. data/vendor/pygments-main/tests/examplefiles/test.moo +51 -0
  317. data/vendor/pygments-main/tests/examplefiles/test.myt +166 -0
  318. data/vendor/pygments-main/tests/examplefiles/test.nim +93 -0
  319. data/vendor/pygments-main/tests/examplefiles/test.pas +743 -0
  320. data/vendor/pygments-main/tests/examplefiles/test.php +505 -0
  321. data/vendor/pygments-main/tests/examplefiles/test.plot +333 -0
  322. data/vendor/pygments-main/tests/examplefiles/test.ps1 +108 -0
  323. data/vendor/pygments-main/tests/examplefiles/test.pypylog +1839 -0
  324. data/vendor/pygments-main/tests/examplefiles/test.r3 +94 -0
  325. data/vendor/pygments-main/tests/examplefiles/test.rb +177 -0
  326. data/vendor/pygments-main/tests/examplefiles/test.rhtml +43 -0
  327. data/vendor/pygments-main/tests/examplefiles/test.scaml +8 -0
  328. data/vendor/pygments-main/tests/examplefiles/test.ssp +12 -0
  329. data/vendor/pygments-main/tests/examplefiles/test.tcsh +830 -0
  330. data/vendor/pygments-main/tests/examplefiles/test.vb +407 -0
  331. data/vendor/pygments-main/tests/examplefiles/test.vhdl +161 -0
  332. data/vendor/pygments-main/tests/examplefiles/test.xqy +138 -0
  333. data/vendor/pygments-main/tests/examplefiles/test.xsl +23 -0
  334. data/vendor/pygments-main/tests/examplefiles/truncated.pytb +15 -0
  335. data/vendor/pygments-main/tests/examplefiles/type.lisp +1202 -0
  336. data/vendor/pygments-main/tests/examplefiles/underscore.coffee +603 -0
  337. data/vendor/pygments-main/tests/examplefiles/unicode.applescript +5 -0
  338. data/vendor/pygments-main/tests/examplefiles/unicodedoc.py +11 -0
  339. data/vendor/pygments-main/tests/examplefiles/webkit-transition.css +3 -0
  340. data/vendor/pygments-main/tests/examplefiles/while.pov +13 -0
  341. data/vendor/pygments-main/tests/examplefiles/wiki.factor +384 -0
  342. data/vendor/pygments-main/tests/examplefiles/xml_example +1897 -0
  343. data/vendor/pygments-main/tests/examplefiles/zmlrpc.f90 +798 -0
  344. data/vendor/pygments-main/tests/old_run.py +138 -0
  345. data/vendor/pygments-main/tests/run.py +48 -0
  346. data/vendor/pygments-main/tests/support.py +15 -0
  347. data/vendor/pygments-main/tests/test_basic_api.py +294 -0
  348. data/vendor/pygments-main/tests/test_clexer.py +31 -0
  349. data/vendor/pygments-main/tests/test_cmdline.py +105 -0
  350. data/vendor/pygments-main/tests/test_examplefiles.py +97 -0
  351. data/vendor/pygments-main/tests/test_html_formatter.py +162 -0
  352. data/vendor/pygments-main/tests/test_latex_formatter.py +55 -0
  353. data/vendor/pygments-main/tests/test_perllexer.py +137 -0
  354. data/vendor/pygments-main/tests/test_regexlexer.py +47 -0
  355. data/vendor/pygments-main/tests/test_token.py +46 -0
  356. data/vendor/pygments-main/tests/test_using_api.py +40 -0
  357. data/vendor/pygments-main/tests/test_util.py +116 -0
  358. data/vendor/simplejson/.gitignore +10 -0
  359. data/vendor/simplejson/.travis.yml +5 -0
  360. data/vendor/simplejson/CHANGES.txt +291 -0
  361. data/vendor/simplejson/LICENSE.txt +19 -0
  362. data/vendor/simplejson/MANIFEST.in +5 -0
  363. data/vendor/simplejson/README.rst +19 -0
  364. data/vendor/simplejson/conf.py +179 -0
  365. data/vendor/simplejson/index.rst +628 -0
  366. data/vendor/simplejson/scripts/make_docs.py +18 -0
  367. data/vendor/simplejson/setup.py +104 -0
  368. data/vendor/simplejson/simplejson/__init__.py +510 -0
  369. data/vendor/simplejson/simplejson/_speedups.c +2745 -0
  370. data/vendor/simplejson/simplejson/decoder.py +425 -0
  371. data/vendor/simplejson/simplejson/encoder.py +567 -0
  372. data/vendor/simplejson/simplejson/ordered_dict.py +119 -0
  373. data/vendor/simplejson/simplejson/scanner.py +77 -0
  374. data/vendor/simplejson/simplejson/tests/__init__.py +67 -0
  375. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +55 -0
  376. data/vendor/simplejson/simplejson/tests/test_check_circular.py +30 -0
  377. data/vendor/simplejson/simplejson/tests/test_decimal.py +66 -0
  378. data/vendor/simplejson/simplejson/tests/test_decode.py +83 -0
  379. data/vendor/simplejson/simplejson/tests/test_default.py +9 -0
  380. data/vendor/simplejson/simplejson/tests/test_dump.py +67 -0
  381. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +46 -0
  382. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +32 -0
  383. data/vendor/simplejson/simplejson/tests/test_errors.py +34 -0
  384. data/vendor/simplejson/simplejson/tests/test_fail.py +91 -0
  385. data/vendor/simplejson/simplejson/tests/test_float.py +19 -0
  386. data/vendor/simplejson/simplejson/tests/test_indent.py +86 -0
  387. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +20 -0
  388. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +121 -0
  389. data/vendor/simplejson/simplejson/tests/test_pass1.py +76 -0
  390. data/vendor/simplejson/simplejson/tests/test_pass2.py +14 -0
  391. data/vendor/simplejson/simplejson/tests/test_pass3.py +20 -0
  392. data/vendor/simplejson/simplejson/tests/test_recursion.py +67 -0
  393. data/vendor/simplejson/simplejson/tests/test_scanstring.py +117 -0
  394. data/vendor/simplejson/simplejson/tests/test_separators.py +42 -0
  395. data/vendor/simplejson/simplejson/tests/test_speedups.py +20 -0
  396. data/vendor/simplejson/simplejson/tests/test_tuple.py +49 -0
  397. data/vendor/simplejson/simplejson/tests/test_unicode.py +109 -0
  398. data/vendor/simplejson/simplejson/tool.py +39 -0
  399. 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'&amp;',
27
+ ord('<'): u'&lt;',
28
+ ord('>'): u'&gt;',
29
+ ord('"'): u'&quot;',
30
+ ord("'"): u'&#39;',
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
+ }