pygments.rb 1.2.1 → 2.0.0

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 (381) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +13 -0
  3. data/.github/workflows/ci.yml +28 -0
  4. data/.github/workflows/release.yml +24 -0
  5. data/.gitignore +5 -6
  6. data/CHANGELOG.adoc +128 -0
  7. data/Gemfile +3 -1
  8. data/LICENSE +1 -1
  9. data/README.adoc +160 -0
  10. data/Rakefile +11 -21
  11. data/bench.rb +8 -7
  12. data/cache-lexers.rb +3 -2
  13. data/lexers +0 -0
  14. data/lib/pygments/lexer.rb +5 -5
  15. data/lib/pygments/mentos.py +23 -110
  16. data/lib/pygments/popen.rb +148 -229
  17. data/lib/pygments/version.rb +2 -2
  18. data/lib/pygments.rb +10 -11
  19. data/pygments.rb.gemspec +12 -10
  20. data/test/test_pygments.rb +46 -104
  21. data/vendor/pygments-main/{AUTHORS → Pygments-2.7.3.dist-info/AUTHORS} +21 -3
  22. data/vendor/pygments-main/Pygments-2.7.3.dist-info/INSTALLER +1 -0
  23. data/vendor/pygments-main/{LICENSE → Pygments-2.7.3.dist-info/LICENSE} +1 -1
  24. data/vendor/pygments-main/Pygments-2.7.3.dist-info/METADATA +49 -0
  25. data/vendor/pygments-main/Pygments-2.7.3.dist-info/RECORD +482 -0
  26. data/vendor/pygments-main/Pygments-2.7.3.dist-info/REQUESTED +0 -0
  27. data/vendor/pygments-main/Pygments-2.7.3.dist-info/WHEEL +5 -0
  28. data/vendor/pygments-main/Pygments-2.7.3.dist-info/entry_points.txt +3 -0
  29. data/vendor/pygments-main/Pygments-2.7.3.dist-info/top_level.txt +1 -0
  30. data/vendor/pygments-main/bin/pygmentize +8 -0
  31. data/vendor/pygments-main/pygments/__init__.py +6 -11
  32. data/vendor/pygments-main/pygments/__main__.py +18 -0
  33. data/vendor/pygments-main/pygments/cmdline.py +38 -29
  34. data/vendor/pygments-main/pygments/console.py +6 -9
  35. data/vendor/pygments-main/pygments/filter.py +4 -6
  36. data/vendor/pygments-main/pygments/filters/__init__.py +609 -21
  37. data/vendor/pygments-main/pygments/formatter.py +4 -4
  38. data/vendor/pygments-main/pygments/formatters/__init__.py +9 -8
  39. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -3
  40. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  41. data/vendor/pygments-main/pygments/formatters/html.py +223 -135
  42. data/vendor/pygments-main/pygments/formatters/img.py +68 -41
  43. data/vendor/pygments-main/pygments/formatters/irc.py +39 -39
  44. data/vendor/pygments-main/pygments/formatters/latex.py +56 -26
  45. data/vendor/pygments-main/pygments/formatters/other.py +12 -8
  46. data/vendor/pygments-main/pygments/formatters/rtf.py +29 -29
  47. data/vendor/pygments-main/pygments/formatters/svg.py +38 -4
  48. data/vendor/pygments-main/pygments/formatters/terminal.py +25 -31
  49. data/vendor/pygments-main/pygments/formatters/terminal256.py +22 -12
  50. data/vendor/pygments-main/pygments/lexer.py +41 -39
  51. data/vendor/pygments-main/pygments/lexers/__init__.py +28 -15
  52. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +5 -5
  53. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +15 -15
  54. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +11 -12
  55. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1717 -1338
  56. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +1 -1
  57. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +2 -4
  58. data/vendor/pygments-main/pygments/lexers/_mapping.py +74 -29
  59. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +2 -2
  60. data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1282 -0
  61. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +1 -1
  62. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +17 -20
  63. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +73 -16
  64. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +2 -2
  65. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1 -3
  66. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +151 -125
  67. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +6 -4
  68. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1 -1
  69. data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +113 -0
  70. data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +280 -0
  71. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1 -1
  72. data/vendor/pygments-main/pygments/lexers/actionscript.py +8 -3
  73. data/vendor/pygments-main/pygments/lexers/agile.py +1 -1
  74. data/vendor/pygments-main/pygments/lexers/algebra.py +20 -1
  75. data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
  76. data/vendor/pygments-main/pygments/lexers/ampl.py +3 -3
  77. data/vendor/pygments-main/pygments/lexers/apl.py +15 -15
  78. data/vendor/pygments-main/pygments/lexers/archetype.py +3 -3
  79. data/vendor/pygments-main/pygments/lexers/arrow.py +117 -0
  80. data/vendor/pygments-main/pygments/lexers/asm.py +440 -76
  81. data/vendor/pygments-main/pygments/lexers/automation.py +1 -1
  82. data/vendor/pygments-main/pygments/lexers/bare.py +104 -0
  83. data/vendor/pygments-main/pygments/lexers/basic.py +166 -4
  84. data/vendor/pygments-main/pygments/lexers/bibtex.py +5 -5
  85. data/vendor/pygments-main/pygments/lexers/boa.py +102 -0
  86. data/vendor/pygments-main/pygments/lexers/business.py +17 -2
  87. data/vendor/pygments-main/pygments/lexers/c_cpp.py +137 -45
  88. data/vendor/pygments-main/pygments/lexers/c_like.py +67 -42
  89. data/vendor/pygments-main/pygments/lexers/capnproto.py +7 -7
  90. data/vendor/pygments-main/pygments/lexers/chapel.py +23 -13
  91. data/vendor/pygments-main/pygments/lexers/clean.py +135 -244
  92. data/vendor/pygments-main/pygments/lexers/compiled.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/configs.py +187 -36
  94. data/vendor/pygments-main/pygments/lexers/console.py +1 -1
  95. data/vendor/pygments-main/pygments/lexers/crystal.py +3 -4
  96. data/vendor/pygments-main/pygments/lexers/csound.py +288 -187
  97. data/vendor/pygments-main/pygments/lexers/css.py +18 -16
  98. data/vendor/pygments-main/pygments/lexers/d.py +10 -5
  99. data/vendor/pygments-main/pygments/lexers/dalvik.py +1 -1
  100. data/vendor/pygments-main/pygments/lexers/data.py +240 -97
  101. data/vendor/pygments-main/pygments/lexers/devicetree.py +109 -0
  102. data/vendor/pygments-main/pygments/lexers/diff.py +4 -4
  103. data/vendor/pygments-main/pygments/lexers/dotnet.py +40 -24
  104. data/vendor/pygments-main/pygments/lexers/dsls.py +144 -62
  105. data/vendor/pygments-main/pygments/lexers/dylan.py +16 -18
  106. data/vendor/pygments-main/pygments/lexers/ecl.py +16 -2
  107. data/vendor/pygments-main/pygments/lexers/eiffel.py +1 -1
  108. data/vendor/pygments-main/pygments/lexers/elm.py +5 -5
  109. data/vendor/pygments-main/pygments/lexers/email.py +151 -0
  110. data/vendor/pygments-main/pygments/lexers/erlang.py +29 -32
  111. data/vendor/pygments-main/pygments/lexers/esoteric.py +46 -19
  112. data/vendor/pygments-main/pygments/lexers/ezhil.py +21 -13
  113. data/vendor/pygments-main/pygments/lexers/factor.py +1 -1
  114. data/vendor/pygments-main/pygments/lexers/fantom.py +1 -1
  115. data/vendor/pygments-main/pygments/lexers/felix.py +1 -1
  116. data/vendor/pygments-main/pygments/lexers/floscript.py +83 -0
  117. data/vendor/pygments-main/pygments/lexers/forth.py +41 -40
  118. data/vendor/pygments-main/pygments/lexers/fortran.py +5 -4
  119. data/vendor/pygments-main/pygments/lexers/foxpro.py +2 -2
  120. data/vendor/pygments-main/pygments/lexers/freefem.py +898 -0
  121. data/vendor/pygments-main/pygments/lexers/functional.py +1 -1
  122. data/vendor/pygments-main/pygments/lexers/gdscript.py +346 -0
  123. data/vendor/pygments-main/pygments/lexers/go.py +1 -1
  124. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +62 -5
  125. data/vendor/pygments-main/pygments/lexers/graph.py +14 -9
  126. data/vendor/pygments-main/pygments/lexers/graphics.py +272 -25
  127. data/vendor/pygments-main/pygments/lexers/haskell.py +48 -21
  128. data/vendor/pygments-main/pygments/lexers/haxe.py +6 -6
  129. data/vendor/pygments-main/pygments/lexers/hdl.py +176 -86
  130. data/vendor/pygments-main/pygments/lexers/hexdump.py +1 -1
  131. data/vendor/pygments-main/pygments/lexers/html.py +31 -19
  132. data/vendor/pygments-main/pygments/lexers/idl.py +19 -8
  133. data/vendor/pygments-main/pygments/lexers/igor.py +244 -112
  134. data/vendor/pygments-main/pygments/lexers/inferno.py +2 -2
  135. data/vendor/pygments-main/pygments/lexers/installers.py +1 -1
  136. data/vendor/pygments-main/pygments/lexers/int_fiction.py +40 -15
  137. data/vendor/pygments-main/pygments/lexers/iolang.py +2 -2
  138. data/vendor/pygments-main/pygments/lexers/j.py +3 -3
  139. data/vendor/pygments-main/pygments/lexers/javascript.py +60 -45
  140. data/vendor/pygments-main/pygments/lexers/julia.py +44 -46
  141. data/vendor/pygments-main/pygments/lexers/jvm.py +265 -165
  142. data/vendor/pygments-main/pygments/lexers/lisp.py +882 -804
  143. data/vendor/pygments-main/pygments/lexers/make.py +10 -6
  144. data/vendor/pygments-main/pygments/lexers/markup.py +213 -43
  145. data/vendor/pygments-main/pygments/lexers/math.py +1 -1
  146. data/vendor/pygments-main/pygments/lexers/matlab.py +98 -41
  147. data/vendor/pygments-main/pygments/lexers/mime.py +226 -0
  148. data/vendor/pygments-main/pygments/lexers/ml.py +198 -9
  149. data/vendor/pygments-main/pygments/lexers/modeling.py +26 -18
  150. data/vendor/pygments-main/pygments/lexers/modula2.py +25 -6
  151. data/vendor/pygments-main/pygments/lexers/monte.py +1 -1
  152. data/vendor/pygments-main/pygments/lexers/mosel.py +448 -0
  153. data/vendor/pygments-main/pygments/lexers/ncl.py +1 -1
  154. data/vendor/pygments-main/pygments/lexers/nimrod.py +4 -4
  155. data/vendor/pygments-main/pygments/lexers/nit.py +1 -1
  156. data/vendor/pygments-main/pygments/lexers/nix.py +1 -1
  157. data/vendor/pygments-main/pygments/lexers/oberon.py +17 -1
  158. data/vendor/pygments-main/pygments/lexers/objective.py +16 -16
  159. data/vendor/pygments-main/pygments/lexers/ooc.py +1 -1
  160. data/vendor/pygments-main/pygments/lexers/other.py +1 -1
  161. data/vendor/pygments-main/pygments/lexers/parasail.py +1 -1
  162. data/vendor/pygments-main/pygments/lexers/parsers.py +23 -58
  163. data/vendor/pygments-main/pygments/lexers/pascal.py +22 -22
  164. data/vendor/pygments-main/pygments/lexers/pawn.py +30 -24
  165. data/vendor/pygments-main/pygments/lexers/perl.py +260 -148
  166. data/vendor/pygments-main/pygments/lexers/php.py +64 -10
  167. data/vendor/pygments-main/pygments/lexers/pointless.py +71 -0
  168. data/vendor/pygments-main/pygments/lexers/pony.py +94 -0
  169. data/vendor/pygments-main/pygments/lexers/praat.py +38 -30
  170. data/vendor/pygments-main/pygments/lexers/prolog.py +36 -36
  171. data/vendor/pygments-main/pygments/lexers/promql.py +183 -0
  172. data/vendor/pygments-main/pygments/lexers/python.py +439 -227
  173. data/vendor/pygments-main/pygments/lexers/qvt.py +6 -6
  174. data/vendor/pygments-main/pygments/lexers/r.py +13 -275
  175. data/vendor/pygments-main/pygments/lexers/rdf.py +232 -39
  176. data/vendor/pygments-main/pygments/lexers/rebol.py +8 -8
  177. data/vendor/pygments-main/pygments/lexers/resource.py +2 -2
  178. data/vendor/pygments-main/pygments/lexers/ride.py +139 -0
  179. data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
  180. data/vendor/pygments-main/pygments/lexers/roboconf.py +1 -1
  181. data/vendor/pygments-main/pygments/lexers/robotframework.py +23 -31
  182. data/vendor/pygments-main/pygments/lexers/ruby.py +22 -24
  183. data/vendor/pygments-main/pygments/lexers/rust.py +76 -72
  184. data/vendor/pygments-main/pygments/lexers/sas.py +1 -1
  185. data/vendor/pygments-main/pygments/lexers/scdoc.py +83 -0
  186. data/vendor/pygments-main/pygments/lexers/scripting.py +75 -13
  187. data/vendor/pygments-main/pygments/lexers/sgf.py +61 -0
  188. data/vendor/pygments-main/pygments/lexers/shell.py +162 -42
  189. data/vendor/pygments-main/pygments/lexers/sieve.py +69 -0
  190. data/vendor/pygments-main/pygments/lexers/slash.py +185 -0
  191. data/vendor/pygments-main/pygments/lexers/smalltalk.py +2 -2
  192. data/vendor/pygments-main/pygments/lexers/smv.py +3 -3
  193. data/vendor/pygments-main/pygments/lexers/snobol.py +1 -1
  194. data/vendor/pygments-main/pygments/lexers/solidity.py +92 -0
  195. data/vendor/pygments-main/pygments/lexers/special.py +5 -3
  196. data/vendor/pygments-main/pygments/lexers/sql.py +333 -177
  197. data/vendor/pygments-main/pygments/lexers/stata.py +107 -44
  198. data/vendor/pygments-main/pygments/lexers/supercollider.py +6 -1
  199. data/vendor/pygments-main/pygments/lexers/tcl.py +1 -1
  200. data/vendor/pygments-main/pygments/lexers/templates.py +102 -121
  201. data/vendor/pygments-main/pygments/lexers/teraterm.py +335 -0
  202. data/vendor/pygments-main/pygments/lexers/testing.py +6 -6
  203. data/vendor/pygments-main/pygments/lexers/text.py +2 -1
  204. data/vendor/pygments-main/pygments/lexers/textedit.py +4 -4
  205. data/vendor/pygments-main/pygments/lexers/textfmts.py +146 -13
  206. data/vendor/pygments-main/pygments/lexers/theorem.py +69 -53
  207. data/vendor/pygments-main/pygments/lexers/tnt.py +263 -0
  208. data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
  209. data/vendor/pygments-main/pygments/lexers/typoscript.py +4 -11
  210. data/vendor/pygments-main/pygments/lexers/unicon.py +412 -0
  211. data/vendor/pygments-main/pygments/lexers/urbi.py +14 -1
  212. data/vendor/pygments-main/pygments/lexers/usd.py +90 -0
  213. data/vendor/pygments-main/pygments/lexers/varnish.py +3 -3
  214. data/vendor/pygments-main/pygments/lexers/verification.py +13 -10
  215. data/vendor/pygments-main/pygments/lexers/web.py +1 -1
  216. data/vendor/pygments-main/pygments/lexers/webidl.py +299 -0
  217. data/vendor/pygments-main/pygments/lexers/webmisc.py +31 -28
  218. data/vendor/pygments-main/pygments/lexers/whiley.py +5 -5
  219. data/vendor/pygments-main/pygments/lexers/x10.py +1 -1
  220. data/vendor/pygments-main/pygments/lexers/xorg.py +5 -4
  221. data/vendor/pygments-main/pygments/lexers/yang.py +104 -0
  222. data/vendor/pygments-main/pygments/lexers/zig.py +124 -0
  223. data/vendor/pygments-main/pygments/modeline.py +1 -1
  224. data/vendor/pygments-main/pygments/plugin.py +4 -2
  225. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  226. data/vendor/pygments-main/pygments/scanner.py +2 -2
  227. data/vendor/pygments-main/pygments/sphinxext.py +2 -4
  228. data/vendor/pygments-main/pygments/style.py +61 -24
  229. data/vendor/pygments-main/pygments/styles/__init__.py +10 -4
  230. data/vendor/pygments-main/pygments/styles/abap.py +1 -1
  231. data/vendor/pygments-main/pygments/styles/algol.py +1 -1
  232. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
  233. data/vendor/pygments-main/pygments/styles/arduino.py +2 -2
  234. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  235. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  236. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  237. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  238. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  239. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  240. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  241. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  242. data/vendor/pygments-main/pygments/styles/igor.py +1 -1
  243. data/vendor/pygments-main/pygments/styles/inkpot.py +67 -0
  244. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
  245. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  246. data/vendor/pygments-main/pygments/styles/monokai.py +4 -3
  247. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  248. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  249. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -1
  250. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -1
  251. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  252. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  253. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -1
  254. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  255. data/vendor/pygments-main/pygments/styles/sas.py +1 -1
  256. data/vendor/pygments-main/pygments/styles/solarized.py +134 -0
  257. data/vendor/pygments-main/pygments/styles/stata_dark.py +41 -0
  258. data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -15
  259. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  260. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  261. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  262. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  263. data/vendor/pygments-main/pygments/styles/xcode.py +1 -1
  264. data/vendor/pygments-main/pygments/token.py +1 -1
  265. data/vendor/pygments-main/pygments/unistring.py +47 -108
  266. data/vendor/pygments-main/pygments/util.py +15 -92
  267. metadata +68 -136
  268. data/CHANGELOG.md +0 -111
  269. data/README.md +0 -121
  270. data/circle.yml +0 -20
  271. data/test/test_data.c +0 -2581
  272. data/test/test_data.py +0 -514
  273. data/test/test_data_generated +0 -2582
  274. data/vendor/custom_lexers/github.py +0 -565
  275. data/vendor/pygments-main/CHANGES +0 -1186
  276. data/vendor/pygments-main/MANIFEST.in +0 -6
  277. data/vendor/pygments-main/Makefile +0 -65
  278. data/vendor/pygments-main/README.rst +0 -39
  279. data/vendor/pygments-main/REVISION +0 -1
  280. data/vendor/pygments-main/TODO +0 -12
  281. data/vendor/pygments-main/doc/Makefile +0 -153
  282. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  283. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  284. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  285. data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
  286. data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
  287. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
  288. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  289. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  290. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  291. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  292. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  293. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
  294. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
  295. data/vendor/pygments-main/doc/conf.py +0 -241
  296. data/vendor/pygments-main/doc/docs/api.rst +0 -354
  297. data/vendor/pygments-main/doc/docs/authors.rst +0 -4
  298. data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
  299. data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
  300. data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
  301. data/vendor/pygments-main/doc/docs/filters.rst +0 -41
  302. data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
  303. data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
  304. data/vendor/pygments-main/doc/docs/index.rst +0 -66
  305. data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
  306. data/vendor/pygments-main/doc/docs/java.rst +0 -70
  307. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
  308. data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
  309. data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
  310. data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
  311. data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
  312. data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
  313. data/vendor/pygments-main/doc/docs/styles.rst +0 -201
  314. data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
  315. data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
  316. data/vendor/pygments-main/doc/download.rst +0 -41
  317. data/vendor/pygments-main/doc/faq.rst +0 -139
  318. data/vendor/pygments-main/doc/index.rst +0 -54
  319. data/vendor/pygments-main/doc/languages.rst +0 -154
  320. data/vendor/pygments-main/doc/make.bat +0 -190
  321. data/vendor/pygments-main/doc/pygmentize.1 +0 -94
  322. data/vendor/pygments-main/external/autopygmentize +0 -101
  323. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
  324. data/vendor/pygments-main/external/markdown-processor.py +0 -67
  325. data/vendor/pygments-main/external/moin-parser.py +0 -112
  326. data/vendor/pygments-main/external/pygments.bashcomp +0 -38
  327. data/vendor/pygments-main/external/rst-directive.py +0 -82
  328. data/vendor/pygments-main/pygmentize +0 -8
  329. data/vendor/pygments-main/pygments/lexers/github.py +0 -565
  330. data/vendor/pygments-main/requirements.txt +0 -5
  331. data/vendor/pygments-main/scripts/check_sources.py +0 -211
  332. data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
  333. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
  334. data/vendor/pygments-main/scripts/epydoc.css +0 -280
  335. data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
  336. data/vendor/pygments-main/scripts/pylintrc +0 -301
  337. data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
  338. data/vendor/pygments-main/setup.cfg +0 -10
  339. data/vendor/pygments-main/setup.py +0 -77
  340. data/vendor/pygments-main/tox.ini +0 -7
  341. data/vendor/simplejson/.gitignore +0 -10
  342. data/vendor/simplejson/.travis.yml +0 -5
  343. data/vendor/simplejson/CHANGES.txt +0 -291
  344. data/vendor/simplejson/LICENSE.txt +0 -19
  345. data/vendor/simplejson/MANIFEST.in +0 -5
  346. data/vendor/simplejson/README.rst +0 -19
  347. data/vendor/simplejson/conf.py +0 -179
  348. data/vendor/simplejson/index.rst +0 -628
  349. data/vendor/simplejson/scripts/make_docs.py +0 -18
  350. data/vendor/simplejson/setup.py +0 -104
  351. data/vendor/simplejson/simplejson/__init__.py +0 -510
  352. data/vendor/simplejson/simplejson/_speedups.c +0 -2745
  353. data/vendor/simplejson/simplejson/decoder.py +0 -425
  354. data/vendor/simplejson/simplejson/encoder.py +0 -567
  355. data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
  356. data/vendor/simplejson/simplejson/scanner.py +0 -77
  357. data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
  358. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
  359. data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
  360. data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
  361. data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
  362. data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
  363. data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
  364. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
  365. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
  366. data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
  367. data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
  368. data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
  369. data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
  370. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
  371. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
  372. data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
  373. data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
  374. data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
  375. data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
  376. data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
  377. data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
  378. data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
  379. data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
  380. data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
  381. data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -1,354 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- =====================
