pygments.rb 1.2.1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (386) hide show
  1. checksums.yaml +5 -5
  2. data/.github/dependabot.yml +13 -0
  3. data/.github/workflows/ci.yml +40 -0
  4. data/.github/workflows/release.yml +24 -0
  5. data/.gitignore +4 -6
  6. data/.rubocop.yml +16 -0
  7. data/CHANGELOG.adoc +137 -0
  8. data/Gemfile +3 -1
  9. data/LICENSE +1 -1
  10. data/README.adoc +159 -0
  11. data/Rakefile +8 -32
  12. data/bench.rb +14 -8
  13. data/lib/pygments.rb +16 -14
  14. data/lib/pygments/lexer.rb +87 -65
  15. data/lib/pygments/mentos.py +23 -110
  16. data/lib/pygments/popen.rb +188 -284
  17. data/lib/pygments/version.rb +2 -2
  18. data/pygments.rb.gemspec +20 -13
  19. data/test/test_pygments.rb +50 -110
  20. data/vendor/pygments-main/{AUTHORS → Pygments-2.8.1.dist-info/AUTHORS} +26 -3
  21. data/vendor/pygments-main/Pygments-2.8.1.dist-info/INSTALLER +1 -0
  22. data/vendor/pygments-main/{LICENSE → Pygments-2.8.1.dist-info/LICENSE} +1 -1
  23. data/vendor/pygments-main/Pygments-2.8.1.dist-info/METADATA +48 -0
  24. data/vendor/pygments-main/Pygments-2.8.1.dist-info/RECORD +494 -0
  25. data/vendor/pygments-main/Pygments-2.8.1.dist-info/REQUESTED +0 -0
  26. data/vendor/pygments-main/Pygments-2.8.1.dist-info/WHEEL +5 -0
  27. data/vendor/pygments-main/Pygments-2.8.1.dist-info/entry_points.txt +3 -0
  28. data/vendor/pygments-main/Pygments-2.8.1.dist-info/top_level.txt +1 -0
  29. data/vendor/pygments-main/bin/pygmentize +8 -0
  30. data/vendor/pygments-main/pygments/__init__.py +6 -12
  31. data/vendor/pygments-main/pygments/__main__.py +17 -0
  32. data/vendor/pygments-main/pygments/cmdline.py +213 -184
  33. data/vendor/pygments-main/pygments/console.py +6 -10
  34. data/vendor/pygments-main/pygments/filter.py +4 -7
  35. data/vendor/pygments-main/pygments/filters/__init__.py +609 -22
  36. data/vendor/pygments-main/pygments/formatter.py +4 -5
  37. data/vendor/pygments-main/pygments/formatters/__init__.py +10 -10
  38. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -4
  39. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -2
  40. data/vendor/pygments-main/pygments/formatters/html.py +242 -139
  41. data/vendor/pygments-main/pygments/formatters/img.py +91 -50
  42. data/vendor/pygments-main/pygments/formatters/irc.py +39 -40
  43. data/vendor/pygments-main/pygments/formatters/latex.py +62 -33
  44. data/vendor/pygments-main/pygments/formatters/other.py +18 -17
  45. data/vendor/pygments-main/pygments/formatters/rtf.py +29 -30
  46. data/vendor/pygments-main/pygments/formatters/svg.py +40 -5
  47. data/vendor/pygments-main/pygments/formatters/terminal.py +25 -32
  48. data/vendor/pygments-main/pygments/formatters/terminal256.py +45 -14
  49. data/vendor/pygments-main/pygments/lexer.py +47 -44
  50. data/vendor/pygments-main/pygments/lexers/__init__.py +341 -0
  51. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1644 -0
  52. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +231 -0
  53. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +75 -0
  54. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1724 -0
  55. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +5326 -0
  56. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +292 -0
  57. data/vendor/pygments-main/pygments/lexers/_mapping.py +554 -0
  58. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1171 -0
  59. data/vendor/pygments-main/pygments/lexers/_mysql_builtins.py +1281 -0
  60. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +2600 -0
  61. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +4752 -0
  62. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +677 -0
  63. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +3093 -0
  64. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1160 -0
  65. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +557 -0
  66. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +457 -0
  67. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1003 -0
  68. data/vendor/pygments-main/pygments/lexers/_usd_builtins.py +112 -0
  69. data/vendor/pygments-main/pygments/lexers/_vbscript_builtins.py +279 -0
  70. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1938 -0
  71. data/vendor/pygments-main/pygments/lexers/actionscript.py +244 -0
  72. data/vendor/pygments-main/pygments/lexers/agile.py +23 -0
  73. data/vendor/pygments-main/pygments/lexers/algebra.py +239 -0
  74. data/vendor/pygments-main/pygments/lexers/ambient.py +75 -0
  75. data/vendor/pygments-main/pygments/lexers/amdgpu.py +48 -0
  76. data/vendor/pygments-main/pygments/lexers/ampl.py +86 -0
  77. data/vendor/pygments-main/pygments/lexers/apl.py +100 -0
  78. data/vendor/pygments-main/pygments/lexers/archetype.py +317 -0
  79. data/vendor/pygments-main/pygments/lexers/arrow.py +116 -0
  80. data/vendor/pygments-main/pygments/lexers/asm.py +1004 -0
  81. data/vendor/pygments-main/pygments/lexers/automation.py +379 -0
  82. data/vendor/pygments-main/pygments/lexers/bare.py +103 -0
  83. data/vendor/pygments-main/pygments/lexers/basic.py +661 -0
  84. data/vendor/pygments-main/pygments/lexers/bibtex.py +159 -0
  85. data/vendor/pygments-main/pygments/lexers/boa.py +101 -0
  86. data/vendor/pygments-main/pygments/lexers/business.py +626 -0
  87. data/vendor/pygments-main/pygments/lexers/c_cpp.py +342 -0
  88. data/vendor/pygments-main/pygments/lexers/c_like.py +565 -0
  89. data/vendor/pygments-main/pygments/lexers/capnproto.py +77 -0
  90. data/vendor/pygments-main/pygments/lexers/cddl.py +190 -0
  91. data/vendor/pygments-main/pygments/lexers/chapel.py +111 -0
  92. data/vendor/pygments-main/pygments/lexers/clean.py +178 -0
  93. data/vendor/pygments-main/pygments/lexers/compiled.py +33 -0
  94. data/vendor/pygments-main/pygments/lexers/configs.py +985 -0
  95. data/vendor/pygments-main/pygments/lexers/console.py +113 -0
  96. data/vendor/pygments-main/pygments/lexers/crystal.py +366 -0
  97. data/vendor/pygments-main/pygments/lexers/csound.py +466 -0
  98. data/vendor/pygments-main/pygments/lexers/css.py +694 -0
  99. data/vendor/pygments-main/pygments/lexers/d.py +255 -0
  100. data/vendor/pygments-main/pygments/lexers/dalvik.py +124 -0
  101. data/vendor/pygments-main/pygments/lexers/data.py +697 -0
  102. data/vendor/pygments-main/pygments/lexers/devicetree.py +108 -0
  103. data/vendor/pygments-main/pygments/lexers/diff.py +164 -0
  104. data/vendor/pygments-main/pygments/lexers/dotnet.py +706 -0
  105. data/vendor/pygments-main/pygments/lexers/dsls.py +959 -0
  106. data/vendor/pygments-main/pygments/lexers/dylan.py +286 -0
  107. data/vendor/pygments-main/pygments/lexers/ecl.py +137 -0
  108. data/vendor/pygments-main/pygments/lexers/eiffel.py +64 -0
  109. data/vendor/pygments-main/pygments/lexers/elm.py +120 -0
  110. data/vendor/pygments-main/pygments/lexers/email.py +150 -0
  111. data/vendor/pygments-main/pygments/lexers/erlang.py +529 -0
  112. data/vendor/pygments-main/pygments/lexers/esoteric.py +303 -0
  113. data/vendor/pygments-main/pygments/lexers/ezhil.py +76 -0
  114. data/vendor/pygments-main/pygments/lexers/factor.py +343 -0
  115. data/vendor/pygments-main/pygments/lexers/fantom.py +249 -0
  116. data/vendor/pygments-main/pygments/lexers/felix.py +272 -0
  117. data/vendor/pygments-main/pygments/lexers/floscript.py +82 -0
  118. data/vendor/pygments-main/pygments/lexers/forth.py +177 -0
  119. data/vendor/pygments-main/pygments/lexers/fortran.py +208 -0
  120. data/vendor/pygments-main/pygments/lexers/foxpro.py +427 -0
  121. data/vendor/pygments-main/pygments/lexers/freefem.py +897 -0
  122. data/vendor/pygments-main/pygments/lexers/functional.py +20 -0
  123. data/vendor/pygments-main/pygments/lexers/futhark.py +110 -0
  124. data/vendor/pygments-main/pygments/lexers/gdscript.py +345 -0
  125. data/vendor/pygments-main/pygments/lexers/go.py +100 -0
  126. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +269 -0
  127. data/vendor/pygments-main/pygments/lexers/graph.py +84 -0
  128. data/vendor/pygments-main/pygments/lexers/graphics.py +799 -0
  129. data/vendor/pygments-main/pygments/lexers/graphviz.py +57 -0
  130. data/vendor/pygments-main/pygments/lexers/haskell.py +869 -0
  131. data/vendor/pygments-main/pygments/lexers/haxe.py +935 -0
  132. data/vendor/pygments-main/pygments/lexers/hdl.py +468 -0
  133. data/vendor/pygments-main/pygments/lexers/hexdump.py +102 -0
  134. data/vendor/pygments-main/pygments/lexers/html.py +613 -0
  135. data/vendor/pygments-main/pygments/lexers/idl.py +280 -0
  136. data/vendor/pygments-main/pygments/lexers/igor.py +419 -0
  137. data/vendor/pygments-main/pygments/lexers/inferno.py +95 -0
  138. data/vendor/pygments-main/pygments/lexers/installers.py +321 -0
  139. data/vendor/pygments-main/pygments/lexers/int_fiction.py +1367 -0
  140. data/vendor/pygments-main/pygments/lexers/iolang.py +62 -0
  141. data/vendor/pygments-main/pygments/lexers/j.py +145 -0
  142. data/vendor/pygments-main/pygments/lexers/javascript.py +1536 -0
  143. data/vendor/pygments-main/pygments/lexers/julia.py +330 -0
  144. data/vendor/pygments-main/pygments/lexers/jvm.py +1739 -0
  145. data/vendor/pygments-main/pygments/lexers/lisp.py +2698 -0
  146. data/vendor/pygments-main/pygments/lexers/make.py +205 -0
  147. data/vendor/pygments-main/pygments/lexers/markup.py +762 -0
  148. data/vendor/pygments-main/pygments/lexers/math.py +20 -0
  149. data/vendor/pygments-main/pygments/lexers/matlab.py +3280 -0
  150. data/vendor/pygments-main/pygments/lexers/mime.py +225 -0
  151. data/vendor/pygments-main/pygments/lexers/ml.py +957 -0
  152. data/vendor/pygments-main/pygments/lexers/modeling.py +365 -0
  153. data/vendor/pygments-main/pygments/lexers/modula2.py +1579 -0
  154. data/vendor/pygments-main/pygments/lexers/monte.py +203 -0
  155. data/vendor/pygments-main/pygments/lexers/mosel.py +447 -0
  156. data/vendor/pygments-main/pygments/lexers/ncl.py +893 -0
  157. data/vendor/pygments-main/pygments/lexers/nimrod.py +158 -0
  158. data/vendor/pygments-main/pygments/lexers/nit.py +63 -0
  159. data/vendor/pygments-main/pygments/lexers/nix.py +135 -0
  160. data/vendor/pygments-main/pygments/lexers/oberon.py +120 -0
  161. data/vendor/pygments-main/pygments/lexers/objective.py +503 -0
  162. data/vendor/pygments-main/pygments/lexers/ooc.py +84 -0
  163. data/vendor/pygments-main/pygments/lexers/other.py +40 -0
  164. data/vendor/pygments-main/pygments/lexers/parasail.py +78 -0
  165. data/vendor/pygments-main/pygments/lexers/parsers.py +799 -0
  166. data/vendor/pygments-main/pygments/lexers/pascal.py +643 -0
  167. data/vendor/pygments-main/pygments/lexers/pawn.py +202 -0
  168. data/vendor/pygments-main/pygments/lexers/perl.py +731 -0
  169. data/vendor/pygments-main/pygments/lexers/php.py +320 -0
  170. data/vendor/pygments-main/pygments/lexers/pointless.py +70 -0
  171. data/vendor/pygments-main/pygments/lexers/pony.py +93 -0
  172. data/vendor/pygments-main/pygments/lexers/praat.py +301 -0
  173. data/vendor/pygments-main/pygments/lexers/prolog.py +305 -0
  174. data/vendor/pygments-main/pygments/lexers/promql.py +182 -0
  175. data/vendor/pygments-main/pygments/lexers/python.py +1158 -0
  176. data/vendor/pygments-main/pygments/lexers/qvt.py +151 -0
  177. data/vendor/pygments-main/pygments/lexers/r.py +190 -0
  178. data/vendor/pygments-main/pygments/lexers/rdf.py +462 -0
  179. data/vendor/pygments-main/pygments/lexers/rebol.py +430 -0
  180. data/vendor/pygments-main/pygments/lexers/resource.py +84 -0
  181. data/vendor/pygments-main/pygments/lexers/ride.py +138 -0
  182. data/vendor/pygments-main/pygments/lexers/rnc.py +66 -0
  183. data/vendor/pygments-main/pygments/lexers/roboconf.py +81 -0
  184. data/vendor/pygments-main/pygments/lexers/robotframework.py +551 -0
  185. data/vendor/pygments-main/pygments/lexers/ruby.py +523 -0
  186. data/vendor/pygments-main/pygments/lexers/rust.py +223 -0
  187. data/vendor/pygments-main/pygments/lexers/sas.py +227 -0
  188. data/vendor/pygments-main/pygments/lexers/scdoc.py +82 -0
  189. data/vendor/pygments-main/pygments/lexers/scripting.py +1283 -0
  190. data/vendor/pygments-main/pygments/lexers/sgf.py +60 -0
  191. data/vendor/pygments-main/pygments/lexers/shell.py +909 -0
  192. data/vendor/pygments-main/pygments/lexers/sieve.py +68 -0
  193. data/vendor/pygments-main/pygments/lexers/slash.py +184 -0
  194. data/vendor/pygments-main/pygments/lexers/smalltalk.py +194 -0
  195. data/vendor/pygments-main/pygments/lexers/smv.py +78 -0
  196. data/vendor/pygments-main/pygments/lexers/snobol.py +82 -0
  197. data/vendor/pygments-main/pygments/lexers/solidity.py +91 -0
  198. data/vendor/pygments-main/pygments/lexers/special.py +106 -0
  199. data/vendor/pygments-main/pygments/lexers/sql.py +832 -0
  200. data/vendor/pygments-main/pygments/lexers/stata.py +170 -0
  201. data/vendor/pygments-main/pygments/lexers/supercollider.py +94 -0
  202. data/vendor/pygments-main/pygments/lexers/tcl.py +144 -0
  203. data/vendor/pygments-main/pygments/lexers/templates.py +2263 -0
  204. data/vendor/pygments-main/pygments/lexers/teraterm.py +334 -0
  205. data/vendor/pygments-main/pygments/lexers/testing.py +206 -0
  206. data/vendor/pygments-main/pygments/lexers/text.py +25 -0
  207. data/vendor/pygments-main/pygments/lexers/textedit.py +168 -0
  208. data/vendor/pygments-main/pygments/lexers/textfmts.py +429 -0
  209. data/vendor/pygments-main/pygments/lexers/theorem.py +476 -0
  210. data/vendor/pygments-main/pygments/lexers/tnt.py +262 -0
  211. data/vendor/pygments-main/pygments/lexers/trafficscript.py +53 -0
  212. data/vendor/pygments-main/pygments/lexers/typoscript.py +218 -0
  213. data/vendor/pygments-main/pygments/lexers/unicon.py +411 -0
  214. data/vendor/pygments-main/pygments/lexers/urbi.py +145 -0
  215. data/vendor/pygments-main/pygments/lexers/usd.py +89 -0
  216. data/vendor/pygments-main/pygments/lexers/varnish.py +189 -0
  217. data/vendor/pygments-main/pygments/lexers/verification.py +113 -0
  218. data/vendor/pygments-main/pygments/lexers/web.py +23 -0
  219. data/vendor/pygments-main/pygments/lexers/webidl.py +298 -0
  220. data/vendor/pygments-main/pygments/lexers/webmisc.py +991 -0
  221. data/vendor/pygments-main/pygments/lexers/whiley.py +115 -0
  222. data/vendor/pygments-main/pygments/lexers/x10.py +68 -0
  223. data/vendor/pygments-main/pygments/lexers/xorg.py +36 -0
  224. data/vendor/pygments-main/pygments/lexers/yang.py +103 -0
  225. data/vendor/pygments-main/pygments/lexers/zig.py +123 -0
  226. data/vendor/pygments-main/pygments/modeline.py +1 -2
  227. data/vendor/pygments-main/pygments/plugin.py +4 -3
  228. data/vendor/pygments-main/pygments/regexopt.py +1 -2
  229. data/vendor/pygments-main/pygments/scanner.py +2 -3
  230. data/vendor/pygments-main/pygments/sphinxext.py +2 -5
  231. data/vendor/pygments-main/pygments/style.py +61 -25
  232. data/vendor/pygments-main/pygments/styles/__init__.py +12 -5
  233. data/vendor/pygments-main/pygments/styles/abap.py +1 -2
  234. data/vendor/pygments-main/pygments/styles/algol.py +1 -2
  235. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -2
  236. data/vendor/pygments-main/pygments/styles/arduino.py +2 -3
  237. data/vendor/pygments-main/pygments/styles/autumn.py +1 -2
  238. data/vendor/pygments-main/pygments/styles/borland.py +1 -2
  239. data/vendor/pygments-main/pygments/styles/bw.py +1 -2
  240. data/vendor/pygments-main/pygments/styles/colorful.py +1 -2
  241. data/vendor/pygments-main/pygments/styles/default.py +1 -2
  242. data/vendor/pygments-main/pygments/styles/emacs.py +1 -2
  243. data/vendor/pygments-main/pygments/styles/friendly.py +1 -2
  244. data/vendor/pygments-main/pygments/styles/fruity.py +1 -2
  245. data/vendor/pygments-main/pygments/styles/igor.py +1 -2
  246. data/vendor/pygments-main/pygments/styles/inkpot.py +66 -0
  247. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -2
  248. data/vendor/pygments-main/pygments/styles/manni.py +1 -2
  249. data/vendor/pygments-main/pygments/styles/material.py +118 -0
  250. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  251. data/vendor/pygments-main/pygments/styles/murphy.py +1 -2
  252. data/vendor/pygments-main/pygments/styles/native.py +1 -2
  253. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -2
  254. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -2
  255. data/vendor/pygments-main/pygments/styles/pastie.py +1 -2
  256. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -2
  257. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +1 -2
  258. data/vendor/pygments-main/pygments/styles/rrt.py +1 -2
  259. data/vendor/pygments-main/pygments/styles/sas.py +1 -2
  260. data/vendor/pygments-main/pygments/styles/solarized.py +136 -0
  261. data/vendor/pygments-main/pygments/styles/stata_dark.py +40 -0
  262. data/vendor/pygments-main/pygments/styles/{stata.py → stata_light.py} +14 -16
  263. data/vendor/pygments-main/pygments/styles/tango.py +1 -2
  264. data/vendor/pygments-main/pygments/styles/trac.py +1 -2
  265. data/vendor/pygments-main/pygments/styles/vim.py +1 -2
  266. data/vendor/pygments-main/pygments/styles/vs.py +1 -2
  267. data/vendor/pygments-main/pygments/styles/xcode.py +1 -2
  268. data/vendor/pygments-main/pygments/styles/zenburn.py +80 -0
  269. data/vendor/pygments-main/pygments/token.py +1 -2
  270. data/vendor/pygments-main/pygments/unistring.py +47 -109
  271. data/vendor/pygments-main/pygments/util.py +16 -96
  272. metadata +81 -139
  273. data/CHANGELOG.md +0 -111
  274. data/README.md +0 -121
  275. data/cache-lexers.rb +0 -8
  276. data/circle.yml +0 -20
  277. data/test/test_data.c +0 -2581
  278. data/test/test_data.py +0 -514
  279. data/test/test_data_generated +0 -2582
  280. data/vendor/custom_lexers/github.py +0 -565
  281. data/vendor/pygments-main/CHANGES +0 -1186
  282. data/vendor/pygments-main/MANIFEST.in +0 -6
  283. data/vendor/pygments-main/Makefile +0 -65
  284. data/vendor/pygments-main/README.rst +0 -39
  285. data/vendor/pygments-main/REVISION +0 -1
  286. data/vendor/pygments-main/TODO +0 -12
  287. data/vendor/pygments-main/doc/Makefile +0 -153
  288. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  289. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  290. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  291. data/vendor/pygments-main/doc/_templates/docssidebar.html +0 -3
  292. data/vendor/pygments-main/doc/_templates/indexsidebar.html +0 -25
  293. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +0 -98
  294. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  295. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  296. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  297. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  298. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  299. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +0 -401
  300. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +0 -15
  301. data/vendor/pygments-main/doc/conf.py +0 -241
  302. data/vendor/pygments-main/doc/docs/api.rst +0 -354
  303. data/vendor/pygments-main/doc/docs/authors.rst +0 -4
  304. data/vendor/pygments-main/doc/docs/changelog.rst +0 -1
  305. data/vendor/pygments-main/doc/docs/cmdline.rst +0 -166
  306. data/vendor/pygments-main/doc/docs/filterdevelopment.rst +0 -71
  307. data/vendor/pygments-main/doc/docs/filters.rst +0 -41
  308. data/vendor/pygments-main/doc/docs/formatterdevelopment.rst +0 -169
  309. data/vendor/pygments-main/doc/docs/formatters.rst +0 -48
  310. data/vendor/pygments-main/doc/docs/index.rst +0 -66
  311. data/vendor/pygments-main/doc/docs/integrate.rst +0 -40
  312. data/vendor/pygments-main/doc/docs/java.rst +0 -70
  313. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +0 -728
  314. data/vendor/pygments-main/doc/docs/lexers.rst +0 -69
  315. data/vendor/pygments-main/doc/docs/moinmoin.rst +0 -39
  316. data/vendor/pygments-main/doc/docs/plugins.rst +0 -93
  317. data/vendor/pygments-main/doc/docs/quickstart.rst +0 -205
  318. data/vendor/pygments-main/doc/docs/rstdirective.rst +0 -22
  319. data/vendor/pygments-main/doc/docs/styles.rst +0 -201
  320. data/vendor/pygments-main/doc/docs/tokens.rst +0 -372
  321. data/vendor/pygments-main/doc/docs/unicode.rst +0 -58
  322. data/vendor/pygments-main/doc/download.rst +0 -41
  323. data/vendor/pygments-main/doc/faq.rst +0 -139
  324. data/vendor/pygments-main/doc/index.rst +0 -54
  325. data/vendor/pygments-main/doc/languages.rst +0 -154
  326. data/vendor/pygments-main/doc/make.bat +0 -190
  327. data/vendor/pygments-main/doc/pygmentize.1 +0 -94
  328. data/vendor/pygments-main/external/autopygmentize +0 -101
  329. data/vendor/pygments-main/external/lasso-builtins-generator-9.lasso +0 -162
  330. data/vendor/pygments-main/external/markdown-processor.py +0 -67
  331. data/vendor/pygments-main/external/moin-parser.py +0 -112
  332. data/vendor/pygments-main/external/pygments.bashcomp +0 -38
  333. data/vendor/pygments-main/external/rst-directive.py +0 -82
  334. data/vendor/pygments-main/pygmentize +0 -8
  335. data/vendor/pygments-main/requirements.txt +0 -5
  336. data/vendor/pygments-main/scripts/check_sources.py +0 -211
  337. data/vendor/pygments-main/scripts/debug_lexer.py +0 -246
  338. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +0 -33
  339. data/vendor/pygments-main/scripts/epydoc.css +0 -280
  340. data/vendor/pygments-main/scripts/get_vimkw.py +0 -74
  341. data/vendor/pygments-main/scripts/pylintrc +0 -301
  342. data/vendor/pygments-main/scripts/vim2pygments.py +0 -935
  343. data/vendor/pygments-main/setup.cfg +0 -10
  344. data/vendor/pygments-main/setup.py +0 -77
  345. data/vendor/pygments-main/tox.ini +0 -7
  346. data/vendor/simplejson/.gitignore +0 -10
  347. data/vendor/simplejson/.travis.yml +0 -5
  348. data/vendor/simplejson/CHANGES.txt +0 -291
  349. data/vendor/simplejson/LICENSE.txt +0 -19
  350. data/vendor/simplejson/MANIFEST.in +0 -5
  351. data/vendor/simplejson/README.rst +0 -19
  352. data/vendor/simplejson/conf.py +0 -179
  353. data/vendor/simplejson/index.rst +0 -628
  354. data/vendor/simplejson/scripts/make_docs.py +0 -18
  355. data/vendor/simplejson/setup.py +0 -104
  356. data/vendor/simplejson/simplejson/__init__.py +0 -510
  357. data/vendor/simplejson/simplejson/_speedups.c +0 -2745
  358. data/vendor/simplejson/simplejson/decoder.py +0 -425
  359. data/vendor/simplejson/simplejson/encoder.py +0 -567
  360. data/vendor/simplejson/simplejson/ordered_dict.py +0 -119
  361. data/vendor/simplejson/simplejson/scanner.py +0 -77
  362. data/vendor/simplejson/simplejson/tests/__init__.py +0 -67
  363. data/vendor/simplejson/simplejson/tests/test_bigint_as_string.py +0 -55
  364. data/vendor/simplejson/simplejson/tests/test_check_circular.py +0 -30
  365. data/vendor/simplejson/simplejson/tests/test_decimal.py +0 -66
  366. data/vendor/simplejson/simplejson/tests/test_decode.py +0 -83
  367. data/vendor/simplejson/simplejson/tests/test_default.py +0 -9
  368. data/vendor/simplejson/simplejson/tests/test_dump.py +0 -67
  369. data/vendor/simplejson/simplejson/tests/test_encode_basestring_ascii.py +0 -46
  370. data/vendor/simplejson/simplejson/tests/test_encode_for_html.py +0 -32
  371. data/vendor/simplejson/simplejson/tests/test_errors.py +0 -34
  372. data/vendor/simplejson/simplejson/tests/test_fail.py +0 -91
  373. data/vendor/simplejson/simplejson/tests/test_float.py +0 -19
  374. data/vendor/simplejson/simplejson/tests/test_indent.py +0 -86
  375. data/vendor/simplejson/simplejson/tests/test_item_sort_key.py +0 -20
  376. data/vendor/simplejson/simplejson/tests/test_namedtuple.py +0 -121
  377. data/vendor/simplejson/simplejson/tests/test_pass1.py +0 -76
  378. data/vendor/simplejson/simplejson/tests/test_pass2.py +0 -14
  379. data/vendor/simplejson/simplejson/tests/test_pass3.py +0 -20
  380. data/vendor/simplejson/simplejson/tests/test_recursion.py +0 -67
  381. data/vendor/simplejson/simplejson/tests/test_scanstring.py +0 -117
  382. data/vendor/simplejson/simplejson/tests/test_separators.py +0 -42
  383. data/vendor/simplejson/simplejson/tests/test_speedups.py +0 -20
  384. data/vendor/simplejson/simplejson/tests/test_tuple.py +0 -49
  385. data/vendor/simplejson/simplejson/tests/test_unicode.py +0 -109
  386. data/vendor/simplejson/simplejson/tool.py +0 -39
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.35.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pygmentize = pygments.cmdline:main
3
+
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/python3.8
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from pygments.cmdline import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  """
3
2
  Pygments
4
3
  ~~~~~~~~
@@ -17,19 +16,18 @@
17
16
  * it is usable as a command-line tool and as a library
18
17
  * ... and it highlights even Brainfuck!
19
18
 
20
- The `Pygments tip`_ is installable with ``easy_install Pygments==dev``.
19
+ The `Pygments master branch`_ is installable with ``easy_install Pygments==dev``.
21
20
 
22
- .. _Pygments tip:
23
- http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev
21
+ .. _Pygments master branch:
22
+ https://github.com/pygments/pygments/archive/master.zip#egg=Pygments-dev
24
23
 
25
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
24
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
26
25
  :license: BSD, see LICENSE for details.
27
26
  """
