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,1753 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.text
4
+ ~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for non-source code file types.
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
+ from bisect import bisect
14
+
15
+ from pygments.lexer import Lexer, LexerContext, RegexLexer, ExtendedRegexLexer, \
16
+ bygroups, include, using, this, do_insertions
17
+ from pygments.token import Punctuation, Text, Comment, Keyword, Name, String, \
18
+ Generic, Operator, Number, Whitespace, Literal
19
+ from pygments.util import get_bool_opt, ClassNotFound
20
+ from pygments.lexers.other import BashLexer
21
+
22
+ __all__ = ['IniLexer', 'PropertiesLexer', 'SourcesListLexer', 'BaseMakefileLexer',
23
+ 'MakefileLexer', 'DiffLexer', 'IrcLogsLexer', 'TexLexer',
24
+ 'GroffLexer', 'ApacheConfLexer', 'BBCodeLexer', 'MoinWikiLexer',
25
+ 'RstLexer', 'VimLexer', 'GettextLexer', 'SquidConfLexer',
26
+ 'DebianControlLexer', 'DarcsPatchLexer', 'YamlLexer',
27
+ 'LighttpdConfLexer', 'NginxConfLexer', 'CMakeLexer', 'HttpLexer',
28
+ 'PyPyLogLexer']
29
+
30
+
31
+ class IniLexer(RegexLexer):
32
+ """
33
+ Lexer for configuration files in INI style.
34
+ """
35
+
36
+ name = 'INI'
37
+ aliases = ['ini', 'cfg']
38
+ filenames = ['*.ini', '*.cfg']
39
+ mimetypes = ['text/x-ini']
40
+
41
+ tokens = {
42
+ 'root': [
43
+ (r'\s+', Text),
44
+ (r'[;#].*?$', Comment),
45
+ (r'\[.*?\]$', Keyword),
46
+ (r'(.*?)([ \t]*)(=)([ \t]*)(.*(?:\n[ \t].+)*)',
47
+ bygroups(Name.Attribute, Text, Operator, Text, String))
48
+ ]
49
+ }
50
+
51
+ def analyse_text(text):
52
+ npos = text.find('\n')
53
+ if npos < 3:
54
+ return False
55
+ return text[0] == '[' and text[npos-1] == ']'
56
+
57
+
58
+ class PropertiesLexer(RegexLexer):
59
+ """
60
+ Lexer for configuration files in Java's properties format.
61
+
62
+ *New in Pygments 1.4.*
63
+ """
64
+
65
+ name = 'Properties'
66
+ aliases = ['properties']
67
+ filenames = ['*.properties']
68
+ mimetypes = ['text/x-java-properties']
69
+
70
+ tokens = {
71
+ 'root': [
72
+ (r'\s+', Text),
73
+ (r'(?:[;#]|//).*$', Comment),
74
+ (r'(.*?)([ \t]*)([=:])([ \t]*)(.*(?:(?<=\\)\n.*)*)',
75
+ bygroups(Name.Attribute, Text, Operator, Text, String)),
76
+ ],
77
+ }
78
+
79
+
80
+ class SourcesListLexer(RegexLexer):
81
+ """
82
+ Lexer that highlights debian sources.list files.
83
+
84
+ *New in Pygments 0.7.*
85
+ """
86
+
87
+ name = 'Debian Sourcelist'
88
+ aliases = ['sourceslist', 'sources.list']
89
+ filenames = ['sources.list']
90
+ mimetype = ['application/x-debian-sourceslist']
91
+
92
+ tokens = {
93
+ 'root': [
94
+ (r'\s+', Text),
95
+ (r'#.*?$', Comment),
96
+ (r'^(deb(?:-src)?)(\s+)',
97
+ bygroups(Keyword, Text), 'distribution')
98
+ ],
99
+ 'distribution': [
100
+ (r'#.*?$', Comment, '#pop'),
101
+ (r'\$\(ARCH\)', Name.Variable),
102
+ (r'[^\s$[]+', String),
103
+ (r'\[', String.Other, 'escaped-distribution'),
104
+ (r'\$', String),
105
+ (r'\s+', Text, 'components')
106
+ ],
107
+ 'escaped-distribution': [
108
+ (r'\]', String.Other, '#pop'),
109
+ (r'\$\(ARCH\)', Name.Variable),
110
+ (r'[^\]$]+', String.Other),
111
+ (r'\$', String.Other)
112
+ ],
113
+ 'components': [
114
+ (r'#.*?$', Comment, '#pop:2'),
115
+ (r'$', Text, '#pop:2'),
116
+ (r'\s+', Text),
117
+ (r'\S+', Keyword.Pseudo),
118
+ ]
119
+ }
120
+
121
+ def analyse_text(text):
122
+ for line in text.split('\n'):
123
+ line = line.strip()
124
+ if not (line.startswith('#') or line.startswith('deb ') or
125
+ line.startswith('deb-src ') or not line):
126
+ return False
127
+ return True
128
+
129
+
130
+ class MakefileLexer(Lexer):
131
+ """
132
+ Lexer for BSD and GNU make extensions (lenient enough to handle both in
133
+ the same file even).
134
+
135
+ *Rewritten in Pygments 0.10.*
136
+ """
137
+
138
+ name = 'Makefile'
139
+ aliases = ['make', 'makefile', 'mf', 'bsdmake']
140
+ filenames = ['*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile']
141
+ mimetypes = ['text/x-makefile']
142
+
143
+ r_special = re.compile(r'^(?:'
144
+ # BSD Make
145
+ r'\.\s*(include|undef|error|warning|if|else|elif|endif|for|endfor)|'
146
+ # GNU Make
147
+ r'\s*(ifeq|ifneq|ifdef|ifndef|else|endif|-?include|define|endef|:))(?=\s)')
148
+ r_comment = re.compile(r'^\s*@?#')
149
+
150
+ def get_tokens_unprocessed(self, text):
151
+ ins = []
152
+ lines = text.splitlines(True)
153
+ done = ''
154
+ lex = BaseMakefileLexer(**self.options)
155
+ backslashflag = False
156
+ for line in lines:
157
+ if self.r_special.match(line) or backslashflag:
158
+ ins.append((len(done), [(0, Comment.Preproc, line)]))
159
+ backslashflag = line.strip().endswith('\\')
160
+ elif self.r_comment.match(line):
161
+ ins.append((len(done), [(0, Comment, line)]))
162
+ else:
163
+ done += line
164
+ for item in do_insertions(ins, lex.get_tokens_unprocessed(done)):
165
+ yield item
166
+
167
+
168
+ class BaseMakefileLexer(RegexLexer):
169
+ """
170
+ Lexer for simple Makefiles (no preprocessing).
171
+
172
+ *New in Pygments 0.10.*
173
+ """
174
+
175
+ name = 'Base Makefile'
176
+ aliases = ['basemake']
177
+ filenames = []
178
+ mimetypes = []
179
+
180
+ tokens = {
181
+ 'root': [
182
+ (r'^(?:[\t ]+.*\n|\n)+', using(BashLexer)),
183
+ (r'\$\((?:.*\\\n|.*\n)+', using(BashLexer)),
184
+ (r'\s+', Text),
185
+ (r'#.*?\n', Comment),
186
+ (r'(export)(\s+)(?=[a-zA-Z0-9_${}\t -]+\n)',
187
+ bygroups(Keyword, Text), 'export'),
188
+ (r'export\s+', Keyword),
189
+ # assignment
190
+ (r'([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)([ \t]*)((?:.*\\\n|.*\n)+)',
191
+ bygroups(Name.Variable, Text, Operator, Text, using(BashLexer))),
192
+ # strings
193
+ (r'(?s)"(\\\\|\\.|[^"\\])*"', String.Double),
194
+ (r"(?s)'(\\\\|\\.|[^'\\])*'", String.Single),
195
+ # targets
196
+ (r'([^\n:]+)(:+)([ \t]*)', bygroups(Name.Function, Operator, Text),
197
+ 'block-header'),
198
+ # TODO: add paren handling (grr)
199
+ ],
200
+ 'export': [
201
+ (r'[a-zA-Z0-9_${}-]+', Name.Variable),
202
+ (r'\n', Text, '#pop'),
203
+ (r'\s+', Text),
204
+ ],
205
+ 'block-header': [
206
+ (r'[^,\\\n#]+', Number),
207
+ (r',', Punctuation),
208
+ (r'#.*?\n', Comment),
209
+ (r'\\\n', Text), # line continuation
210
+ (r'\\.', Text),
211
+ (r'(?:[\t ]+.*\n|\n)+', using(BashLexer), '#pop'),
212
+ ],
213
+ }
214
+
215
+
216
+ class DiffLexer(RegexLexer):
217
+ """
218
+ Lexer for unified or context-style diffs or patches.
219
+ """
220
+
221
+ name = 'Diff'
222
+ aliases = ['diff', 'udiff']
223
+ filenames = ['*.diff', '*.patch']
224
+ mimetypes = ['text/x-diff', 'text/x-patch']
225
+
226
+ tokens = {
227
+ 'root': [
228
+ (r' .*\n', Text),
229
+ (r'\+.*\n', Generic.Inserted),
230
+ (r'-.*\n', Generic.Deleted),
231
+ (r'!.*\n', Generic.Strong),
232
+ (r'@.*\n', Generic.Subheading),
233
+ (r'([Ii]ndex|diff).*\n', Generic.Heading),
234
+ (r'=.*\n', Generic.Heading),
235
+ (r'.*\n', Text),
236
+ ]
237
+ }
238
+
239
+ def analyse_text(text):
240
+ if text[:7] == 'Index: ':
241
+ return True
242
+ if text[:5] == 'diff ':
243
+ return True
244
+ if text[:4] == '--- ':
245
+ return 0.9
246
+
247
+
248
+ DPATCH_KEYWORDS = ['hunk', 'addfile', 'adddir', 'rmfile', 'rmdir', 'move',
249
+ 'replace']
250
+
251
+ class DarcsPatchLexer(RegexLexer):
252
+ """
253
+ DarcsPatchLexer is a lexer for the various versions of the darcs patch
254
+ format. Examples of this format are derived by commands such as
255
+ ``darcs annotate --patch`` and ``darcs send``.
256
+
257
+ *New in Pygments 0.10.*
258
+ """
259
+ name = 'Darcs Patch'
260
+ aliases = ['dpatch']
261
+ filenames = ['*.dpatch', '*.darcspatch']
262
+
263
+ tokens = {
264
+ 'root': [
265
+ (r'<', Operator),
266
+ (r'>', Operator),
267
+ (r'{', Operator),
268
+ (r'}', Operator),
269
+ (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)(\])',
270
+ bygroups(Operator, Keyword, Name, Text, Name, Operator,
271
+ Literal.Date, Text, Operator)),
272
+ (r'(\[)((?:TAG )?)(.*)(\n)(.*)(\*\*)(\d+)(\s?)',
273
+ bygroups(Operator, Keyword, Name, Text, Name, Operator,
274
+ Literal.Date, Text), 'comment'),
275
+ (r'New patches:', Generic.Heading),
276
+ (r'Context:', Generic.Heading),
277
+ (r'Patch bundle hash:', Generic.Heading),
278
+ (r'(\s*)(%s)(.*\n)' % '|'.join(DPATCH_KEYWORDS),
279
+ bygroups(Text, Keyword, Text)),
280
+ (r'\+', Generic.Inserted, "insert"),
281
+ (r'-', Generic.Deleted, "delete"),
282
+ (r'.*\n', Text),
283
+ ],
284
+ 'comment': [
285
+ (r'[^\]].*\n', Comment),
286
+ (r'\]', Operator, "#pop"),
287
+ ],
288
+ 'specialText': [ # darcs add [_CODE_] special operators for clarity
289
+ (r'\n', Text, "#pop"), # line-based
290
+ (r'\[_[^_]*_]', Operator),
291
+ ],
292
+ 'insert': [
293
+ include('specialText'),
294
+ (r'\[', Generic.Inserted),
295
+ (r'[^\n\[]+', Generic.Inserted),
296
+ ],
297
+ 'delete': [
298
+ include('specialText'),
299
+ (r'\[', Generic.Deleted),
300
+ (r'[^\n\[]+', Generic.Deleted),
301
+ ],
302
+ }
303
+
304
+
305
+ class IrcLogsLexer(RegexLexer):
306
+ """
307
+ Lexer for IRC logs in *irssi*, *xchat* or *weechat* style.
308
+ """
309
+
310
+ name = 'IRC logs'
311
+ aliases = ['irc']
312
+ filenames = ['*.weechatlog']
313
+ mimetypes = ['text/x-irclog']
314
+
315
+ flags = re.VERBOSE | re.MULTILINE
316
+ timestamp = r"""
317
+ (
318
+ # irssi / xchat and others
319
+ (?: \[|\()? # Opening bracket or paren for the timestamp
320
+ (?: # Timestamp
321
+ (?: (?:\d{1,4} [-/]?)+ # Date as - or /-separated groups of digits
322
+ [T ])? # Date/time separator: T or space
323
+ (?: \d?\d [:.]?)+ # Time as :/.-separated groups of 1 or 2 digits
324
+ )
325
+ (?: \]|\))?\s+ # Closing bracket or paren for the timestamp
326
+ |
327
+ # weechat
328
+ \d{4}\s\w{3}\s\d{2}\s # Date
329
+ \d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
330
+ |
331
+ # xchat
332
+ \w{3}\s\d{2}\s # Date
333
+ \d{2}:\d{2}:\d{2}\s+ # Time + Whitespace
334
+ )?
335
+ """
336
+ tokens = {
337
+ 'root': [
338
+ # log start/end
339
+ (r'^\*\*\*\*(.*)\*\*\*\*$', Comment),
340
+ # hack
341
+ ("^" + timestamp + r'(\s*<[^>]*>\s*)$', bygroups(Comment.Preproc, Name.Tag)),
342
+ # normal msgs
343
+ ("^" + timestamp + r"""
344
+ (\s*<.*?>\s*) # Nick """,
345
+ bygroups(Comment.Preproc, Name.Tag), 'msg'),
346
+ # /me msgs
347
+ ("^" + timestamp + r"""
348
+ (\s*[*]\s+) # Star
349
+ (\S+\s+.*?\n) # Nick + rest of message """,
350
+ bygroups(Comment.Preproc, Keyword, Generic.Inserted)),
351
+ # join/part msgs
352
+ ("^" + timestamp + r"""
353
+ (\s*(?:\*{3}|<?-[!@=P]?->?)\s*) # Star(s) or symbols
354
+ (\S+\s+) # Nick + Space
355
+ (.*?\n) # Rest of message """,
356
+ bygroups(Comment.Preproc, Keyword, String, Comment)),
357
+ (r"^.*?\n", Text),
358
+ ],
359
+ 'msg': [
360
+ (r"\S+:(?!//)", Name.Attribute), # Prefix
361
+ (r".*\n", Text, '#pop'),
362
+ ],
363
+ }
364
+
365
+
366
+ class BBCodeLexer(RegexLexer):
367
+ """
368
+ A lexer that highlights BBCode(-like) syntax.
369
+
370
+ *New in Pygments 0.6.*
371
+ """
372
+
373
+ name = 'BBCode'
374
+ aliases = ['bbcode']
375
+ mimetypes = ['text/x-bbcode']
376
+
377
+ tokens = {
378
+ 'root': [
379
+ (r'[^[]+', Text),
380
+ # tag/end tag begin
381
+ (r'\[/?\w+', Keyword, 'tag'),
382
+ # stray bracket
383
+ (r'\[', Text),
384
+ ],
385
+ 'tag': [
386
+ (r'\s+', Text),
387
+ # attribute with value
388
+ (r'(\w+)(=)("?[^\s"\]]+"?)',
389
+ bygroups(Name.Attribute, Operator, String)),
390
+ # tag argument (a la [color=green])
391
+ (r'(=)("?[^\s"\]]+"?)',
392
+ bygroups(Operator, String)),
393
+ # tag end
394
+ (r'\]', Keyword, '#pop'),
395
+ ],
396
+ }
397
+
398
+
399
+ class TexLexer(RegexLexer):
400
+ """
401
+ Lexer for the TeX and LaTeX typesetting languages.
402
+ """
403
+
404
+ name = 'TeX'
405
+ aliases = ['tex', 'latex']
406
+ filenames = ['*.tex', '*.aux', '*.toc']
407
+ mimetypes = ['text/x-tex', 'text/x-latex']
408
+
409
+ tokens = {
410
+ 'general': [
411
+ (r'%.*?\n', Comment),
412
+ (r'[{}]', Name.Builtin),
413
+ (r'[&_^]', Name.Builtin),
414
+ ],
415
+ 'root': [
416
+ (r'\\\[', String.Backtick, 'displaymath'),
417
+ (r'\\\(', String, 'inlinemath'),
418
+ (r'\$\$', String.Backtick, 'displaymath'),
419
+ (r'\$', String, 'inlinemath'),
420
+ (r'\\([a-zA-Z]+|.)', Keyword, 'command'),
421
+ include('general'),
422
+ (r'[^\\$%&_^{}]+', Text),
423
+ ],
424
+ 'math': [
425
+ (r'\\([a-zA-Z]+|.)', Name.Variable),
426
+ include('general'),
427
+ (r'[0-9]+', Number),
428
+ (r'[-=!+*/()\[\]]', Operator),
429
+ (r'[^=!+*/()\[\]\\$%&_^{}0-9-]+', Name.Builtin),
430
+ ],
431
+ 'inlinemath': [
432
+ (r'\\\)', String, '#pop'),
433
+ (r'\$', String, '#pop'),
434
+ include('math'),
435
+ ],
436
+ 'displaymath': [
437
+ (r'\\\]', String, '#pop'),
438
+ (r'\$\$', String, '#pop'),
439
+ (r'\$', Name.Builtin),
440
+ include('math'),
441
+ ],
442
+ 'command': [
443
+ (r'\[.*?\]', Name.Attribute),
444
+ (r'\*', Keyword),
445
+ (r'', Text, '#pop'),
446
+ ],
447
+ }
448
+
449
+ def analyse_text(text):
450
+ for start in ("\\documentclass", "\\input", "\\documentstyle",
451
+ "\\relax"):
452
+ if text[:len(start)] == start:
453
+ return True
454
+
455
+
456
+ class GroffLexer(RegexLexer):
457
+ """
458
+ Lexer for the (g)roff typesetting language, supporting groff
459
+ extensions. Mainly useful for highlighting manpage sources.
460
+
461
+ *New in Pygments 0.6.*
462
+ """
463
+
464
+ name = 'Groff'
465
+ aliases = ['groff', 'nroff', 'man']
466
+ filenames = ['*.[1234567]', '*.man']
467
+ mimetypes = ['application/x-troff', 'text/troff']
468
+
469
+ tokens = {
470
+ 'root': [
471
+ (r'(\.)(\w+)', bygroups(Text, Keyword), 'request'),
472
+ (r'\.', Punctuation, 'request'),
473
+ # Regular characters, slurp till we find a backslash or newline
474
+ (r'[^\\\n]*', Text, 'textline'),
475
+ ],
476
+ 'textline': [
477
+ include('escapes'),
478
+ (r'[^\\\n]+', Text),
479
+ (r'\n', Text, '#pop'),
480
+ ],
481
+ 'escapes': [
482
+ # groff has many ways to write escapes.
483
+ (r'\\"[^\n]*', Comment),
484
+ (r'\\[fn]\w', String.Escape),
485
+ (r'\\\(.{2}', String.Escape),
486
+ (r'\\.\[.*\]', String.Escape),
487
+ (r'\\.', String.Escape),
488
+ (r'\\\n', Text, 'request'),
489
+ ],
490
+ 'request': [
491
+ (r'\n', Text, '#pop'),
492
+ include('escapes'),
493
+ (r'"[^\n"]+"', String.Double),
494
+ (r'\d+', Number),
495
+ (r'\S+', String),
496
+ (r'\s+', Text),
497
+ ],
498
+ }
499
+
500
+ def analyse_text(text):
501
+ if text[:1] != '.':
502
+ return False
503
+ if text[:3] == '.\\"':
504
+ return True
505
+ if text[:4] == '.TH ':
506
+ return True
507
+ if text[1:3].isalnum() and text[3].isspace():
508
+ return 0.9
509
+
510
+
511
+ class ApacheConfLexer(RegexLexer):
512
+ """
513
+ Lexer for configuration files following the Apache config file
514
+ format.
515
+
516
+ *New in Pygments 0.6.*
517
+ """
518
+
519
+ name = 'ApacheConf'
520
+ aliases = ['apacheconf', 'aconf', 'apache']
521
+ filenames = ['.htaccess', 'apache.conf', 'apache2.conf']
522
+ mimetypes = ['text/x-apacheconf']
523
+ flags = re.MULTILINE | re.IGNORECASE
524
+
525
+ tokens = {
526
+ 'root': [
527
+ (r'\s+', Text),
528
+ (r'(#.*?)$', Comment),
529
+ (r'(<[^\s>]+)(?:(\s+)(.*?))?(>)',
530
+ bygroups(Name.Tag, Text, String, Name.Tag)),
531
+ (r'([a-zA-Z][a-zA-Z0-9_]*)(\s+)',
532
+ bygroups(Name.Builtin, Text), 'value'),
533
+ (r'\.+', Text),
534
+ ],
535
+ 'value': [
536
+ (r'$', Text, '#pop'),
537
+ (r'[^\S\n]+', Text),
538
+ (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
539
+ (r'\d+', Number),
540
+ (r'/([a-zA-Z0-9][a-zA-Z0-9_./-]+)', String.Other),
541
+ (r'(on|off|none|any|all|double|email|dns|min|minimal|'
542
+ r'os|productonly|full|emerg|alert|crit|error|warn|'
543
+ r'notice|info|debug|registry|script|inetd|standalone|'
544
+ r'user|group)\b', Keyword),
545
+ (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
546
+ (r'[^\s"]+', Text)
547
+ ]
548
+ }
549
+
550
+
551
+ class MoinWikiLexer(RegexLexer):
552
+ """
553
+ For MoinMoin (and Trac) Wiki markup.
554
+
555
+ *New in Pygments 0.7.*
556
+ """
557
+
558
+ name = 'MoinMoin/Trac Wiki markup'
559
+ aliases = ['trac-wiki', 'moin']
560
+ filenames = []
561
+ mimetypes = ['text/x-trac-wiki']
562
+ flags = re.MULTILINE | re.IGNORECASE
563
+
564
+ tokens = {
565
+ 'root': [
566
+ (r'^#.*$', Comment),
567
+ (r'(!)(\S+)', bygroups(Keyword, Text)), # Ignore-next
568
+ # Titles
569
+ (r'^(=+)([^=]+)(=+)(\s*#.+)?$',
570
+ bygroups(Generic.Heading, using(this), Generic.Heading, String)),
571
+ # Literal code blocks, with optional shebang
572
+ (r'({{{)(\n#!.+)?', bygroups(Name.Builtin, Name.Namespace), 'codeblock'),
573
+ (r'(\'\'\'?|\|\||`|__|~~|\^|,,|::)', Comment), # Formatting
574
+ # Lists
575
+ (r'^( +)([.*-])( )', bygroups(Text, Name.Builtin, Text)),
576
+ (r'^( +)([a-zivx]{1,5}\.)( )', bygroups(Text, Name.Builtin, Text)),
577
+ # Other Formatting
578
+ (r'\[\[\w+.*?\]\]', Keyword), # Macro
579
+ (r'(\[[^\s\]]+)(\s+[^\]]+?)?(\])',
580
+ bygroups(Keyword, String, Keyword)), # Link
581
+ (r'^----+$', Keyword), # Horizontal rules
582
+ (r'[^\n\'\[{!_~^,|]+', Text),
583
+ (r'\n', Text),
584
+ (r'.', Text),
585
+ ],
586
+ 'codeblock': [
587
+ (r'}}}', Name.Builtin, '#pop'),
588
+ # these blocks are allowed to be nested in Trac, but not MoinMoin
589
+ (r'{{{', Text, '#push'),
590
+ (r'[^{}]+', Comment.Preproc), # slurp boring text
591
+ (r'.', Comment.Preproc), # allow loose { or }
592
+ ],
593
+ }
594
+
595
+
596
+ class RstLexer(RegexLexer):
597
+ """
598
+ For `reStructuredText <http://docutils.sf.net/rst.html>`_ markup.
599
+
600
+ *New in Pygments 0.7.*
601
+
602
+ Additional options accepted:
603
+
604
+ `handlecodeblocks`
605
+ Highlight the contents of ``.. sourcecode:: langauge`` and
606
+ ``.. code:: language`` directives with a lexer for the given
607
+ language (default: ``True``). *New in Pygments 0.8.*
608
+ """
609
+ name = 'reStructuredText'
610
+ aliases = ['rst', 'rest', 'restructuredtext']
611
+ filenames = ['*.rst', '*.rest']
612
+ mimetypes = ["text/x-rst", "text/prs.fallenstein.rst"]
613
+ flags = re.MULTILINE
614
+
615
+ def _handle_sourcecode(self, match):
616
+ from pygments.lexers import get_lexer_by_name
617
+
618
+ # section header
619
+ yield match.start(1), Punctuation, match.group(1)
620
+ yield match.start(2), Text, match.group(2)
621
+ yield match.start(3), Operator.Word, match.group(3)
622
+ yield match.start(4), Punctuation, match.group(4)
623
+ yield match.start(5), Text, match.group(5)
624
+ yield match.start(6), Keyword, match.group(6)
625
+ yield match.start(7), Text, match.group(7)
626
+
627
+ # lookup lexer if wanted and existing
628
+ lexer = None
629
+ if self.handlecodeblocks:
630
+ try:
631
+ lexer = get_lexer_by_name(match.group(6).strip())
632
+ except ClassNotFound:
633
+ pass
634
+ indention = match.group(8)
635
+ indention_size = len(indention)
636
+ code = (indention + match.group(9) + match.group(10) + match.group(11))
637
+
638
+ # no lexer for this language. handle it like it was a code block
639
+ if lexer is None:
640
+ yield match.start(8), String, code
641
+ return
642
+
643
+ # highlight the lines with the lexer.
644
+ ins = []
645
+ codelines = code.splitlines(True)
646
+ code = ''
647
+ for line in codelines:
648
+ if len(line) > indention_size:
649
+ ins.append((len(code), [(0, Text, line[:indention_size])]))
650
+ code += line[indention_size:]
651
+ else:
652
+ code += line
653
+ for item in do_insertions(ins, lexer.get_tokens_unprocessed(code)):
654
+ yield item
655
+
656
+ # from docutils.parsers.rst.states
657
+ closers = u'\'")]}>\u2019\u201d\xbb!?'
658
+ unicode_delimiters = u'\u2010\u2011\u2012\u2013\u2014\u00a0'
659
+ end_string_suffix = (r'((?=$)|(?=[-/:.,; \n\x00%s%s]))'
660
+ % (re.escape(unicode_delimiters),
661
+ re.escape(closers)))
662
+
663
+ tokens = {
664
+ 'root': [
665
+ # Heading with overline
666
+ (r'^(=+|-+|`+|:+|\.+|\'+|"+|~+|\^+|_+|\*+|\++|#+)([ \t]*\n)'
667
+ r'(.+)(\n)(\1)(\n)',
668
+ bygroups(Generic.Heading, Text, Generic.Heading,
669
+ Text, Generic.Heading, Text)),
670
+ # Plain heading
671
+ (r'^(\S.*)(\n)(={3,}|-{3,}|`{3,}|:{3,}|\.{3,}|\'{3,}|"{3,}|'
672
+ r'~{3,}|\^{3,}|_{3,}|\*{3,}|\+{3,}|#{3,})(\n)',
673
+ bygroups(Generic.Heading, Text, Generic.Heading, Text)),
674
+ # Bulleted lists
675
+ (r'^(\s*)([-*+])( .+\n(?:\1 .+\n)*)',
676
+ bygroups(Text, Number, using(this, state='inline'))),
677
+ # Numbered lists
678
+ (r'^(\s*)([0-9#ivxlcmIVXLCM]+\.)( .+\n(?:\1 .+\n)*)',
679
+ bygroups(Text, Number, using(this, state='inline'))),
680
+ (r'^(\s*)(\(?[0-9#ivxlcmIVXLCM]+\))( .+\n(?:\1 .+\n)*)',
681
+ bygroups(Text, Number, using(this, state='inline'))),
682
+ # Numbered, but keep words at BOL from becoming lists
683
+ (r'^(\s*)([A-Z]+\.)( .+\n(?:\1 .+\n)+)',
684
+ bygroups(Text, Number, using(this, state='inline'))),
685
+ (r'^(\s*)(\(?[A-Za-z]+\))( .+\n(?:\1 .+\n)+)',
686
+ bygroups(Text, Number, using(this, state='inline'))),
687
+ # Line blocks
688
+ (r'^(\s*)(\|)( .+\n(?:\| .+\n)*)',
689
+ bygroups(Text, Operator, using(this, state='inline'))),
690
+ # Sourcecode directives
691
+ (r'^( *\.\.)(\s*)((?:source)?code)(::)([ \t]*)([^\n]+)'
692
+ r'(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\8.*|)\n)+)',
693
+ _handle_sourcecode),
694
+ # A directive
695
+ (r'^( *\.\.)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
696
+ bygroups(Punctuation, Text, Operator.Word, Punctuation, Text,
697
+ using(this, state='inline'))),
698
+ # A reference target
699
+ (r'^( *\.\.)(\s*)(_(?:[^:\\]|\\.)+:)(.*?)$',
700
+ bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
701
+ # A footnote/citation target
702
+ (r'^( *\.\.)(\s*)(\[.+\])(.*?)$',
703
+ bygroups(Punctuation, Text, Name.Tag, using(this, state='inline'))),
704
+ # A substitution def
705
+ (r'^( *\.\.)(\s*)(\|.+\|)(\s*)([\w:-]+?)(::)(?:([ \t]*)(.*))',
706
+ bygroups(Punctuation, Text, Name.Tag, Text, Operator.Word,
707
+ Punctuation, Text, using(this, state='inline'))),
708
+ # Comments
709
+ (r'^ *\.\..*(\n( +.*\n|\n)+)?', Comment.Preproc),
710
+ # Field list
711
+ (r'^( *)(:[a-zA-Z-]+:)(\s*)$', bygroups(Text, Name.Class, Text)),
712
+ (r'^( *)(:.*?:)([ \t]+)(.*?)$',
713
+ bygroups(Text, Name.Class, Text, Name.Function)),
714
+ # Definition list
715
+ (r'^([^ ].*(?<!::)\n)((?:(?: +.*)\n)+)',
716
+ bygroups(using(this, state='inline'), using(this, state='inline'))),
717
+ # Code blocks
718
+ (r'(::)(\n[ \t]*\n)([ \t]+)(.*)(\n)((?:(?:\3.*|)\n)+)',
719
+ bygroups(String.Escape, Text, String, String, Text, String)),
720
+ include('inline'),
721
+ ],
722
+ 'inline': [
723
+ (r'\\.', Text), # escape
724
+ (r'``', String, 'literal'), # code
725
+ (r'(`.+?)(<.+?>)(`__?)', # reference with inline target
726
+ bygroups(String, String.Interpol, String)),
727
+ (r'`.+?`__?', String), # reference
728
+ (r'(`.+?`)(:[a-zA-Z0-9:-]+?:)?',
729
+ bygroups(Name.Variable, Name.Attribute)), # role
730
+ (r'(:[a-zA-Z0-9:-]+?:)(`.+?`)',
731
+ bygroups(Name.Attribute, Name.Variable)), # role (content first)
732
+ (r'\*\*.+?\*\*', Generic.Strong), # Strong emphasis
733
+ (r'\*.+?\*', Generic.Emph), # Emphasis
734
+ (r'\[.*?\]_', String), # Footnote or citation
735
+ (r'<.+?>', Name.Tag), # Hyperlink
736
+ (r'[^\\\n\[*`:]+', Text),
737
+ (r'.', Text),
738
+ ],
739
+ 'literal': [
740
+ (r'[^`]+', String),
741
+ (r'``' + end_string_suffix, String, '#pop'),
742
+ (r'`', String),
743
+ ]
744
+ }
745
+
746
+ def __init__(self, **options):
747
+ self.handlecodeblocks = get_bool_opt(options, 'handlecodeblocks', True)
748
+ RegexLexer.__init__(self, **options)
749
+
750
+ def analyse_text(text):
751
+ if text[:2] == '..' and text[2:3] != '.':
752
+ return 0.3
753
+ p1 = text.find("\n")
754
+ p2 = text.find("\n", p1 + 1)
755
+ if (p2 > -1 and # has two lines
756
+ p1 * 2 + 1 == p2 and # they are the same length
757
+ text[p1+1] in '-=' and # the next line both starts and ends with
758
+ text[p1+1] == text[p2-1]): # ...a sufficiently high header
759
+ return 0.5
760
+
761
+
762
+ class VimLexer(RegexLexer):
763
+ """
764
+ Lexer for VimL script files.
765
+
766
+ *New in Pygments 0.8.*
767
+ """
768
+ name = 'VimL'
769
+ aliases = ['vim']
770
+ filenames = ['*.vim', '.vimrc', '.exrc', '.gvimrc',
771
+ '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc']
772
+ mimetypes = ['text/x-vim']
773
+ flags = re.MULTILINE
774
+
775
+ tokens = {
776
+ 'root': [
777
+ (r'^\s*".*', Comment),
778
+
779
+ (r'[ \t]+', Text),
780
+ # TODO: regexes can have other delims
781
+ (r'/(\\\\|\\/|[^\n/])*/', String.Regex),
782
+ (r'"(\\\\|\\"|[^\n"])*"', String.Double),
783
+ (r"'(\\\\|\\'|[^\n'])*'", String.Single),
784
+
785
+ # Who decided that doublequote was a good comment character??
786
+ (r'(?<=\s)"[^\-:.%#=*].*', Comment),
787
+ (r'-?\d+', Number),
788
+ (r'#[0-9a-f]{6}', Number.Hex),
789
+ (r'^:', Punctuation),
790
+ (r'[()<>+=!|,~-]', Punctuation), # Inexact list. Looks decent.
791
+ (r'\b(let|if|else|endif|elseif|fun|function|endfunction)\b',
792
+ Keyword),
793
+ (r'\b(NONE|bold|italic|underline|dark|light)\b', Name.Builtin),
794
+ (r'\b\w+\b', Name.Other), # These are postprocessed below
795
+ (r'.', Text),
796
+ ],
797
+ }
798
+ def __init__(self, **options):
799
+ from pygments.lexers._vimbuiltins import command, option, auto
800
+ self._cmd = command
801
+ self._opt = option
802
+ self._aut = auto
803
+
804
+ RegexLexer.__init__(self, **options)
805
+
806
+ def is_in(self, w, mapping):
807
+ r"""
808
+ It's kind of difficult to decide if something might be a keyword
809
+ in VimL because it allows you to abbreviate them. In fact,
810
+ 'ab[breviate]' is a good example. :ab, :abbre, or :abbreviate are
811
+ valid ways to call it so rather than making really awful regexps
812
+ like::
813
+
814
+ \bab(?:b(?:r(?:e(?:v(?:i(?:a(?:t(?:e)?)?)?)?)?)?)?)?\b
815
+
816
+ we match `\b\w+\b` and then call is_in() on those tokens. See
817
+ `scripts/get_vimkw.py` for how the lists are extracted.
818
+ """
819
+ p = bisect(mapping, (w,))
820
+ if p > 0:
821
+ if mapping[p-1][0] == w[:len(mapping[p-1][0])] and \
822
+ mapping[p-1][1][:len(w)] == w: return True
823
+ if p < len(mapping):
824
+ return mapping[p][0] == w[:len(mapping[p][0])] and \
825
+ mapping[p][1][:len(w)] == w
826
+ return False
827
+
828
+ def get_tokens_unprocessed(self, text):
829
+ # TODO: builtins are only subsequent tokens on lines
830
+ # and 'keywords' only happen at the beginning except
831
+ # for :au ones
832
+ for index, token, value in \
833
+ RegexLexer.get_tokens_unprocessed(self, text):
834
+ if token is Name.Other:
835
+ if self.is_in(value, self._cmd):
836
+ yield index, Keyword, value
837
+ elif self.is_in(value, self._opt) or \
838
+ self.is_in(value, self._aut):
839
+ yield index, Name.Builtin, value
840
+ else:
841
+ yield index, Text, value
842
+ else:
843
+ yield index, token, value
844
+
845
+
846
+ class GettextLexer(RegexLexer):
847
+ """
848
+ Lexer for Gettext catalog files.
849
+
850
+ *New in Pygments 0.9.*
851
+ """
852
+ name = 'Gettext Catalog'
853
+ aliases = ['pot', 'po']
854
+ filenames = ['*.pot', '*.po']
855
+ mimetypes = ['application/x-gettext', 'text/x-gettext', 'text/gettext']
856
+
857
+ tokens = {
858
+ 'root': [
859
+ (r'^#,\s.*?$', Keyword.Type),
860
+ (r'^#:\s.*?$', Keyword.Declaration),
861
+ #(r'^#$', Comment),
862
+ (r'^(#|#\.\s|#\|\s|#~\s|#\s).*$', Comment.Single),
863
+ (r'^(")([A-Za-z-]+:)(.*")$',
864
+ bygroups(String, Name.Property, String)),
865
+ (r'^".*"$', String),
866
+ (r'^(msgid|msgid_plural|msgstr)(\s+)(".*")$',
867
+ bygroups(Name.Variable, Text, String)),
868
+ (r'^(msgstr\[)(\d)(\])(\s+)(".*")$',
869
+ bygroups(Name.Variable, Number.Integer, Name.Variable, Text, String)),
870
+ ]
871
+ }
872
+
873
+
874
+ class SquidConfLexer(RegexLexer):
875
+ """
876
+ Lexer for `squid <http://www.squid-cache.org/>`_ configuration files.
877
+
878
+ *New in Pygments 0.9.*
879
+ """
880
+
881
+ name = 'SquidConf'
882
+ aliases = ['squidconf', 'squid.conf', 'squid']
883
+ filenames = ['squid.conf']
884
+ mimetypes = ['text/x-squidconf']
885
+ flags = re.IGNORECASE
886
+
887
+ keywords = [
888
+ "access_log", "acl", "always_direct", "announce_host",
889
+ "announce_period", "announce_port", "announce_to", "anonymize_headers",
890
+ "append_domain", "as_whois_server", "auth_param_basic",
891
+ "authenticate_children", "authenticate_program", "authenticate_ttl",
892
+ "broken_posts", "buffered_logs", "cache_access_log", "cache_announce",
893
+ "cache_dir", "cache_dns_program", "cache_effective_group",
894
+ "cache_effective_user", "cache_host", "cache_host_acl",
895
+ "cache_host_domain", "cache_log", "cache_mem", "cache_mem_high",
896
+ "cache_mem_low", "cache_mgr", "cachemgr_passwd", "cache_peer",
897
+ "cache_peer_access", "cahce_replacement_policy", "cache_stoplist",
898
+ "cache_stoplist_pattern", "cache_store_log", "cache_swap",
899
+ "cache_swap_high", "cache_swap_log", "cache_swap_low", "client_db",
900
+ "client_lifetime", "client_netmask", "connect_timeout", "coredump_dir",
901
+ "dead_peer_timeout", "debug_options", "delay_access", "delay_class",
902
+ "delay_initial_bucket_level", "delay_parameters", "delay_pools",
903
+ "deny_info", "dns_children", "dns_defnames", "dns_nameservers",
904
+ "dns_testnames", "emulate_httpd_log", "err_html_text",
905
+ "fake_user_agent", "firewall_ip", "forwarded_for", "forward_snmpd_port",
906
+ "fqdncache_size", "ftpget_options", "ftpget_program", "ftp_list_width",
907
+ "ftp_passive", "ftp_user", "half_closed_clients", "header_access",
908
+ "header_replace", "hierarchy_stoplist", "high_response_time_warning",
909
+ "high_page_fault_warning", "hosts_file", "htcp_port", "http_access",
910
+ "http_anonymizer", "httpd_accel", "httpd_accel_host",
911
+ "httpd_accel_port", "httpd_accel_uses_host_header",
912
+ "httpd_accel_with_proxy", "http_port", "http_reply_access",
913
+ "icp_access", "icp_hit_stale", "icp_port", "icp_query_timeout",
914
+ "ident_lookup", "ident_lookup_access", "ident_timeout",
915
+ "incoming_http_average", "incoming_icp_average", "inside_firewall",
916
+ "ipcache_high", "ipcache_low", "ipcache_size", "local_domain",
917
+ "local_ip", "logfile_rotate", "log_fqdn", "log_icp_queries",
918
+ "log_mime_hdrs", "maximum_object_size", "maximum_single_addr_tries",
919
+ "mcast_groups", "mcast_icp_query_timeout", "mcast_miss_addr",
920
+ "mcast_miss_encode_key", "mcast_miss_port", "memory_pools",
921
+ "memory_pools_limit", "memory_replacement_policy", "mime_table",
922
+ "min_http_poll_cnt", "min_icp_poll_cnt", "minimum_direct_hops",
923
+ "minimum_object_size", "minimum_retry_timeout", "miss_access",
924
+ "negative_dns_ttl", "negative_ttl", "neighbor_timeout",
925
+ "neighbor_type_domain", "netdb_high", "netdb_low", "netdb_ping_period",
926
+ "netdb_ping_rate", "never_direct", "no_cache", "passthrough_proxy",
927
+ "pconn_timeout", "pid_filename", "pinger_program", "positive_dns_ttl",
928
+ "prefer_direct", "proxy_auth", "proxy_auth_realm", "query_icmp",
929
+ "quick_abort", "quick_abort", "quick_abort_max", "quick_abort_min",
930
+ "quick_abort_pct", "range_offset_limit", "read_timeout",
931
+ "redirect_children", "redirect_program",
932
+ "redirect_rewrites_host_header", "reference_age", "reference_age",
933
+ "refresh_pattern", "reload_into_ims", "request_body_max_size",
934
+ "request_size", "request_timeout", "shutdown_lifetime",
935
+ "single_parent_bypass", "siteselect_timeout", "snmp_access",
936
+ "snmp_incoming_address", "snmp_port", "source_ping", "ssl_proxy",
937
+ "store_avg_object_size", "store_objects_per_bucket",
938
+ "strip_query_terms", "swap_level1_dirs", "swap_level2_dirs",
939
+ "tcp_incoming_address", "tcp_outgoing_address", "tcp_recv_bufsize",
940
+ "test_reachability", "udp_hit_obj", "udp_hit_obj_size",
941
+ "udp_incoming_address", "udp_outgoing_address", "unique_hostname",
942
+ "unlinkd_program", "uri_whitespace", "useragent_log",
943
+ "visible_hostname", "wais_relay", "wais_relay_host", "wais_relay_port",
944
+ ]
945
+
946
+ opts = [
947
+ "proxy-only", "weight", "ttl", "no-query", "default", "round-robin",
948
+ "multicast-responder", "on", "off", "all", "deny", "allow", "via",
949
+ "parent", "no-digest", "heap", "lru", "realm", "children", "q1", "q2",
950
+ "credentialsttl", "none", "disable", "offline_toggle", "diskd",
951
+ ]
952
+
953
+ actions = [
954
+ "shutdown", "info", "parameter", "server_list", "client_list",
955
+ r'squid\.conf',
956
+ ]
957
+
958
+ actions_stats = [
959
+ "objects", "vm_objects", "utilization", "ipcache", "fqdncache", "dns",
960
+ "redirector", "io", "reply_headers", "filedescriptors", "netdb",
961
+ ]
962
+
963
+ actions_log = ["status", "enable", "disable", "clear"]
964
+
965
+ acls = [
966
+ "url_regex", "urlpath_regex", "referer_regex", "port", "proto",
967
+ "req_mime_type", "rep_mime_type", "method", "browser", "user", "src",
968
+ "dst", "time", "dstdomain", "ident", "snmp_community",
969
+ ]
970
+
971
+ ip_re = (
972
+ r'(?:(?:(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|0x0*[0-9a-f]{1,2}|'
973
+ r'0+[1-3]?[0-7]{0,2})(?:\.(?:[3-9]\d?|2(?:5[0-5]|[0-4]?\d)?|1\d{0,2}|'
974
+ r'0x0*[0-9a-f]{1,2}|0+[1-3]?[0-7]{0,2})){3})|(?!.*::.*::)(?:(?!:)|'
975
+ r':(?=:))(?:[0-9a-f]{0,4}(?:(?<=::)|(?<!::):)){6}(?:[0-9a-f]{0,4}'
976
+ r'(?:(?<=::)|(?<!::):)[0-9a-f]{0,4}(?:(?<=::)|(?<!:)|(?<=:)(?<!::):)|'
977
+ r'(?:25[0-4]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-4]|2[0-4]\d|1\d\d|'
978
+ r'[1-9]?\d)){3}))'
979
+ )
980
+
981
+ def makelistre(list):
982
+ return r'\b(?:' + '|'.join(list) + r')\b'
983
+
984
+ tokens = {
985
+ 'root': [
986
+ (r'\s+', Whitespace),
987
+ (r'#', Comment, 'comment'),
988
+ (makelistre(keywords), Keyword),
989
+ (makelistre(opts), Name.Constant),
990
+ # Actions
991
+ (makelistre(actions), String),
992
+ (r'stats/'+makelistre(actions), String),
993
+ (r'log/'+makelistre(actions)+r'=', String),
994
+ (makelistre(acls), Keyword),
995
+ (ip_re + r'(?:/(?:' + ip_re + r'|\b\d+\b))?', Number.Float),
996
+ (r'(?:\b\d+\b(?:-\b\d+|%)?)', Number),
997
+ (r'\S+', Text),
998
+ ],
999
+ 'comment': [
1000
+ (r'\s*TAG:.*', String.Escape, '#pop'),
1001
+ (r'.*', Comment, '#pop'),
1002
+ ],
1003
+ }
1004
+
1005
+
1006
+ class DebianControlLexer(RegexLexer):
1007
+ """
1008
+ Lexer for Debian ``control`` files and ``apt-cache show <pkg>`` outputs.
1009
+
1010
+ *New in Pygments 0.9.*
1011
+ """
1012
+ name = 'Debian Control file'
1013
+ aliases = ['control']
1014
+ filenames = ['control']
1015
+
1016
+ tokens = {
1017
+ 'root': [
1018
+ (r'^(Description)', Keyword, 'description'),
1019
+ (r'^(Maintainer)(:\s*)', bygroups(Keyword, Text), 'maintainer'),
1020
+ (r'^((Build-)?Depends)', Keyword, 'depends'),
1021
+ (r'^((?:Python-)?Version)(:\s*)(\S+)$',
1022
+ bygroups(Keyword, Text, Number)),
1023
+ (r'^((?:Installed-)?Size)(:\s*)(\S+)$',
1024
+ bygroups(Keyword, Text, Number)),
1025
+ (r'^(MD5Sum|SHA1|SHA256)(:\s*)(\S+)$',
1026
+ bygroups(Keyword, Text, Number)),
1027
+ (r'^([a-zA-Z\-0-9\.]*?)(:\s*)(.*?)$',
1028
+ bygroups(Keyword, Whitespace, String)),
1029
+ ],
1030
+ 'maintainer': [
1031
+ (r'<[^>]+>', Generic.Strong),
1032
+ (r'<[^>]+>$', Generic.Strong, '#pop'),
1033
+ (r',\n?', Text),
1034
+ (r'.', Text),
1035
+ ],
1036
+ 'description': [
1037
+ (r'(.*)(Homepage)(: )(\S+)',
1038
+ bygroups(Text, String, Name, Name.Class)),
1039
+ (r':.*\n', Generic.Strong),
1040
+ (r' .*\n', Text),
1041
+ ('', Text, '#pop'),
1042
+ ],
1043
+ 'depends': [
1044
+ (r':\s*', Text),
1045
+ (r'(\$)(\{)(\w+\s*:\s*\w+)', bygroups(Operator, Text, Name.Entity)),
1046
+ (r'\(', Text, 'depend_vers'),
1047
+ (r',', Text),
1048
+ (r'\|', Operator),
1049
+ (r'[\s]+', Text),
1050
+ (r'[}\)]\s*$', Text, '#pop'),
1051
+ (r'}', Text),
1052
+ (r'[^,]$', Name.Function, '#pop'),
1053
+ (r'([\+\.a-zA-Z0-9-])(\s*)', bygroups(Name.Function, Text)),
1054
+ (r'\[.*?\]', Name.Entity),
1055
+ ],
1056
+ 'depend_vers': [
1057
+ (r'\),', Text, '#pop'),
1058
+ (r'\)[^,]', Text, '#pop:2'),
1059
+ (r'([><=]+)(\s*)([^\)]+)', bygroups(Operator, Text, Number))
1060
+ ]
1061
+ }
1062
+
1063
+
1064
+ class YamlLexerContext(LexerContext):
1065
+ """Indentation context for the YAML lexer."""
1066
+
1067
+ def __init__(self, *args, **kwds):
1068
+ super(YamlLexerContext, self).__init__(*args, **kwds)
1069
+ self.indent_stack = []
1070
+ self.indent = -1
1071
+ self.next_indent = 0
1072
+ self.block_scalar_indent = None
1073
+
1074
+
1075
+ class YamlLexer(ExtendedRegexLexer):
1076
+ """
1077
+ Lexer for `YAML <http://yaml.org/>`_, a human-friendly data serialization
1078
+ language.
1079
+
1080
+ *New in Pygments 0.11.*
1081
+ """
1082
+
1083
+ name = 'YAML'
1084
+ aliases = ['yaml']
1085
+ filenames = ['*.yaml', '*.yml']
1086
+ mimetypes = ['text/x-yaml']
1087
+
1088
+
1089
+ def something(token_class):
1090
+ """Do not produce empty tokens."""
1091
+ def callback(lexer, match, context):
1092
+ text = match.group()
1093
+ if not text:
1094
+ return
1095
+ yield match.start(), token_class, text
1096
+ context.pos = match.end()
1097
+ return callback
1098
+
1099
+ def reset_indent(token_class):
1100
+ """Reset the indentation levels."""
1101
+ def callback(lexer, match, context):
1102
+ text = match.group()
1103
+ context.indent_stack = []
1104
+ context.indent = -1
1105
+ context.next_indent = 0
1106
+ context.block_scalar_indent = None
1107
+ yield match.start(), token_class, text
1108
+ context.pos = match.end()
1109
+ return callback
1110
+
1111
+ def save_indent(token_class, start=False):
1112
+ """Save a possible indentation level."""
1113
+ def callback(lexer, match, context):
1114
+ text = match.group()
1115
+ extra = ''
1116
+ if start:
1117
+ context.next_indent = len(text)
1118
+ if context.next_indent < context.indent:
1119
+ while context.next_indent < context.indent:
1120
+ context.indent = context.indent_stack.pop()
1121
+ if context.next_indent > context.indent:
1122
+ extra = text[context.indent:]
1123
+ text = text[:context.indent]
1124
+ else:
1125
+ context.next_indent += len(text)
1126
+ if text:
1127
+ yield match.start(), token_class, text
1128
+ if extra:
1129
+ yield match.start()+len(text), token_class.Error, extra
1130
+ context.pos = match.end()
1131
+ return callback
1132
+
1133
+ def set_indent(token_class, implicit=False):
1134
+ """Set the previously saved indentation level."""
1135
+ def callback(lexer, match, context):
1136
+ text = match.group()
1137
+ if context.indent < context.next_indent:
1138
+ context.indent_stack.append(context.indent)
1139
+ context.indent = context.next_indent
1140
+ if not implicit:
1141
+ context.next_indent += len(text)
1142
+ yield match.start(), token_class, text
1143
+ context.pos = match.end()
1144
+ return callback
1145
+
1146
+ def set_block_scalar_indent(token_class):
1147
+ """Set an explicit indentation level for a block scalar."""
1148
+ def callback(lexer, match, context):
1149
+ text = match.group()
1150
+ context.block_scalar_indent = None
1151
+ if not text:
1152
+ return
1153
+ increment = match.group(1)
1154
+ if increment:
1155
+ current_indent = max(context.indent, 0)
1156
+ increment = int(increment)
1157
+ context.block_scalar_indent = current_indent + increment
1158
+ if text:
1159
+ yield match.start(), token_class, text
1160
+ context.pos = match.end()
1161
+ return callback
1162
+
1163
+ def parse_block_scalar_empty_line(indent_token_class, content_token_class):
1164
+ """Process an empty line in a block scalar."""
1165
+ def callback(lexer, match, context):
1166
+ text = match.group()
1167
+ if (context.block_scalar_indent is None or
1168
+ len(text) <= context.block_scalar_indent):
1169
+ if text:
1170
+ yield match.start(), indent_token_class, text
1171
+ else:
1172
+ indentation = text[:context.block_scalar_indent]
1173
+ content = text[context.block_scalar_indent:]
1174
+ yield match.start(), indent_token_class, indentation
1175
+ yield (match.start()+context.block_scalar_indent,
1176
+ content_token_class, content)
1177
+ context.pos = match.end()
1178
+ return callback
1179
+
1180
+ def parse_block_scalar_indent(token_class):
1181
+ """Process indentation spaces in a block scalar."""
1182
+ def callback(lexer, match, context):
1183
+ text = match.group()
1184
+ if context.block_scalar_indent is None:
1185
+ if len(text) <= max(context.indent, 0):
1186
+ context.stack.pop()
1187
+ context.stack.pop()
1188
+ return
1189
+ context.block_scalar_indent = len(text)
1190
+ else:
1191
+ if len(text) < context.block_scalar_indent:
1192
+ context.stack.pop()
1193
+ context.stack.pop()
1194
+ return
1195
+ if text:
1196
+ yield match.start(), token_class, text
1197
+ context.pos = match.end()
1198
+ return callback
1199
+
1200
+ def parse_plain_scalar_indent(token_class):
1201
+ """Process indentation spaces in a plain scalar."""
1202
+ def callback(lexer, match, context):
1203
+ text = match.group()
1204
+ if len(text) <= context.indent:
1205
+ context.stack.pop()
1206
+ context.stack.pop()
1207
+ return
1208
+ if text:
1209
+ yield match.start(), token_class, text
1210
+ context.pos = match.end()
1211
+ return callback
1212
+
1213
+
1214
+
1215
+ tokens = {
1216
+ # the root rules
1217
+ 'root': [
1218
+ # ignored whitespaces
1219
+ (r'[ ]+(?=#|$)', Text),
1220
+ # line breaks
1221
+ (r'\n+', Text),
1222
+ # a comment
1223
+ (r'#[^\n]*', Comment.Single),
1224
+ # the '%YAML' directive
1225
+ (r'^%YAML(?=[ ]|$)', reset_indent(Name.Tag), 'yaml-directive'),
1226
+ # the %TAG directive
1227
+ (r'^%TAG(?=[ ]|$)', reset_indent(Name.Tag), 'tag-directive'),
1228
+ # document start and document end indicators
1229
+ (r'^(?:---|\.\.\.)(?=[ ]|$)', reset_indent(Name.Namespace),
1230
+ 'block-line'),
1231
+ # indentation spaces
1232
+ (r'[ ]*(?![ \t\n\r\f\v]|$)', save_indent(Text, start=True),
1233
+ ('block-line', 'indentation')),
1234
+ ],
1235
+
1236
+ # trailing whitespaces after directives or a block scalar indicator
1237
+ 'ignored-line': [
1238
+ # ignored whitespaces
1239
+ (r'[ ]+(?=#|$)', Text),
1240
+ # a comment
1241
+ (r'#[^\n]*', Comment.Single),
1242
+ # line break
1243
+ (r'\n', Text, '#pop:2'),
1244
+ ],
1245
+
1246
+ # the %YAML directive
1247
+ 'yaml-directive': [
1248
+ # the version number
1249
+ (r'([ ]+)([0-9]+\.[0-9]+)',
1250
+ bygroups(Text, Number), 'ignored-line'),
1251
+ ],
1252
+
1253
+ # the %YAG directive
1254
+ 'tag-directive': [
1255
+ # a tag handle and the corresponding prefix
1256
+ (r'([ ]+)(!|![0-9A-Za-z_-]*!)'
1257
+ r'([ ]+)(!|!?[0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+)',
1258
+ bygroups(Text, Keyword.Type, Text, Keyword.Type),
1259
+ 'ignored-line'),
1260
+ ],
1261
+
1262
+ # block scalar indicators and indentation spaces
1263
+ 'indentation': [
1264
+ # trailing whitespaces are ignored
1265
+ (r'[ ]*$', something(Text), '#pop:2'),
1266
+ # whitespaces preceeding block collection indicators
1267
+ (r'[ ]+(?=[?:-](?:[ ]|$))', save_indent(Text)),
1268
+ # block collection indicators
1269
+ (r'[?:-](?=[ ]|$)', set_indent(Punctuation.Indicator)),
1270
+ # the beginning a block line
1271
+ (r'[ ]*', save_indent(Text), '#pop'),
1272
+ ],
1273
+
1274
+ # an indented line in the block context
1275
+ 'block-line': [
1276
+ # the line end
1277
+ (r'[ ]*(?=#|$)', something(Text), '#pop'),
1278
+ # whitespaces separating tokens
1279
+ (r'[ ]+', Text),
1280
+ # tags, anchors and aliases,
1281
+ include('descriptors'),
1282
+ # block collections and scalars
1283
+ include('block-nodes'),
1284
+ # flow collections and quoted scalars
1285
+ include('flow-nodes'),
1286
+ # a plain scalar
1287
+ (r'(?=[^ \t\n\r\f\v?:,\[\]{}#&*!|>\'"%@`-]|[?:-][^ \t\n\r\f\v])',
1288
+ something(Name.Variable),
1289
+ 'plain-scalar-in-block-context'),
1290
+ ],
1291
+
1292
+ # tags, anchors, aliases
1293
+ 'descriptors' : [
1294
+ # a full-form tag
1295
+ (r'!<[0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+>', Keyword.Type),
1296
+ # a tag in the form '!', '!suffix' or '!handle!suffix'
1297
+ (r'!(?:[0-9A-Za-z_-]+)?'
1298
+ r'(?:![0-9A-Za-z;/?:@&=+$,_.!~*\'()\[\]%-]+)?', Keyword.Type),
1299
+ # an anchor
1300
+ (r'&[0-9A-Za-z_-]+', Name.Label),
1301
+ # an alias
1302
+ (r'\*[0-9A-Za-z_-]+', Name.Variable),
1303
+ ],
1304
+
1305
+ # block collections and scalars
1306
+ 'block-nodes': [
1307
+ # implicit key
1308
+ (r':(?=[ ]|$)', set_indent(Punctuation.Indicator, implicit=True)),
1309
+ # literal and folded scalars
1310
+ (r'[|>]', Punctuation.Indicator,
1311
+ ('block-scalar-content', 'block-scalar-header')),
1312
+ ],
1313
+
1314
+ # flow collections and quoted scalars
1315
+ 'flow-nodes': [
1316
+ # a flow sequence
1317
+ (r'\[', Punctuation.Indicator, 'flow-sequence'),
1318
+ # a flow mapping
1319
+ (r'\{', Punctuation.Indicator, 'flow-mapping'),
1320
+ # a single-quoted scalar
1321
+ (r'\'', String, 'single-quoted-scalar'),
1322
+ # a double-quoted scalar
1323
+ (r'\"', String, 'double-quoted-scalar'),
1324
+ ],
1325
+
1326
+ # the content of a flow collection
1327
+ 'flow-collection': [
1328
+ # whitespaces
1329
+ (r'[ ]+', Text),
1330
+ # line breaks
1331
+ (r'\n+', Text),
1332
+ # a comment
1333
+ (r'#[^\n]*', Comment.Single),
1334
+ # simple indicators
1335
+ (r'[?:,]', Punctuation.Indicator),
1336
+ # tags, anchors and aliases
1337
+ include('descriptors'),
1338
+ # nested collections and quoted scalars
1339
+ include('flow-nodes'),
1340
+ # a plain scalar
1341
+ (r'(?=[^ \t\n\r\f\v?:,\[\]{}#&*!|>\'"%@`])',
1342
+ something(Name.Variable),
1343
+ 'plain-scalar-in-flow-context'),
1344
+ ],
1345
+
1346
+ # a flow sequence indicated by '[' and ']'
1347
+ 'flow-sequence': [
1348
+ # include flow collection rules
1349
+ include('flow-collection'),
1350
+ # the closing indicator
1351
+ (r'\]', Punctuation.Indicator, '#pop'),
1352
+ ],
1353
+
1354
+ # a flow mapping indicated by '{' and '}'
1355
+ 'flow-mapping': [
1356
+ # include flow collection rules
1357
+ include('flow-collection'),
1358
+ # the closing indicator
1359
+ (r'\}', Punctuation.Indicator, '#pop'),
1360
+ ],
1361
+
1362
+ # block scalar lines
1363
+ 'block-scalar-content': [
1364
+ # line break
1365
+ (r'\n', Text),
1366
+ # empty line
1367
+ (r'^[ ]+$',
1368
+ parse_block_scalar_empty_line(Text, Name.Constant)),
1369
+ # indentation spaces (we may leave the state here)
1370
+ (r'^[ ]*', parse_block_scalar_indent(Text)),
1371
+ # line content
1372
+ (r'[^\n\r\f\v]+', Name.Constant),
1373
+ ],
1374
+
1375
+ # the content of a literal or folded scalar
1376
+ 'block-scalar-header': [
1377
+ # indentation indicator followed by chomping flag
1378
+ (r'([1-9])?[+-]?(?=[ ]|$)',
1379
+ set_block_scalar_indent(Punctuation.Indicator),
1380
+ 'ignored-line'),
1381
+ # chomping flag followed by indentation indicator
1382
+ (r'[+-]?([1-9])?(?=[ ]|$)',
1383
+ set_block_scalar_indent(Punctuation.Indicator),
1384
+ 'ignored-line'),
1385
+ ],
1386
+
1387
+ # ignored and regular whitespaces in quoted scalars
1388
+ 'quoted-scalar-whitespaces': [
1389
+ # leading and trailing whitespaces are ignored
1390
+ (r'^[ ]+', Text),
1391
+ (r'[ ]+$', Text),
1392
+ # line breaks are ignored
1393
+ (r'\n+', Text),
1394
+ # other whitespaces are a part of the value
1395
+ (r'[ ]+', Name.Variable),
1396
+ ],
1397
+
1398
+ # single-quoted scalars
1399
+ 'single-quoted-scalar': [
1400
+ # include whitespace and line break rules
1401
+ include('quoted-scalar-whitespaces'),
1402
+ # escaping of the quote character
1403
+ (r'\'\'', String.Escape),
1404
+ # regular non-whitespace characters
1405
+ (r'[^ \t\n\r\f\v\']+', String),
1406
+ # the closing quote
1407
+ (r'\'', String, '#pop'),
1408
+ ],
1409
+
1410
+ # double-quoted scalars
1411
+ 'double-quoted-scalar': [
1412
+ # include whitespace and line break rules
1413
+ include('quoted-scalar-whitespaces'),
1414
+ # escaping of special characters
1415
+ (r'\\[0abt\tn\nvfre "\\N_LP]', String),
1416
+ # escape codes
1417
+ (r'\\(?:x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})',
1418
+ String.Escape),
1419
+ # regular non-whitespace characters
1420
+ (r'[^ \t\n\r\f\v\"\\]+', String),
1421
+ # the closing quote
1422
+ (r'"', String, '#pop'),
1423
+ ],
1424
+
1425
+ # the beginning of a new line while scanning a plain scalar
1426
+ 'plain-scalar-in-block-context-new-line': [
1427
+ # empty lines
1428
+ (r'^[ ]+$', Text),
1429
+ # line breaks
1430
+ (r'\n+', Text),
1431
+ # document start and document end indicators
1432
+ (r'^(?=---|\.\.\.)', something(Name.Namespace), '#pop:3'),
1433
+ # indentation spaces (we may leave the block line state here)
1434
+ (r'^[ ]*', parse_plain_scalar_indent(Text), '#pop'),
1435
+ ],
1436
+
1437
+ # a plain scalar in the block context
1438
+ 'plain-scalar-in-block-context': [
1439
+ # the scalar ends with the ':' indicator
1440
+ (r'[ ]*(?=:[ ]|:$)', something(Text), '#pop'),
1441
+ # the scalar ends with whitespaces followed by a comment
1442
+ (r'[ ]+(?=#)', Text, '#pop'),
1443
+ # trailing whitespaces are ignored
1444
+ (r'[ ]+$', Text),
1445
+ # line breaks are ignored
1446
+ (r'\n+', Text, 'plain-scalar-in-block-context-new-line'),
1447
+ # other whitespaces are a part of the value
1448
+ (r'[ ]+', Literal.Scalar.Plain),
1449
+ # regular non-whitespace characters
1450
+ (r'(?::(?![ \t\n\r\f\v])|[^ \t\n\r\f\v:])+', Literal.Scalar.Plain),
1451
+ ],
1452
+
1453
+ # a plain scalar is the flow context
1454
+ 'plain-scalar-in-flow-context': [
1455
+ # the scalar ends with an indicator character
1456
+ (r'[ ]*(?=[,:?\[\]{}])', something(Text), '#pop'),
1457
+ # the scalar ends with a comment
1458
+ (r'[ ]+(?=#)', Text, '#pop'),
1459
+ # leading and trailing whitespaces are ignored
1460
+ (r'^[ ]+', Text),
1461
+ (r'[ ]+$', Text),
1462
+ # line breaks are ignored
1463
+ (r'\n+', Text),
1464
+ # other whitespaces are a part of the value
1465
+ (r'[ ]+', Name.Variable),
1466
+ # regular non-whitespace characters
1467
+ (r'[^ \t\n\r\f\v,:?\[\]{}]+', Name.Variable),
1468
+ ],
1469
+
1470
+ }
1471
+
1472
+ def get_tokens_unprocessed(self, text=None, context=None):
1473
+ if context is None:
1474
+ context = YamlLexerContext(text, 0)
1475
+ return super(YamlLexer, self).get_tokens_unprocessed(text, context)
1476
+
1477
+
1478
+ class LighttpdConfLexer(RegexLexer):
1479
+ """
1480
+ Lexer for `Lighttpd <http://lighttpd.net/>`_ configuration files.
1481
+
1482
+ *New in Pygments 0.11.*
1483
+ """
1484
+ name = 'Lighttpd configuration file'
1485
+ aliases = ['lighty', 'lighttpd']
1486
+ filenames = []
1487
+ mimetypes = ['text/x-lighttpd-conf']
1488
+
1489
+ tokens = {
1490
+ 'root': [
1491
+ (r'#.*\n', Comment.Single),
1492
+ (r'/\S*', Name), # pathname
1493
+ (r'[a-zA-Z._-]+', Keyword),
1494
+ (r'\d+\.\d+\.\d+\.\d+(?:/\d+)?', Number),
1495
+ (r'[0-9]+', Number),
1496
+ (r'=>|=~|\+=|==|=|\+', Operator),
1497
+ (r'\$[A-Z]+', Name.Builtin),
1498
+ (r'[(){}\[\],]', Punctuation),
1499
+ (r'"([^"\\]*(?:\\.[^"\\]*)*)"', String.Double),
1500
+ (r'\s+', Text),
1501
+ ],
1502
+
1503
+ }
1504
+
1505
+
1506
+ class NginxConfLexer(RegexLexer):
1507
+ """
1508
+ Lexer for `Nginx <http://nginx.net/>`_ configuration files.
1509
+
1510
+ *New in Pygments 0.11.*
1511
+ """
1512
+ name = 'Nginx configuration file'
1513
+ aliases = ['nginx']
1514
+ filenames = []
1515
+ mimetypes = ['text/x-nginx-conf']
1516
+
1517
+ tokens = {
1518
+ 'root': [
1519
+ (r'(include)(\s+)([^\s;]+)', bygroups(Keyword, Text, Name)),
1520
+ (r'[^\s;#]+', Keyword, 'stmt'),
1521
+ include('base'),
1522
+ ],
1523
+ 'block': [
1524
+ (r'}', Punctuation, '#pop:2'),
1525
+ (r'[^\s;#]+', Keyword.Namespace, 'stmt'),
1526
+ include('base'),
1527
+ ],
1528
+ 'stmt': [
1529
+ (r'{', Punctuation, 'block'),
1530
+ (r';', Punctuation, '#pop'),
1531
+ include('base'),
1532
+ ],
1533
+ 'base': [
1534
+ (r'#.*\n', Comment.Single),
1535
+ (r'on|off', Name.Constant),
1536
+ (r'\$[^\s;#()]+', Name.Variable),
1537
+ (r'([a-z0-9.-]+)(:)([0-9]+)',
1538
+ bygroups(Name, Punctuation, Number.Integer)),
1539
+ (r'[a-z-]+/[a-z-+]+', String), # mimetype
1540
+ #(r'[a-zA-Z._-]+', Keyword),
1541
+ (r'[0-9]+[km]?\b', Number.Integer),
1542
+ (r'(~)(\s*)([^\s{]+)', bygroups(Punctuation, Text, String.Regex)),
1543
+ (r'[:=~]', Punctuation),
1544
+ (r'[^\s;#{}$]+', String), # catch all
1545
+ (r'/[^\s;#]*', Name), # pathname
1546
+ (r'\s+', Text),
1547
+ (r'[$;]', Text), # leftover characters
1548
+ ],
1549
+ }
1550
+
1551
+
1552
+ class CMakeLexer(RegexLexer):
1553
+ """
1554
+ Lexer for `CMake <http://cmake.org/Wiki/CMake>`_ files.
1555
+
1556
+ *New in Pygments 1.2.*
1557
+ """
1558
+ name = 'CMake'
1559
+ aliases = ['cmake']
1560
+ filenames = ['*.cmake', 'CMakeLists.txt']
1561
+ mimetypes = ['text/x-cmake']
1562
+
1563
+ tokens = {
1564
+ 'root': [
1565
+ #(r'(ADD_CUSTOM_COMMAND|ADD_CUSTOM_TARGET|ADD_DEFINITIONS|'
1566
+ # r'ADD_DEPENDENCIES|ADD_EXECUTABLE|ADD_LIBRARY|ADD_SUBDIRECTORY|'
1567
+ # r'ADD_TEST|AUX_SOURCE_DIRECTORY|BUILD_COMMAND|BUILD_NAME|'
1568
+ # r'CMAKE_MINIMUM_REQUIRED|CONFIGURE_FILE|CREATE_TEST_SOURCELIST|'
1569
+ # r'ELSE|ELSEIF|ENABLE_LANGUAGE|ENABLE_TESTING|ENDFOREACH|'
1570
+ # r'ENDFUNCTION|ENDIF|ENDMACRO|ENDWHILE|EXEC_PROGRAM|'
1571
+ # r'EXECUTE_PROCESS|EXPORT_LIBRARY_DEPENDENCIES|FILE|FIND_FILE|'
1572
+ # r'FIND_LIBRARY|FIND_PACKAGE|FIND_PATH|FIND_PROGRAM|FLTK_WRAP_UI|'
1573
+ # r'FOREACH|FUNCTION|GET_CMAKE_PROPERTY|GET_DIRECTORY_PROPERTY|'
1574
+ # r'GET_FILENAME_COMPONENT|GET_SOURCE_FILE_PROPERTY|'
1575
+ # r'GET_TARGET_PROPERTY|GET_TEST_PROPERTY|IF|INCLUDE|'
1576
+ # r'INCLUDE_DIRECTORIES|INCLUDE_EXTERNAL_MSPROJECT|'
1577
+ # r'INCLUDE_REGULAR_EXPRESSION|INSTALL|INSTALL_FILES|'
1578
+ # r'INSTALL_PROGRAMS|INSTALL_TARGETS|LINK_DIRECTORIES|'
1579
+ # r'LINK_LIBRARIES|LIST|LOAD_CACHE|LOAD_COMMAND|MACRO|'
1580
+ # r'MAKE_DIRECTORY|MARK_AS_ADVANCED|MATH|MESSAGE|OPTION|'
1581
+ # r'OUTPUT_REQUIRED_FILES|PROJECT|QT_WRAP_CPP|QT_WRAP_UI|REMOVE|'
1582
+ # r'REMOVE_DEFINITIONS|SEPARATE_ARGUMENTS|SET|'
1583
+ # r'SET_DIRECTORY_PROPERTIES|SET_SOURCE_FILES_PROPERTIES|'
1584
+ # r'SET_TARGET_PROPERTIES|SET_TESTS_PROPERTIES|SITE_NAME|'
1585
+ # r'SOURCE_GROUP|STRING|SUBDIR_DEPENDS|SUBDIRS|'
1586
+ # r'TARGET_LINK_LIBRARIES|TRY_COMPILE|TRY_RUN|UNSET|'
1587
+ # r'USE_MANGLED_MESA|UTILITY_SOURCE|VARIABLE_REQUIRES|'
1588
+ # r'VTK_MAKE_INSTANTIATOR|VTK_WRAP_JAVA|VTK_WRAP_PYTHON|'
1589
+ # r'VTK_WRAP_TCL|WHILE|WRITE_FILE|'
1590
+ # r'COUNTARGS)\b', Name.Builtin, 'args'),
1591
+ (r'\b([A-Za-z_]+)([ \t]*)(\()', bygroups(Name.Builtin, Text,
1592
+ Punctuation), 'args'),
1593
+ include('keywords'),
1594
+ include('ws')
1595
+ ],
1596
+ 'args': [
1597
+ (r'\(', Punctuation, '#push'),
1598
+ (r'\)', Punctuation, '#pop'),
1599
+ (r'(\${)(.+?)(})', bygroups(Operator, Name.Variable, Operator)),
1600
+ (r'(?s)".*?"', String.Double),
1601
+ (r'\\\S+', String),
1602
+ (r'[^\)$"# \t\n]+', String),
1603
+ (r'\n', Text), # explicitly legal
1604
+ include('keywords'),
1605
+ include('ws')
1606
+ ],
1607
+ 'string': [
1608
+
1609
+ ],
1610
+ 'keywords': [
1611
+ (r'\b(WIN32|UNIX|APPLE|CYGWIN|BORLAND|MINGW|MSVC|MSVC_IDE|MSVC60|'
1612
+ r'MSVC70|MSVC71|MSVC80|MSVC90)\b', Keyword),
1613
+ ],
1614
+ 'ws': [
1615
+ (r'[ \t]+', Text),
1616
+ (r'#.+\n', Comment),
1617
+ ]
1618
+ }
1619
+
1620
+
1621
+ class HttpLexer(RegexLexer):
1622
+ """
1623
+ Lexer for HTTP sessions.
1624
+
1625
+ *New in Pygments 1.5.*
1626
+ """
1627
+
1628
+ name = 'HTTP'
1629
+ aliases = ['http']
1630
+
1631
+ flags = re.DOTALL
1632
+
1633
+ def header_callback(self, match):
1634
+ if match.group(1).lower() == 'content-type':
1635
+ content_type = match.group(5).strip()
1636
+ if ';' in content_type:
1637
+ content_type = content_type[:content_type.find(';')].strip()
1638
+ self.content_type = content_type
1639
+ yield match.start(1), Name.Attribute, match.group(1)
1640
+ yield match.start(2), Text, match.group(2)
1641
+ yield match.start(3), Operator, match.group(3)
1642
+ yield match.start(4), Text, match.group(4)
1643
+ yield match.start(5), Literal, match.group(5)
1644
+ yield match.start(6), Text, match.group(6)
1645
+
1646
+ def content_callback(self, match):
1647
+ content_type = getattr(self, 'content_type', None)
1648
+ content = match.group()
1649
+ offset = match.start()
1650
+ if content_type:
1651
+ from pygments.lexers import get_lexer_for_mimetype
1652
+ try:
1653
+ lexer = get_lexer_for_mimetype(content_type)
1654
+ except ClassNotFound:
1655
+ pass
1656
+ else:
1657
+ for idx, token, value in lexer.get_tokens_unprocessed(content):
1658
+ yield offset + idx, token, value
1659
+ return
1660
+ yield offset, Text, content
1661
+
1662
+ tokens = {
1663
+ 'root': [
1664
+ (r'(GET|POST|PUT|DELETE|HEAD|OPTIONS|TRACE)( +)([^ ]+)( +)'
1665
+ r'(HTTPS?)(/)(1\.[01])(\r?\n|$)',
1666
+ bygroups(Name.Function, Text, Name.Namespace, Text,
1667
+ Keyword.Reserved, Operator, Number, Text),
1668
+ 'headers'),
1669
+ (r'(HTTPS?)(/)(1\.[01])( +)(\d{3})( +)([^\r\n]+)(\r?\n|$)',
1670
+ bygroups(Keyword.Reserved, Operator, Number, Text, Number,
1671
+ Text, Name.Exception, Text),
1672
+ 'headers'),
1673
+ ],
1674
+ 'headers': [
1675
+ (r'([^\s:]+)( *)(:)( *)([^\r\n]+)(\r?\n|$)', header_callback),
1676
+ (r'\r?\n', Text, 'content')
1677
+ ],
1678
+ 'content': [
1679
+ (r'.+', content_callback)
1680
+ ]
1681
+ }
1682
+
1683
+
1684
+ class PyPyLogLexer(RegexLexer):
1685
+ """
1686
+ Lexer for PyPy log files.
1687
+
1688
+ *New in Pygments 1.5.*
1689
+ """
1690
+ name = "PyPy Log"
1691
+ aliases = ["pypylog", "pypy"]
1692
+ filenames = ["*.pypylog"]
1693
+ mimetypes = ['application/x-pypylog']
1694
+
1695
+ tokens = {
1696
+ "root": [
1697
+ (r"\[\w+\] {jit-log-.*?$", Keyword, "jit-log"),
1698
+ (r"\[\w+\] {jit-backend-counts$", Keyword, "jit-backend-counts"),
1699
+ include("extra-stuff"),
1700
+ ],
1701
+ "jit-log": [
1702
+ (r"\[\w+\] jit-log-.*?}$", Keyword, "#pop"),
1703
+
1704
+ (r"^\+\d+: ", Comment),
1705
+ (r"[ifp]\d+", Name),
1706
+ (r"ptr\d+", Name),
1707
+ (r"(\()(\w+(?:\.\w+)?)(\))",
1708
+ bygroups(Punctuation, Name.Builtin, Punctuation)),
1709
+ (r"[\[\]=,()]", Punctuation),
1710
+ (r"(\d+\.\d+|inf|-inf)", Number.Float),
1711
+ (r"-?\d+", Number.Integer),
1712
+ (r"'.*'", String),
1713
+ (r"(None|descr|ConstClass|ConstPtr|TargetToken)", Name),
1714
+ (r"<.*?>", Name.Builtin),
1715
+ (r"(label|debug_merge_point|jump|finish)", Name.Class),
1716
+ (r"(int_add_ovf|int_add|int_sub_ovf|int_sub|int_mul_ovf|int_mul|"
1717
+ r"int_floordiv|int_mod|int_lshift|int_rshift|int_and|int_or|"
1718
+ r"int_xor|int_eq|int_ne|int_ge|int_gt|int_le|int_lt|int_is_zero|"
1719
+ r"int_is_true|"
1720
+ r"uint_floordiv|uint_ge|uint_lt|"
1721
+ r"float_add|float_sub|float_mul|float_truediv|float_neg|"
1722
+ r"float_eq|float_ne|float_ge|float_gt|float_le|float_lt|float_abs|"
1723
+ r"ptr_eq|ptr_ne|instance_ptr_eq|instance_ptr_ne|"
1724
+ r"cast_int_to_float|cast_float_to_int|"
1725
+ r"force_token|quasiimmut_field|same_as|virtual_ref_finish|"
1726
+ r"virtual_ref|mark_opaque_ptr|"
1727
+ r"call_may_force|call_assembler|call_loopinvariant|"
1728
+ r"call_release_gil|call_pure|call|"
1729
+ r"new_with_vtable|new_array|newstr|newunicode|new|"
1730
+ r"arraylen_gc|"
1731
+ r"getarrayitem_gc_pure|getarrayitem_gc|setarrayitem_gc|"
1732
+ r"getarrayitem_raw|setarrayitem_raw|getfield_gc_pure|"
1733
+ r"getfield_gc|getinteriorfield_gc|setinteriorfield_gc|"
1734
+ r"getfield_raw|setfield_gc|setfield_raw|"
1735
+ r"strgetitem|strsetitem|strlen|copystrcontent|"
1736
+ r"unicodegetitem|unicodesetitem|unicodelen|"
1737
+ r"guard_true|guard_false|guard_value|guard_isnull|"
1738
+ r"guard_nonnull_class|guard_nonnull|guard_class|guard_no_overflow|"
1739
+ r"guard_not_forced|guard_no_exception|guard_not_invalidated)",
1740
+ Name.Builtin),
1741
+ include("extra-stuff"),
1742
+ ],
1743
+ "jit-backend-counts": [
1744
+ (r"\[\w+\] jit-backend-counts}$", Keyword, "#pop"),
1745
+ (r":", Punctuation),
1746
+ (r"\d+", Number),
1747
+ include("extra-stuff"),
1748
+ ],
1749
+ "extra-stuff": [
1750
+ (r"\s+", Text),
1751
+ (r"#.*?$", Comment),
1752
+ ],
1753
+ }