4
- The full Pygments API
5
- =====================
6
-
7
- This page describes the Pygments API.
8
-
9
- High-level API
10
- ==============
11
-
12
- .. module:: pygments
13
-
14
- Functions from the :mod:`pygments` module:
15
-
16
- .. function:: lex(code, lexer)
17
-
18
- Lex `code` with the `lexer` (must be a `Lexer` instance)
19
- and return an iterable of tokens. Currently, this only calls
20
- `lexer.get_tokens()`.
21
-
22
- .. function:: format(tokens, formatter, outfile=None)
23
-
24
- Format a token stream (iterable of tokens) `tokens` with the
25
- `formatter` (must be a `Formatter` instance). The result is
26
- written to `outfile`, or if that is ``None``, returned as a
27
- string.
28
-
29
- .. function:: highlight(code, lexer, formatter, outfile=None)
30
-
31
- This is the most high-level highlighting function.
32
- It combines `lex` and `format` in one function.
33
-
34
-
35
- .. module:: pygments.lexers
36
-
37
- Functions from :mod:`pygments.lexers`:
38
-
39
- .. function:: get_lexer_by_name(alias, **options)
40
-
41
- Return an instance of a `Lexer` subclass that has `alias` in its
42
- aliases list. The lexer is given the `options` at its
43
- instantiation.
44
-
45
- Will raise :exc:`pygments.util.ClassNotFound` if no lexer with that alias is
46
- found.
47
-
48
- .. function:: get_lexer_for_filename(fn, **options)
49
-
50
- Return a `Lexer` subclass instance that has a filename pattern
51
- matching `fn`. The lexer is given the `options` at its
52
- instantiation.
53
-
54
- Will raise :exc:`pygments.util.ClassNotFound` if no lexer for that filename
55
- is found.
56
-
57
- .. function:: get_lexer_for_mimetype(mime, **options)
58
-
59
- Return a `Lexer` subclass instance that has `mime` in its mimetype
60
- list. The lexer is given the `options` at its instantiation.
61
-
62
- Will raise :exc:`pygments.util.ClassNotFound` if not lexer for that mimetype
63
- is found.
64
-
65
- .. function:: load_lexer_from_file(filename, lexername="CustomLexer", **options)
66
-
67
- Return a `Lexer` subclass instance loaded from the provided file, relative
68
- to the current directory. The file is expected to contain a Lexer class
69
- named `lexername` (by default, CustomLexer). Users should be very careful with
70
- the input, because this method is equivalent to running eval on the input file.
71
- The lexer is given the `options` at its instantiation.
72
-
73
- :exc:`ClassNotFound` is raised if there are any errors loading the Lexer
74
-
75
- .. versionadded:: 2.2
76
-
77
- .. function:: guess_lexer(text, **options)
78
-
79
- Return a `Lexer` subclass instance that's guessed from the text in
80
- `text`. For that, the :meth:`.analyse_text()` method of every known lexer
81
- class is called with the text as argument, and the lexer which returned the
82
- highest value will be instantiated and returned.
83
-
84
- :exc:`pygments.util.ClassNotFound` is raised if no lexer thinks it can
85
- handle the content.
86
-
87
- .. function:: guess_lexer_for_filename(filename, text, **options)
88
-
89
- As :func:`guess_lexer()`, but only lexers which have a pattern in `filenames`
90
- or `alias_filenames` that matches `filename` are taken into consideration.
91
-
92
- :exc:`pygments.util.ClassNotFound` is raised if no lexer thinks it can
93
- handle the content.
94
-
95
- .. function:: get_all_lexers()
96
-
97
- Return an iterable over all registered lexers, yielding tuples in the
98
- format::
99
-
100
- (longname, tuple of aliases, tuple of filename patterns, tuple of mimetypes)
101
-
102
- .. versionadded:: 0.6
103
-
104
- .. function:: find_lexer_class_by_name(alias)
105
-
106
- Return the `Lexer` subclass that has `alias` in its aliases list, without
107
- instantiating it.
108
-
109
- Will raise :exc:`pygments.util.ClassNotFound` if no lexer with that alias is
110
- found.
111
-
112
- .. versionadded:: 2.2
113
-
114
- .. function:: find_lexer_class(name)
115
-
116
- Return the `Lexer` subclass that with the *name* attribute as given by
117
- the *name* argument.
118
-
119
-
120
- .. module:: pygments.formatters
121
-
122
- Functions from :mod:`pygments.formatters`:
123
-
124
- .. function:: get_formatter_by_name(alias, **options)
125
-
126
- Return an instance of a :class:`.Formatter` subclass that has `alias` in its
127
- aliases list. The formatter is given the `options` at its instantiation.
128
-
129
- Will raise :exc:`pygments.util.ClassNotFound` if no formatter with that
130
- alias is found.
131
-
132
- .. function:: get_formatter_for_filename(fn, **options)
133
-
134
- Return a :class:`.Formatter` subclass instance that has a filename pattern
135
- matching `fn`. The formatter is given the `options` at its instantiation.
136
-
137
- Will raise :exc:`pygments.util.ClassNotFound` if no formatter for that filename
138
- is found.
139
-
140
- .. function:: load_formatter_from_file(filename, formattername="CustomFormatter", **options)
141
-
142
- Return a `Formatter` subclass instance loaded from the provided file, relative
143
- to the current directory. The file is expected to contain a Formatter class
144
- named ``formattername`` (by default, CustomFormatter). Users should be very
145
- careful with the input, because this method is equivalent to running eval
146
- on the input file. The formatter is given the `options` at its instantiation.
147
-
148
- :exc:`ClassNotFound` is raised if there are any errors loading the Formatter
149
-
150
- .. versionadded:: 2.2
151
-
152
- .. module:: pygments.styles
153
-
154
- Functions from :mod:`pygments.styles`:
155
-
156
- .. function:: get_style_by_name(name)
157
-
158
- Return a style class by its short name. The names of the builtin styles
159
- are listed in :data:`pygments.styles.STYLE_MAP`.
160
-
161
- Will raise :exc:`pygments.util.ClassNotFound` if no style of that name is
162
- found.
163
-
164
- .. function:: get_all_styles()
165
-
166
- Return an iterable over all registered styles, yielding their names.
167
-
168
- .. versionadded:: 0.6
169
-
170
-
171
- .. module:: pygments.lexer
172
-
173
- Lexers
174
- ======
175
-
176
- The base lexer class from which all lexers are derived is:
177
-
178
- .. class:: Lexer(**options)
179
-
180
- The constructor takes a \*\*keywords dictionary of options.
181
- Every subclass must first process its own options and then call
182
- the `Lexer` constructor, since it processes the `stripnl`,
183
- `stripall` and `tabsize` options.
184
-
185
- An example looks like this:
186
-
187
- .. sourcecode:: python
188
-
189
- def __init__(self, **options):
190
- self.compress = options.get('compress', '')
191
- Lexer.__init__(self, **options)
192
-
193
- As these options must all be specifiable as strings (due to the
194
- command line usage), there are various utility functions
195
- available to help with that, see `Option processing`_.
196
-
197
- .. method:: get_tokens(text)
198
-
199
- This method is the basic interface of a lexer. It is called by
200
- the `highlight()` function. It must process the text and return an
201
- iterable of ``(tokentype, value)`` pairs from `text`.
202
-
203
- Normally, you don't need to override this method. The default
204
- implementation processes the `stripnl`, `stripall` and `tabsize`
205
- options and then yields all tokens from `get_tokens_unprocessed()`,
206
- with the ``index`` dropped.
207
-
208
- .. method:: get_tokens_unprocessed(text)
209
-
210
- This method should process the text and return an iterable of
211
- ``(index, tokentype, value)`` tuples where ``index`` is the starting
212
- position of the token within the input text.
213
-
214
- This method must be overridden by subclasses.
215
-
216
- .. staticmethod:: analyse_text(text)
217
-
218
- A static method which is called for lexer guessing. It should analyse
219
- the text and return a float in the range from ``0.0`` to ``1.0``.
220
- If it returns ``0.0``, the lexer will not be selected as the most
221
- probable one, if it returns ``1.0``, it will be selected immediately.
222
-
223
- .. note:: You don't have to add ``@staticmethod`` to the definition of
224
- this method, this will be taken care of by the Lexer's metaclass.
225
-
226
- For a list of known tokens have a look at the :doc:`tokens` page.
227
-
228
- A lexer also can have the following attributes (in fact, they are mandatory
229
- except `alias_filenames`) that are used by the builtin lookup mechanism.
230
-
231
- .. attribute:: name
232
-
233
- Full name for the lexer, in human-readable form.
234
-
235
- .. attribute:: aliases
236
-
237
- A list of short, unique identifiers that can be used to lookup
238
- the lexer from a list, e.g. using `get_lexer_by_name()`.
239
-
240
- .. attribute:: filenames
241
-
242
- A list of `fnmatch` patterns that match filenames which contain
243
- content for this lexer. The patterns in this list should be unique among
244
- all lexers.
245
-
246
- .. attribute:: alias_filenames
247
-
248
- A list of `fnmatch` patterns that match filenames which may or may not
249
- contain content for this lexer. This list is used by the
250
- :func:`.guess_lexer_for_filename()` function, to determine which lexers
251
- are then included in guessing the correct one. That means that
252
- e.g. every lexer for HTML and a template language should include
253
- ``\*.html`` in this list.
254
-
255
- .. attribute:: mimetypes
256
-
257
- A list of MIME types for content that can be lexed with this
258
- lexer.
259
-
260
-
261
- .. module:: pygments.formatter
262
-
263
- Formatters
264
- ==========
265
-
266
- A formatter is derived from this class:
267
-
268
-
269
- .. class:: Formatter(**options)
270
-
271
- As with lexers, this constructor processes options and then must call the
272
- base class :meth:`__init__`.
273
-
274
- The :class:`Formatter` class recognizes the options `style`, `full` and
275
- `title`. It is up to the formatter class whether it uses them.
276
-
277
- .. method:: get_style_defs(arg='')
278
-
279
- This method must return statements or declarations suitable to define
280
- the current style for subsequent highlighted text (e.g. CSS classes
281
- in the `HTMLFormatter`).
282
-
283
- The optional argument `arg` can be used to modify the generation and
284
- is formatter dependent (it is standardized because it can be given on
285
- the command line).
286
-
287
- This method is called by the ``-S`` :doc:`command-line option <cmdline>`,
288
- the `arg` is then given by the ``-a`` option.
289
-
290
- .. method:: format(tokensource, outfile)
291
-
292
- This method must format the tokens from the `tokensource` iterable and
293
- write the formatted version to the file object `outfile`.
294
-
295
- Formatter options can control how exactly the tokens are converted.
296
-
297
- .. versionadded:: 0.7
298
- A formatter must have the following attributes that are used by the
299
- builtin lookup mechanism.
300
-
301
- .. attribute:: name
302
-
303
- Full name for the formatter, in human-readable form.
304
-
305
- .. attribute:: aliases
306
-
307
- A list of short, unique identifiers that can be used to lookup
308
- the formatter from a list, e.g. using :func:`.get_formatter_by_name()`.
309
-
310
- .. attribute:: filenames
311
-
312
- A list of :mod:`fnmatch` patterns that match filenames for which this
313
- formatter can produce output. The patterns in this list should be unique
314
- among all formatters.
315
-
316
-
317
- .. module:: pygments.util
318
-
319
- Option processing
320
- =================
321
-
322
- The :mod:`pygments.util` module has some utility functions usable for option
323
- processing:
324
-
325
- .. exception:: OptionError
326
-
327
- This exception will be raised by all option processing functions if
328
- the type or value of the argument is not correct.
329
-
330
- .. function:: get_bool_opt(options, optname, default=None)
331
-
332
- Interpret the key `optname` from the dictionary `options` as a boolean and
333
- return it. Return `default` if `optname` is not in `options`.
334
-
335
- The valid string values for ``True`` are ``1``, ``yes``, ``true`` and
336
- ``on``, the ones for ``False`` are ``0``, ``no``, ``false`` and ``off``
337
- (matched case-insensitively).
338
-
339
- .. function:: get_int_opt(options, optname, default=None)
340
-
341
- As :func:`get_bool_opt`, but interpret the value as an integer.
342
-
343
- .. function:: get_list_opt(options, optname, default=None)
344
-
345
- If the key `optname` from the dictionary `options` is a string,
346
- split it at whitespace and return it. If it is already a list
347
- or a tuple, it is returned as a list.
348
-
349
- .. function:: get_choice_opt(options, optname, allowed, default=None)
350
-
351
- If the key `optname` from the dictionary is not in the sequence
352
- `allowed`, raise an error, otherwise return it.
353
-
354
- .. versionadded:: 0.8
@@ -1,4 +0,0 @@
1
- Full contributor list
2
- =====================
3
-
4
- .. include:: ../../AUTHORS
@@ -1 +0,0 @@
1
- .. include:: ../../CHANGES
@@ -1,166 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- ======================
4
- Command Line Interface
5
- ======================
6
-
7
- You can use Pygments from the shell, provided you installed the
8
- :program:`pygmentize` script::
9
-
10
- $ pygmentize test.py
11
- print "Hello World"
12
-
13
- will print the file test.py to standard output, using the Python lexer
14
- (inferred from the file name extension) and the terminal formatter (because
15
- you didn't give an explicit formatter name).
16
-
17
- If you want HTML output::
18
-
19
- $ pygmentize -f html -l python -o test.html test.py
20
-
21
- As you can see, the -l option explicitly selects a lexer. As seen above, if you
22
- give an input file name and it has an extension that Pygments recognizes, you can
23
- omit this option.
24
-
25
- The ``-o`` option gives an output file name. If it is not given, output is
26
- written to stdout.
27
-
28
- The ``-f`` option selects a formatter (as with ``-l``, it can also be omitted
29
- if an output file name is given and has a supported extension).
30
- If no output file name is given and ``-f`` is omitted, the
31
- :class:`.TerminalFormatter` is used.
32
-
33
- The above command could therefore also be given as::
34
-
35
- $ pygmentize -o test.html test.py
36
-
37
- To create a full HTML document, including line numbers and stylesheet (using the
38
- "emacs" style), highlighting the Python file ``test.py`` to ``test.html``::
39
-
40
- $ pygmentize -O full,style=emacs -o test.html test.py
41
-
42
-
43
- Options and filters
44
- -------------------
45
-
46
- Lexer and formatter options can be given using the ``-O`` option::
47
-
48
- $ pygmentize -f html -O style=colorful,linenos=1 -l python test.py
49
-
50
- Be sure to enclose the option string in quotes if it contains any special shell
51
- characters, such as spaces or expansion wildcards like ``*``. If an option
52
- expects a list value, separate the list entries with spaces (you'll have to
53
- quote the option value in this case too, so that the shell doesn't split it).
54
-
55
- Since the ``-O`` option argument is split at commas and expects the split values
56
- to be of the form ``name=value``, you can't give an option value that contains
57
- commas or equals signs. Therefore, an option ``-P`` is provided (as of Pygments
58
- 0.9) that works like ``-O`` but can only pass one option per ``-P``. Its value
59
- can then contain all characters::
60
-
61
- $ pygmentize -P "heading=Pygments, the Python highlighter" ...
62
-
63
- Filters are added to the token stream using the ``-F`` option::
64
-
65
- $ pygmentize -f html -l pascal -F keywordcase:case=upper main.pas
66
-
67
- As you see, options for the filter are given after a colon. As for ``-O``, the
68
- filter name and options must be one shell word, so there may not be any spaces
69
- around the colon.
70
-
71
-
72
- Generating styles
73
- -----------------
74
-
75
- Formatters normally don't output full style information. For example, the HTML
76
- formatter by default only outputs ``<span>`` tags with ``class`` attributes.
77
- Therefore, there's a special ``-S`` option for generating style definitions.
78
- Usage is as follows::
79
-
80
- $ pygmentize -f html -S colorful -a .syntax
81
-
82
- generates a CSS style sheet (because you selected the HTML formatter) for
83
- the "colorful" style prepending a ".syntax" selector to all style rules.
84
-
85
- For an explanation what ``-a`` means for :doc:`a particular formatter
86
- <formatters>`, look for the `arg` argument for the formatter's
87
- :meth:`.get_style_defs()` method.
88
-
89
-
90
- Getting lexer names
91
- -------------------
92
-
93
- .. versionadded:: 1.0
94
-
95
- The ``-N`` option guesses a lexer name for a given filename, so that ::
96
-
97
- $ pygmentize -N setup.py
98
-
99
- will print out ``python``. It won't highlight anything yet. If no specific
100
- lexer is known for that filename, ``text`` is printed.
101
-
102
- Custom Lexers and Formatters
103
- ----------------------------
104
-
105
- .. versionadded:: 2.2
106
-
107
- The ``-x`` flag enables custom lexers and formatters to be loaded
108
- from files relative to the current directory. Create a file with a class named
109
- CustomLexer or CustomFormatter, then specify it on the command line::
110
-
111
- $ pygmentize -l your_lexer.py -f your_formatter.py -x
112
-
113
- You can also specify the name of your class with a colon::
114
-
115
- $ pygmentize -l your_lexer.py:SomeLexer -x
116
-
117
- For more information, see :doc:`the Pygments documentation on Lexer development
118
- <lexerdevelopment>`.
119
-
120
- Getting help
121
- ------------
122
-
123
- The ``-L`` option lists lexers, formatters, along with their short
124
- names and supported file name extensions, styles and filters. If you want to see
125
- only one category, give it as an argument::
126
-
127
- $ pygmentize -L filters
128
-
129
- will list only all installed filters.
130
-
131
- The ``-H`` option will give you detailed information (the same that can be found
132
- in this documentation) about a lexer, formatter or filter. Usage is as follows::
133
-
134
- $ pygmentize -H formatter html
135
-
136
- will print the help for the HTML formatter, while ::
137
-
138
- $ pygmentize -H lexer python
139
-
140
- will print the help for the Python lexer, etc.
141
-
142
-
143
- A note on encodings
144
- -------------------
145
-
146
- .. versionadded:: 0.9
147
-
148
- Pygments tries to be smart regarding encodings in the formatting process:
149
-
150
- * If you give an ``encoding`` option, it will be used as the input and
151
- output encoding.
152
-
153
- * If you give an ``outencoding`` option, it will override ``encoding``
154
- as the output encoding.
155
-
156
- * If you give an ``inencoding`` option, it will override ``encoding``
157
- as the input encoding.
158
-
159
- * If you don't give an encoding and have given an output file, the default
160
- encoding for lexer and formatter is the terminal encoding or the default
161
- locale encoding of the system. As a last resort, ``latin1`` is used (which
162
- will pass through all non-ASCII characters).
163
-
164
- * If you don't give an encoding and haven't given an output file (that means
165
- output is written to the console), the default encoding for lexer and
166
- formatter is the terminal encoding (``sys.stdout.encoding``).
@@ -1,71 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- =====================
4
- Write your own filter
5
- =====================
6
-
7
- .. versionadded:: 0.7
8
-
9
- Writing own filters is very easy. All you have to do is to subclass
10
- the `Filter` class and override the `filter` method. Additionally a
11
- filter is instantiated with some keyword arguments you can use to
12
- adjust the behavior of your filter.
13
-
14
-
15
- Subclassing Filters
16
- ===================
17
-
18
- As an example, we write a filter that converts all `Name.Function` tokens
19
- to normal `Name` tokens to make the output less colorful.
20
-
21
- .. sourcecode:: python
22
-
23
- from pygments.util import get_bool_opt
24
- from pygments.token import Name
25
- from pygments.filter import Filter
26
-
27
- class UncolorFilter(Filter):
28
-
29
- def __init__(self, **options):
30
- Filter.__init__(self, **options)
31
- self.class_too = get_bool_opt(options, 'classtoo')
32
-
33
- def filter(self, lexer, stream):
34
- for ttype, value in stream:
35
- if ttype is Name.Function or (self.class_too and
36
- ttype is Name.Class):
37
- ttype = Name
38
- yield ttype, value
39
-
40
- Some notes on the `lexer` argument: that can be quite confusing since it doesn't
41
- need to be a lexer instance. If a filter was added by using the `add_filter()`
42
- function of lexers, that lexer is registered for the filter. In that case
43
- `lexer` will refer to the lexer that has registered the filter. It *can* be used
44
- to access options passed to a lexer. Because it could be `None` you always have
45
- to check for that case if you access it.
46
-
47
-
48
- Using a decorator
49
- =================
50
-
51
- You can also use the `simplefilter` decorator from the `pygments.filter` module:
52
-
53
- .. sourcecode:: python
54
-
55
- from pygments.util import get_bool_opt
56
- from pygments.token import Name
57
- from pygments.filter import simplefilter
58
-
59
-
60
- @simplefilter
61
- def uncolor(self, lexer, stream, options):
62
- class_too = get_bool_opt(options, 'classtoo')
63
- for ttype, value in stream:
64
- if ttype is Name.Function or (class_too and
65
- ttype is Name.Class):
66
- ttype = Name
67
- yield ttype, value
68
-
69
- The decorator automatically subclasses an internal filter class and uses the
70
- decorated function as a method for filtering. (That's why there is a `self`
71
- argument that you probably won't end up using in the method.)
@@ -1,41 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- =======
4
- Filters
5
- =======
6
-
7
- .. versionadded:: 0.7
8
-
9
- You can filter token streams coming from lexers to improve or annotate the
10
- output. For example, you can highlight special words in comments, convert
11
- keywords to upper or lowercase to enforce a style guide etc.
12
-
13
- To apply a filter, you can use the `add_filter()` method of a lexer:
14
-
15
- .. sourcecode:: pycon
16
-
17
- >>> from pygments.lexers import PythonLexer
18
- >>> l = PythonLexer()
19
- >>> # add a filter given by a string and options
20
- >>> l.add_filter('codetagify', case='lower')
21
- >>> l.filters
22
- [<pygments.filters.CodeTagFilter object at 0xb785decc>]
23
- >>> from pygments.filters import KeywordCaseFilter
24
- >>> # or give an instance
25
- >>> l.add_filter(KeywordCaseFilter(case='lower'))
26
-
27
- The `add_filter()` method takes keyword arguments which are forwarded to
28
- the constructor of the filter.
29
-
30
- To get a list of all registered filters by name, you can use the
31
- `get_all_filters()` function from the `pygments.filters` module that returns an
32
- iterable for all known filters.
33
-
34
- If you want to write your own filter, have a look at :doc:`Write your own filter
35
- <filterdevelopment>`.
36
-
37
-
38
- Builtin Filters
39
- ===============
40
-
41
- .. pygmentsdoc:: filters