28
27
  import sys
28
+ from io import StringIO, BytesIO
29
29
 
30
- from pygments.util import StringIO, BytesIO
31
-
32
- __version__ = '2.2.0'
30
+ __version__ = '2.8.1'
33
31
  __docformat__ = 'restructuredtext'
34
32
 
35
33
  __all__ = ['lex', 'format', 'highlight']
@@ -84,7 +82,3 @@ def highlight(code, lexer, formatter, outfile=None):
84
82
  """
85
83
  return format(lex(code, lexer), formatter, outfile)
86
84
 
87
-
88
- if __name__ == '__main__': # pragma: no cover
89
- from pygments.cmdline import main
90
- sys.exit(main(sys.argv))
@@ -0,0 +1,17 @@
1
+ """
2
+ pygments.__main__
3
+ ~~~~~~~~~~~~~~~~~
4
+
5
+ Main entry point for ``python -m pygments``.
6
+
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+ import sys
12
+ import pygments.cmdline
13
+
14
+ try:
15
+ sys.exit(pygments.cmdline.main(sys.argv))
16
+ except KeyboardInterrupt:
17
+ sys.exit(1)
@@ -1,24 +1,23 @@
1
- # -*- coding: utf-8 -*-
2
1
  """
3
2
  pygments.cmdline
4
3
  ~~~~~~~~~~~~~~~~
5
4
 
6
5
  Command line interface.
7
6
 
8
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
7
+ :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
9
8
  :license: BSD, see LICENSE for details.
10
9
  """
11
10
 
12
- from __future__ import print_function
13
-
14
11
  import os
15
12
  import sys
16
- import getopt
13
+ import shutil
14
+ import argparse
17
15
  from textwrap import dedent
18
16
 
19
17
  from pygments import __version__, highlight
20
18
  from pygments.util import ClassNotFound, OptionError, docstring_headline, \
21
- guess_decode, guess_decode_from_terminal, terminal_encoding
19
+ guess_decode, guess_decode_from_terminal, terminal_encoding, \
20
+ UnclosingTextIOWrapper
22
21
  from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
23
22
  load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
24
23
  from pygments.lexers.special import TextLexer
@@ -31,84 +30,6 @@ from pygments.filters import get_all_filters, find_filter_class
31
30
  from pygments.styles import get_all_styles, get_style_by_name
32
31
 
33
32
 
34
- USAGE = """\
35
- Usage: %s [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]
36
- [-O <options>] [-P <option=value>] [-s] [-v] [-x] [-o <outfile>] [<infile>]
37
-
38
- %s -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]
39
- %s -L [<which> ...]
40
- %s -N <filename>
41
- %s -H <type> <name>
42
- %s -h | -V
43
-
44
- Highlight the input file and write the result to <outfile>.
45
-
46
- If no input file is given, use stdin, if -o is not given, use stdout.
47
-
48
- If -s is passed, lexing will be done in "streaming" mode, reading and
49
- highlighting one line at a time. This will only work properly with
50
- lexers that have no constructs spanning multiple lines!
51
-
52
- <lexer> is a lexer name (query all lexer names with -L). If -l is not
53
- given, the lexer is guessed from the extension of the input file name
54
- (this obviously doesn't work if the input is stdin). If -g is passed,
55
- attempt to guess the lexer from the file contents, or pass through as
56
- plain text if this fails (this can work for stdin).
57
-
58
- Likewise, <formatter> is a formatter name, and will be guessed from
59
- the extension of the output file name. If no output file is given,
60
- the terminal formatter will be used by default.
61
-
62
- The additional option -x allows custom lexers and formatters to be
63
- loaded from a .py file relative to the current working directory. For
64
- example, ``-l ./customlexer.py -x``. By default, this option expects a
65
- file with a class named CustomLexer or CustomFormatter; you can also
66
- specify your own class name with a colon (``-l ./lexer.py:MyLexer``).
67
- Users should be very careful not to use this option with untrusted files,
68
- because it will import and run them.
69
-
70
- With the -O option, you can give the lexer and formatter a comma-
71
- separated list of options, e.g. ``-O bg=light,python=cool``.
72
-
73
- The -P option adds lexer and formatter options like the -O option, but
74
- you can only give one option per -P. That way, the option value may
75
- contain commas and equals signs, which it can't with -O, e.g.
76
- ``-P "heading=Pygments, the Python highlighter".
77
-
78
- With the -F option, you can add filters to the token stream, you can
79
- give options in the same way as for -O after a colon (note: there must
80
- not be spaces around the colon).
81
-
82
- The -O, -P and -F options can be given multiple times.
83
-
84
- With the -S option, print out style definitions for style <style>
85
- for formatter <formatter>. The argument given by -a is formatter
86
- dependent.
87
-
88
- The -L option lists lexers, formatters, styles or filters -- set
89
- `which` to the thing you want to list (e.g. "styles"), or omit it to
90
- list everything.
91
-
92
- The -N option guesses and prints out a lexer name based solely on
93
- the given filename. It does not take input or highlight anything.
94
- If no specific lexer can be determined "text" is returned.
95
-
96
- The -H option prints detailed help for the object <name> of type <type>,
97
- where <type> is one of "lexer", "formatter" or "filter".
98
-
99
- The -s option processes lines one at a time until EOF, rather than
100
- waiting to process the entire file. This only works for stdin, and
101
- is intended for streaming input such as you get from 'tail -f'.
102
- Example usage: "tail -f sql.log | pygmentize -s -l sql"
103
-
104
- The -v option prints a detailed traceback on unhandled exceptions,
105
- which is useful for debugging and bug reports.
106
-
107
- The -h option prints this help.
108
- The -V option prints the package version.
109
- """
110
-
111
-
112
33
  def _parse_options(o_strs):
113
34
  opts = {}
114
35
  if not o_strs:
@@ -214,95 +135,94 @@ def _print_list(what):
214
135
  print(" %s" % docstring_headline(cls))
215
136
 
216
137
 
217
- def main_inner(popts, args, usage):
218
- opts = {}
219
- O_opts = []
220
- P_opts = []
221
- F_opts = []
222
- for opt, arg in popts:
223
- if opt == '-O':
224
- O_opts.append(arg)
225
- elif opt == '-P':
226
- P_opts.append(arg)
227
- elif opt == '-F':
228
- F_opts.append(arg)
229
- opts[opt] = arg
230
-
231
- if opts.pop('-h', None) is not None:
232
- print(usage)
138
+ def main_inner(parser, argns):
139
+ if argns.help:
140
+ parser.print_help()
233
141
  return 0
234
142
 
235
- if opts.pop('-V', None) is not None:
236
- print('Pygments version %s, (c) 2006-2017 by Georg Brandl.' % __version__)
143
+ if argns.V:
144
+ print('Pygments version %s, (c) 2006-2021 by Georg Brandl, Matthäus '
145
+ 'Chajdas and contributors.' % __version__)
237
146
  return 0
238
147
 
148
+ def is_only_option(opt):
149
+ return not any(v for (k, v) in vars(argns).items() if k != opt)
150
+
239
151
  # handle ``pygmentize -L``
240
- L_opt = opts.pop('-L', None)
241
- if L_opt is not None:
242
- if opts:
243
- print(usage, file=sys.stderr)
152
+ if argns.L is not None:
153
+ if not is_only_option('L'):
154
+ parser.print_help(sys.stderr)
244
155
  return 2
245
-
246
156
  # print version
247
157
  main(['', '-V'])
248
- if not args:
249
- args = ['lexer', 'formatter', 'filter', 'style']
250
- for arg in args:
251
- _print_list(arg.rstrip('s'))
158
+ allowed_types = {'lexer', 'formatter', 'filter', 'style'}
159
+ largs = [arg.rstrip('s') for arg in argns.L]
160
+ if any(arg not in allowed_types for arg in largs):
161
+ parser.print_help(sys.stderr)
162
+ return 0
163
+ if not largs:
164
+ largs = allowed_types
165
+ for arg in largs:
166
+ _print_list(arg)
252
167
  return 0
253
168
 
254
169
  # handle ``pygmentize -H``
255
- H_opt = opts.pop('-H', None)
256
- if H_opt is not None:
257
- if opts or len(args) != 2:
258
- print(usage, file=sys.stderr)
170
+ if argns.H:
171
+ if not is_only_option('H'):
172
+ parser.print_help(sys.stderr)
259
173
  return 2
260
-
261
- what, name = args # pylint: disable=unbalanced-tuple-unpacking
174
+ what, name = argns.H
262
175
  if what not in ('lexer', 'formatter', 'filter'):
263
- print(usage, file=sys.stderr)
176
+ parser.print_help(sys.stderr)
264
177
  return 2
265
-
266
178
  return _print_help(what, name)
267
179
 
268
180
  # parse -O options
269
- parsed_opts = _parse_options(O_opts)
270
- opts.pop('-O', None)
181
+ parsed_opts = _parse_options(argns.O or [])
271
182
 
272
183
  # parse -P options
273
- for p_opt in P_opts:
184
+ for p_opt in argns.P or []:
274
185
  try:
275
186
  name, value = p_opt.split('=', 1)
276
187
  except ValueError:
277
188
  parsed_opts[p_opt] = True
278
189
  else:
279
190
  parsed_opts[name] = value
280
- opts.pop('-P', None)
281
191
 
282
192
  # encodings
283
193
  inencoding = parsed_opts.get('inencoding', parsed_opts.get('encoding'))
284
194
  outencoding = parsed_opts.get('outencoding', parsed_opts.get('encoding'))
285
195
 
286
196
  # handle ``pygmentize -N``
287
- infn = opts.pop('-N', None)
288
- if infn is not None:
289
- lexer = find_lexer_class_for_filename(infn)
197
+ if argns.N:
198
+ lexer = find_lexer_class_for_filename(argns.N)
290
199
  if lexer is None:
291
200
  lexer = TextLexer
292
201
 
293
202
  print(lexer.aliases[0])
294
203
  return 0
295
204
 
205
+ # handle ``pygmentize -C``
206
+ if argns.C:
207
+ inp = sys.stdin.buffer.read()
208
+ try:
209
+ lexer = guess_lexer(inp, inencoding=inencoding)
210
+ except ClassNotFound:
211
+ lexer = TextLexer
212
+
213
+ print(lexer.aliases[0])
214
+ return 0
215
+
296
216
  # handle ``pygmentize -S``
297
- S_opt = opts.pop('-S', None)
298
- a_opt = opts.pop('-a', None)
217
+ S_opt = argns.S
218
+ a_opt = argns.a
299
219
  if S_opt is not None:
300
- f_opt = opts.pop('-f', None)
220
+ f_opt = argns.f
301
221
  if not f_opt:
302
- print(usage, file=sys.stderr)
222
+ parser.print_help(sys.stderr)
303
223
  return 2
304
- if opts or args:
305
- print(usage, file=sys.stderr)
224
+ if argns.l or argns.INPUTFILE:
225
+ parser.print_help(sys.stderr)
306
226
  return 2
307
227
 
308
228
  try:
@@ -316,30 +236,36 @@ def main_inner(popts, args, usage):
316
236
  return 0
317
237
 
318
238
  # if no -S is given, -a is not allowed
319
- if a_opt is not None:
320
- print(usage, file=sys.stderr)
239
+ if argns.a is not None:
240
+ parser.print_help(sys.stderr)
321
241
  return 2
322
242
 
323
243
  # parse -F options
324
- F_opts = _parse_filters(F_opts)
325
- opts.pop('-F', None)
244
+ F_opts = _parse_filters(argns.F or [])
326
245
 
327
- allow_custom_lexer_formatter = False
328
246
  # -x: allow custom (eXternal) lexers and formatters
329
- if opts.pop('-x', None) is not None:
330
- allow_custom_lexer_formatter = True
247
+ allow_custom_lexer_formatter = bool(argns.x)
331
248
 
332
249
  # select lexer
333
250
  lexer = None
334
251
 
335
252
  # given by name?
336
- lexername = opts.pop('-l', None)
253
+ lexername = argns.l
337
254
  if lexername:
338
255
  # custom lexer, located relative to user's cwd
339
256
  if allow_custom_lexer_formatter and '.py' in lexername:
340
257
  try:
258
+ filename = None
259
+ name = None
341
260
  if ':' in lexername:
342
261
  filename, name = lexername.rsplit(':', 1)
262
+
263
+ if '.py' in name:
264
+ # This can happen on Windows: If the lexername is
265
+ # C:\lexer.py -- return to normal load path in that case
266
+ name = None
267
+
268
+ if filename and name:
343
269
  lexer = load_lexer_from_file(filename, name,
344
270
  **parsed_opts)
345
271
  else:
@@ -357,17 +283,13 @@ def main_inner(popts, args, usage):
357
283
  # read input code
358
284
  code = None
359
285
 
360
- if args:
361
- if len(args) > 1:
362
- print(usage, file=sys.stderr)
363
- return 2
364
-
365
- if '-s' in opts:
286
+ if argns.INPUTFILE:
287
+ if argns.s:
366
288
  print('Error: -s option not usable when input file specified',
367
289
  file=sys.stderr)
368
290
  return 2
369
291
 
370
- infn = args[0]
292
+ infn = argns.INPUTFILE
371
293
  try:
372
294
  with open(infn, 'rb') as infp:
373
295
  code = infp.read()
@@ -382,7 +304,7 @@ def main_inner(popts, args, usage):
382
304
  try:
383
305
  lexer = get_lexer_for_filename(infn, code, **parsed_opts)
384
306
  except ClassNotFound as err:
385
- if '-g' in opts:
307
+ if argns.g:
386
308
  try:
387
309
  lexer = guess_lexer(code, **parsed_opts)
388
310
  except ClassNotFound:
@@ -394,14 +316,10 @@ def main_inner(popts, args, usage):
394
316
  print('Error:', err, file=sys.stderr)
395
317
  return 1
396
318
 
397
- elif '-s' not in opts: # treat stdin as full file (-s support is later)
319
+ elif not argns.s: # treat stdin as full file (-s support is later)
398
320
  # read code from terminal, always in binary mode since we want to
399
321
  # decode ourselves and be tolerant with it
400
- if sys.version_info > (3,):
401
- # Python 3: we have to use .buffer to get a binary stream
402
- code = sys.stdin.buffer.read()
403
- else:
404
- code = sys.stdin.read()
322
+ code = sys.stdin.buffer.read() # use .buffer to get a binary stream
405
323
  if not inencoding:
406
324
  code, inencoding = guess_decode_from_terminal(code, sys.stdin)
407
325
  # else the lexer will do the decoding
@@ -426,15 +344,23 @@ def main_inner(popts, args, usage):
426
344
  return 1
427
345
 
428
346
  # select formatter
429
- outfn = opts.pop('-o', None)
430
- fmter = opts.pop('-f', None)
347
+ outfn = argns.o
348
+ fmter = argns.f
431
349
  if fmter:
432
350
  # custom formatter, located relative to user's cwd
433
351
  if allow_custom_lexer_formatter and '.py' in fmter:
434
352
  try:
353
+ filename = None
354
+ name = None
435
355
  if ':' in fmter:
436
- file, fmtername = fmter.rsplit(':', 1)
437
- fmter = load_formatter_from_file(file, fmtername,
356
+ # Same logic as above for custom lexer
357
+ filename, name = fmter.rsplit(':', 1)
358
+
359
+ if '.py' in name:
360
+ name = None
361
+
362
+ if filename and name:
363
+ fmter = load_formatter_from_file(filename, name,
438
364
  **parsed_opts)
439
365
  else:
440
366
  fmter = load_formatter_from_file(fmter, **parsed_opts)
@@ -466,11 +392,7 @@ def main_inner(popts, args, usage):
466
392
  fmter = Terminal256Formatter(**parsed_opts)
467
393
  else:
468
394
  fmter = TerminalFormatter(**parsed_opts)
469
- if sys.version_info > (3,):
470
- # Python 3: we have to use .buffer to get a binary stream
471
- outfile = sys.stdout.buffer
472
- else:
473
- outfile = sys.stdout
395
+ outfile = sys.stdout.buffer
474
396
 
475
397
  # determine output encoding if not explicitly selected
476
398
  if not outencoding:
@@ -485,10 +407,8 @@ def main_inner(popts, args, usage):
485
407
  if not outfn and sys.platform in ('win32', 'cygwin') and \
486
408
  fmter.name in ('Terminal', 'Terminal256'): # pragma: no cover
487
409
  # unfortunately colorama doesn't support binary streams on Py3
488
- if sys.version_info > (3,):
489
- from pygments.util import UnclosingTextIOWrapper
490
- outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
491
- fmter.encoding = None
410
+ outfile = UnclosingTextIOWrapper(outfile, encoding=fmter.encoding)
411
+ fmter.encoding = None
492
412
  try:
493
413
  import colorama.initialise
494
414
  except ImportError:
@@ -507,19 +427,19 @@ def main_inner(popts, args, usage):
507
427
  lexer = LatexEmbeddedLexer(left, right, lexer)
508
428
 
509
429
  # ... and do it!
510
- if '-s' not in opts:
430
+ if not argns.s:
511
431
  # process whole input as per normal...
512
- highlight(code, lexer, fmter, outfile)
432
+ try:
433
+ highlight(code, lexer, fmter, outfile)
434
+ finally:
435
+ if outfn:
436
+ outfile.close()
513
437
  return 0
514
438
  else:
515
439
  # line by line processing of stdin (eg: for 'tail -f')...
516
440
  try:
517
441
  while 1:
518
- if sys.version_info > (3,):
519
- # Python 3: we have to use .buffer to get a binary stream
520
- line = sys.stdin.buffer.readline()
521
- else:
522
- line = sys.stdin.readline()
442
+ line = sys.stdin.buffer.readline()
523
443
  if not line:
524
444
  break
525
445
  if not inencoding:
@@ -530,31 +450,140 @@ def main_inner(popts, args, usage):
530
450
  return 0
531
451
  except KeyboardInterrupt: # pragma: no cover
532
452
  return 0
453
+ finally:
454
+ if outfn:
455
+ outfile.close()
456
+
457
+
458
+ class HelpFormatter(argparse.HelpFormatter):
459
+ def __init__(self, prog, indent_increment=2, max_help_position=16, width=None):
460
+ if width is None:
461
+ try:
462
+ width = shutil.get_terminal_size().columns - 2
463
+ except Exception:
464
+ pass
465
+ argparse.HelpFormatter.__init__(self, prog, indent_increment,
466
+ max_help_position, width)
533
467
 
534
468
 
535
469
  def main(args=sys.argv):
536
470
  """
537
471
  Main command line entry point.
538
472
  """
539
- usage = USAGE % ((args[0],) * 6)
540
-
541
- try:
542
- popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:vhVHgsx")
543
- except getopt.GetoptError:
544
- print(usage, file=sys.stderr)
545
- return 2
473
+ desc = "Highlight an input file and write the result to an output file."
474
+ parser = argparse.ArgumentParser(description=desc, add_help=False,
475
+ formatter_class=HelpFormatter)
476
+
477
+ operation = parser.add_argument_group('Main operation')
478
+ lexersel = operation.add_mutually_exclusive_group()
479
+ lexersel.add_argument(
480
+ '-l', metavar='LEXER',
481
+ help='Specify the lexer to use. (Query names with -L.) If not '
482
+ 'given and -g is not present, the lexer is guessed from the filename.')
483
+ lexersel.add_argument(
484
+ '-g', action='store_true',
485
+ help='Guess the lexer from the file contents, or pass through '
486
+ 'as plain text if nothing can be guessed.')
487
+ operation.add_argument(
488
+ '-F', metavar='FILTER[:options]', action='append',
489
+ help='Add a filter to the token stream. (Query names with -L.) '
490
+ 'Filter options are given after a colon if necessary.')
491
+ operation.add_argument(
492
+ '-f', metavar='FORMATTER',
493
+ help='Specify the formatter to use. (Query names with -L.) '
494
+ 'If not given, the formatter is guessed from the output filename, '
495
+ 'and defaults to the terminal formatter if the output is to the '
496
+ 'terminal or an unknown file extension.')
497
+ operation.add_argument(
498
+ '-O', metavar='OPTION=value[,OPTION=value,...]', action='append',
499
+ help='Give options to the lexer and formatter as a comma-separated '
500
+ 'list of key-value pairs. '
501
+ 'Example: `-O bg=light,python=cool`.')
502
+ operation.add_argument(
503
+ '-P', metavar='OPTION=value', action='append',
504
+ help='Give a single option to the lexer and formatter - with this '
505
+ 'you can pass options whose value contains commas and equal signs. '
506
+ 'Example: `-P "heading=Pygments, the Python highlighter"`.')
507
+ operation.add_argument(
508
+ '-o', metavar='OUTPUTFILE',
509
+ help='Where to write the output. Defaults to standard output.')
510
+
511
+ operation.add_argument(
512
+ 'INPUTFILE', nargs='?',
513
+ help='Where to read the input. Defaults to standard input.')
514
+
515
+ flags = parser.add_argument_group('Operation flags')
516
+ flags.add_argument(
517
+ '-v', action='store_true',
518
+ help='Print a detailed traceback on unhandled exceptions, which '
519
+ 'is useful for debugging and bug reports.')
520
+ flags.add_argument(
521
+ '-s', action='store_true',
522
+ help='Process lines one at a time until EOF, rather than waiting to '
523
+ 'process the entire file. This only works for stdin, only for lexers '
524
+ 'with no line-spanning constructs, and is intended for streaming '
525
+ 'input such as you get from `tail -f`. '
526
+ 'Example usage: `tail -f sql.log | pygmentize -s -l sql`.')
527
+ flags.add_argument(
528
+ '-x', action='store_true',
529
+ help='Allow custom lexers and formatters to be loaded from a .py file '
530
+ 'relative to the current working directory. For example, '
531
+ '`-l ./customlexer.py -x`. By default, this option expects a file '
532
+ 'with a class named CustomLexer or CustomFormatter; you can also '
533
+ 'specify your own class name with a colon (`-l ./lexer.py:MyLexer`). '
534
+ 'Users should be very careful not to use this option with untrusted '
535
+ 'files, because it will import and run them.')
536
+
537
+ special_modes_group = parser.add_argument_group(
538
+ 'Special modes - do not do any highlighting')
539
+ special_modes = special_modes_group.add_mutually_exclusive_group()
540
+ special_modes.add_argument(
541
+ '-S', metavar='STYLE -f formatter',
542
+ help='Print style definitions for STYLE for a formatter '
543
+ 'given with -f. The argument given by -a is formatter '
544
+ 'dependent.')
545
+ special_modes.add_argument(
546
+ '-L', nargs='*', metavar='WHAT',
547
+ help='List lexers, formatters, styles or filters -- '
548
+ 'give additional arguments for the thing(s) you want to list '
549
+ '(e.g. "styles"), or omit them to list everything.')
550
+ special_modes.add_argument(
551
+ '-N', metavar='FILENAME',
552
+ help='Guess and print out a lexer name based solely on the given '
553
+ 'filename. Does not take input or highlight anything. If no specific '
554
+ 'lexer can be determined, "text" is printed.')
555
+ special_modes.add_argument(
556
+ '-C', action='store_true',
557
+ help='Like -N, but print out a lexer name based solely on '
558
+ 'a given content from standard input.')
559
+ special_modes.add_argument(
560
+ '-H', action='store', nargs=2, metavar=('NAME', 'TYPE'),
561
+ help='Print detailed help for the object <name> of type <type>, '
562
+ 'where <type> is one of "lexer", "formatter" or "filter".')
563
+ special_modes.add_argument(
564
+ '-V', action='store_true',
565
+ help='Print the package version.')
566
+ special_modes.add_argument(
567
+ '-h', '--help', action='store_true',
568
+ help='Print this help.')
569
+ special_modes_group.add_argument(
570
+ '-a', metavar='ARG',
571
+ help='Formatter-specific additional argument for the -S (print '
572
+ 'style sheet) mode.')
573
+
574
+ argns = parser.parse_args(args[1:])
546
575
 
547
576
  try:
548
- return main_inner(popts, args, usage)
577
+ return main_inner(parser, argns)
549
578
  except Exception:
550
- if '-v' in dict(popts):
579
+ if argns.v:
551
580
  print(file=sys.stderr)
552
581
  print('*' * 65, file=sys.stderr)
553
582
  print('An unhandled exception occurred while highlighting.',
554
583
  file=sys.stderr)
555
584
  print('Please report the whole traceback to the issue tracker at',
556
585
  file=sys.stderr)
557
- print('<https://bitbucket.org/birkenfeld/pygments-main/issues>.',
586
+ print('<https://github.com/pygments/pygments/issues>.',
558
587
  file=sys.stderr)
559
588
  print('*' * 65, file=sys.stderr)
560
589
  print(file=sys.stderr)