pygments.rb 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/Rakefile +1 -0
  4. data/lib/pygments/version.rb +1 -1
  5. data/pygments.rb.gemspec +1 -2
  6. data/vendor/pygments-main/AUTHORS +2 -0
  7. data/vendor/pygments-main/CHANGES +27 -4
  8. data/vendor/pygments-main/LICENSE +1 -1
  9. data/vendor/pygments-main/MANIFEST.in +1 -1
  10. data/vendor/pygments-main/Makefile +1 -1
  11. data/vendor/pygments-main/REVISION +1 -1
  12. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +1 -1
  13. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +1 -1
  14. data/vendor/pygments-main/doc/docs/api.rst +23 -0
  15. data/vendor/pygments-main/doc/docs/cmdline.rst +17 -0
  16. data/vendor/pygments-main/doc/docs/lexerdevelopment.rst +42 -3
  17. data/vendor/pygments-main/external/autopygmentize +28 -11
  18. data/vendor/pygments-main/external/markdown-processor.py +1 -1
  19. data/vendor/pygments-main/external/moin-parser.py +1 -1
  20. data/vendor/pygments-main/external/rst-directive.py +1 -1
  21. data/vendor/pygments-main/pygments/__init__.py +2 -2
  22. data/vendor/pygments-main/pygments/cmdline.py +61 -17
  23. data/vendor/pygments-main/pygments/console.py +1 -1
  24. data/vendor/pygments-main/pygments/filter.py +1 -1
  25. data/vendor/pygments-main/pygments/filters/__init__.py +1 -1
  26. data/vendor/pygments-main/pygments/formatter.py +1 -1
  27. data/vendor/pygments-main/pygments/formatters/__init__.py +37 -2
  28. data/vendor/pygments-main/pygments/formatters/_mapping.py +1 -1
  29. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  30. data/vendor/pygments-main/pygments/formatters/html.py +1 -1
  31. data/vendor/pygments-main/pygments/formatters/img.py +38 -1
  32. data/vendor/pygments-main/pygments/formatters/irc.py +1 -1
  33. data/vendor/pygments-main/pygments/formatters/latex.py +1 -1
  34. data/vendor/pygments-main/pygments/formatters/other.py +1 -1
  35. data/vendor/pygments-main/pygments/formatters/rtf.py +1 -1
  36. data/vendor/pygments-main/pygments/formatters/svg.py +1 -1
  37. data/vendor/pygments-main/pygments/formatters/terminal.py +1 -1
  38. data/vendor/pygments-main/pygments/formatters/terminal256.py +1 -1
  39. data/vendor/pygments-main/pygments/lexer.py +1 -1
  40. data/vendor/pygments-main/pygments/lexers/__init__.py +39 -5
  41. data/vendor/pygments-main/pygments/lexers/_asy_builtins.py +1 -1
  42. data/vendor/pygments-main/pygments/lexers/_cl_builtins.py +1 -1
  43. data/vendor/pygments-main/pygments/lexers/_cocoa_builtins.py +1 -1
  44. data/vendor/pygments-main/pygments/lexers/_csound_builtins.py +1 -1
  45. data/vendor/pygments-main/pygments/lexers/_lasso_builtins.py +8 -1
  46. data/vendor/pygments-main/pygments/lexers/_lua_builtins.py +1 -1
  47. data/vendor/pygments-main/pygments/lexers/_mapping.py +6 -5
  48. data/vendor/pygments-main/pygments/lexers/_mql_builtins.py +1 -1
  49. data/vendor/pygments-main/pygments/lexers/_openedge_builtins.py +1 -1
  50. data/vendor/pygments-main/pygments/lexers/_php_builtins.py +1 -1
  51. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +1 -1
  52. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  53. data/vendor/pygments-main/pygments/lexers/_sourcemod_builtins.py +1 -1
  54. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +1 -1
  55. data/vendor/pygments-main/pygments/lexers/_stata_builtins.py +1 -1
  56. data/vendor/pygments-main/pygments/lexers/_tsql_builtins.py +1 -1
  57. data/vendor/pygments-main/pygments/lexers/_vim_builtins.py +1 -1
  58. data/vendor/pygments-main/pygments/lexers/actionscript.py +1 -1
  59. data/vendor/pygments-main/pygments/lexers/agile.py +1 -1
  60. data/vendor/pygments-main/pygments/lexers/algebra.py +1 -1
  61. data/vendor/pygments-main/pygments/lexers/ambient.py +1 -1
  62. data/vendor/pygments-main/pygments/lexers/ampl.py +1 -1
  63. data/vendor/pygments-main/pygments/lexers/apl.py +1 -1
  64. data/vendor/pygments-main/pygments/lexers/archetype.py +1 -1
  65. data/vendor/pygments-main/pygments/lexers/asm.py +21 -10
  66. data/vendor/pygments-main/pygments/lexers/automation.py +3 -3
  67. data/vendor/pygments-main/pygments/lexers/basic.py +1 -1
  68. data/vendor/pygments-main/pygments/lexers/bibtex.py +9 -5
  69. data/vendor/pygments-main/pygments/lexers/business.py +53 -35
  70. data/vendor/pygments-main/pygments/lexers/c_cpp.py +1 -1
  71. data/vendor/pygments-main/pygments/lexers/c_like.py +2 -2
  72. data/vendor/pygments-main/pygments/lexers/capnproto.py +14 -15
  73. data/vendor/pygments-main/pygments/lexers/chapel.py +4 -3
  74. data/vendor/pygments-main/pygments/lexers/clean.py +11 -11
  75. data/vendor/pygments-main/pygments/lexers/compiled.py +1 -1
  76. data/vendor/pygments-main/pygments/lexers/configs.py +3 -3
  77. data/vendor/pygments-main/pygments/lexers/console.py +1 -1
  78. data/vendor/pygments-main/pygments/lexers/crystal.py +29 -20
  79. data/vendor/pygments-main/pygments/lexers/csound.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/css.py +1 -1
  81. data/vendor/pygments-main/pygments/lexers/d.py +1 -1
  82. data/vendor/pygments-main/pygments/lexers/dalvik.py +1 -1
  83. data/vendor/pygments-main/pygments/lexers/data.py +1 -1
  84. data/vendor/pygments-main/pygments/lexers/diff.py +1 -1
  85. data/vendor/pygments-main/pygments/lexers/dotnet.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/dsls.py +4 -4
  87. data/vendor/pygments-main/pygments/lexers/dylan.py +1 -1
  88. data/vendor/pygments-main/pygments/lexers/ecl.py +1 -1
  89. data/vendor/pygments-main/pygments/lexers/eiffel.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/elm.py +1 -1
  91. data/vendor/pygments-main/pygments/lexers/erlang.py +1 -1
  92. data/vendor/pygments-main/pygments/lexers/esoteric.py +9 -7
  93. data/vendor/pygments-main/pygments/lexers/ezhil.py +4 -3
  94. data/vendor/pygments-main/pygments/lexers/factor.py +1 -1
  95. data/vendor/pygments-main/pygments/lexers/fantom.py +1 -1
  96. data/vendor/pygments-main/pygments/lexers/felix.py +1 -1
  97. data/vendor/pygments-main/pygments/lexers/forth.py +1 -1
  98. data/vendor/pygments-main/pygments/lexers/fortran.py +1 -1
  99. data/vendor/pygments-main/pygments/lexers/foxpro.py +1 -1
  100. data/vendor/pygments-main/pygments/lexers/functional.py +1 -1
  101. data/vendor/pygments-main/pygments/lexers/go.py +1 -1
  102. data/vendor/pygments-main/pygments/lexers/grammar_notation.py +2 -2
  103. data/vendor/pygments-main/pygments/lexers/graph.py +1 -1
  104. data/vendor/pygments-main/pygments/lexers/graphics.py +1 -1
  105. data/vendor/pygments-main/pygments/lexers/haskell.py +5 -2
  106. data/vendor/pygments-main/pygments/lexers/haxe.py +1 -1
  107. data/vendor/pygments-main/pygments/lexers/hdl.py +1 -1
  108. data/vendor/pygments-main/pygments/lexers/hexdump.py +18 -12
  109. data/vendor/pygments-main/pygments/lexers/html.py +1 -1
  110. data/vendor/pygments-main/pygments/lexers/idl.py +2 -2
  111. data/vendor/pygments-main/pygments/lexers/igor.py +1 -1
  112. data/vendor/pygments-main/pygments/lexers/inferno.py +1 -1
  113. data/vendor/pygments-main/pygments/lexers/installers.py +1 -1
  114. data/vendor/pygments-main/pygments/lexers/int_fiction.py +1 -1
  115. data/vendor/pygments-main/pygments/lexers/iolang.py +1 -1
  116. data/vendor/pygments-main/pygments/lexers/j.py +1 -1
  117. data/vendor/pygments-main/pygments/lexers/javascript.py +56 -37
  118. data/vendor/pygments-main/pygments/lexers/julia.py +3 -3
  119. data/vendor/pygments-main/pygments/lexers/jvm.py +1 -1
  120. data/vendor/pygments-main/pygments/lexers/lisp.py +1 -1
  121. data/vendor/pygments-main/pygments/lexers/make.py +1 -1
  122. data/vendor/pygments-main/pygments/lexers/markup.py +1 -1
  123. data/vendor/pygments-main/pygments/lexers/math.py +1 -1
  124. data/vendor/pygments-main/pygments/lexers/matlab.py +1 -1
  125. data/vendor/pygments-main/pygments/lexers/ml.py +1 -1
  126. data/vendor/pygments-main/pygments/lexers/modeling.py +1 -1
  127. data/vendor/pygments-main/pygments/lexers/modula2.py +1 -1
  128. data/vendor/pygments-main/pygments/lexers/monte.py +4 -3
  129. data/vendor/pygments-main/pygments/lexers/ncl.py +85 -244
  130. data/vendor/pygments-main/pygments/lexers/nimrod.py +1 -1
  131. data/vendor/pygments-main/pygments/lexers/nit.py +1 -1
  132. data/vendor/pygments-main/pygments/lexers/nix.py +1 -1
  133. data/vendor/pygments-main/pygments/lexers/oberon.py +1 -1
  134. data/vendor/pygments-main/pygments/lexers/objective.py +1 -1
  135. data/vendor/pygments-main/pygments/lexers/ooc.py +1 -1
  136. data/vendor/pygments-main/pygments/lexers/other.py +1 -1
  137. data/vendor/pygments-main/pygments/lexers/parasail.py +1 -1
  138. data/vendor/pygments-main/pygments/lexers/parsers.py +1 -1
  139. data/vendor/pygments-main/pygments/lexers/pascal.py +2 -2
  140. data/vendor/pygments-main/pygments/lexers/pawn.py +1 -1
  141. data/vendor/pygments-main/pygments/lexers/perl.py +17 -13
  142. data/vendor/pygments-main/pygments/lexers/php.py +1 -1
  143. data/vendor/pygments-main/pygments/lexers/praat.py +1 -1
  144. data/vendor/pygments-main/pygments/lexers/prolog.py +1 -1
  145. data/vendor/pygments-main/pygments/lexers/python.py +2 -1
  146. data/vendor/pygments-main/pygments/lexers/qvt.py +1 -1
  147. data/vendor/pygments-main/pygments/lexers/r.py +1 -1
  148. data/vendor/pygments-main/pygments/lexers/rdf.py +1 -1
  149. data/vendor/pygments-main/pygments/lexers/rebol.py +1 -1
  150. data/vendor/pygments-main/pygments/lexers/resource.py +1 -1
  151. data/vendor/pygments-main/pygments/lexers/rnc.py +1 -1
  152. data/vendor/pygments-main/pygments/lexers/roboconf.py +1 -1
  153. data/vendor/pygments-main/pygments/lexers/robotframework.py +1 -1
  154. data/vendor/pygments-main/pygments/lexers/ruby.py +1 -1
  155. data/vendor/pygments-main/pygments/lexers/rust.py +41 -30
  156. data/vendor/pygments-main/pygments/lexers/sas.py +7 -7
  157. data/vendor/pygments-main/pygments/lexers/scripting.py +1 -1
  158. data/vendor/pygments-main/pygments/lexers/shell.py +14 -10
  159. data/vendor/pygments-main/pygments/lexers/smalltalk.py +1 -1
  160. data/vendor/pygments-main/pygments/lexers/smv.py +28 -24
  161. data/vendor/pygments-main/pygments/lexers/snobol.py +1 -1
  162. data/vendor/pygments-main/pygments/lexers/special.py +1 -1
  163. data/vendor/pygments-main/pygments/lexers/sql.py +1 -1
  164. data/vendor/pygments-main/pygments/lexers/stata.py +9 -7
  165. data/vendor/pygments-main/pygments/lexers/supercollider.py +1 -1
  166. data/vendor/pygments-main/pygments/lexers/tcl.py +1 -1
  167. data/vendor/pygments-main/pygments/lexers/templates.py +48 -17
  168. data/vendor/pygments-main/pygments/lexers/testing.py +1 -1
  169. data/vendor/pygments-main/pygments/lexers/text.py +1 -1
  170. data/vendor/pygments-main/pygments/lexers/textedit.py +1 -1
  171. data/vendor/pygments-main/pygments/lexers/textfmts.py +1 -1
  172. data/vendor/pygments-main/pygments/lexers/theorem.py +1 -1
  173. data/vendor/pygments-main/pygments/lexers/trafficscript.py +1 -1
  174. data/vendor/pygments-main/pygments/lexers/typoscript.py +8 -7
  175. data/vendor/pygments-main/pygments/lexers/urbi.py +1 -1
  176. data/vendor/pygments-main/pygments/lexers/varnish.py +3 -3
  177. data/vendor/pygments-main/pygments/lexers/verification.py +3 -3
  178. data/vendor/pygments-main/pygments/lexers/web.py +1 -1
  179. data/vendor/pygments-main/pygments/lexers/webmisc.py +20 -11
  180. data/vendor/pygments-main/pygments/lexers/whiley.py +7 -8
  181. data/vendor/pygments-main/pygments/lexers/x10.py +1 -1
  182. data/vendor/pygments-main/pygments/lexers/xorg.py +36 -0
  183. data/vendor/pygments-main/pygments/modeline.py +6 -5
  184. data/vendor/pygments-main/pygments/plugin.py +12 -18
  185. data/vendor/pygments-main/pygments/regexopt.py +1 -1
  186. data/vendor/pygments-main/pygments/scanner.py +1 -1
  187. data/vendor/pygments-main/pygments/sphinxext.py +1 -1
  188. data/vendor/pygments-main/pygments/style.py +1 -1
  189. data/vendor/pygments-main/pygments/styles/__init__.py +4 -2
  190. data/vendor/pygments-main/pygments/styles/abap.py +29 -0
  191. data/vendor/pygments-main/pygments/styles/algol.py +1 -1
  192. data/vendor/pygments-main/pygments/styles/algol_nu.py +1 -1
  193. data/vendor/pygments-main/pygments/styles/arduino.py +1 -1
  194. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  195. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  196. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  197. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  198. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  199. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  200. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  201. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  202. data/vendor/pygments-main/pygments/styles/igor.py +1 -1
  203. data/vendor/pygments-main/pygments/styles/lovelace.py +1 -1
  204. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  205. data/vendor/pygments-main/pygments/styles/monokai.py +1 -1
  206. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  207. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  208. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +1 -1
  209. data/vendor/pygments-main/pygments/styles/paraiso_light.py +1 -1
  210. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  211. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  212. data/vendor/pygments-main/pygments/styles/rainbow_dash.py +89 -0
  213. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  214. data/vendor/pygments-main/pygments/styles/sas.py +3 -0
  215. data/vendor/pygments-main/pygments/styles/stata.py +3 -0
  216. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  217. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  218. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  219. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  220. data/vendor/pygments-main/pygments/styles/xcode.py +1 -1
  221. data/vendor/pygments-main/pygments/token.py +1 -1
  222. data/vendor/pygments-main/pygments/unistring.py +1 -1
  223. data/vendor/pygments-main/pygments/util.py +5 -4
  224. data/vendor/pygments-main/scripts/check_sources.py +2 -2
  225. data/vendor/pygments-main/scripts/debug_lexer.py +1 -1
  226. data/vendor/pygments-main/scripts/get_vimkw.py +1 -1
  227. data/vendor/pygments-main/setup.cfg +2 -2
  228. data/vendor/pygments-main/setup.py +3 -3
  229. metadata +6 -4
  230. data/vendor/pygments-main/scripts/find_error.py +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bc5149afa7c5c2d0c10d4c6aff7bc3baa070995
4
- data.tar.gz: 082c9c329d7efa34eeef65e3418cf692651df776
3
+ metadata.gz: 68bbaf00ae347f4be0aa0915c3c91d3702fb1018
4
+ data.tar.gz: 3a35c538fdf8ceec9ad26f3ac86cb708e73f7109
5
5
  SHA512:
6
- metadata.gz: 804642de1b753e1f29469248eba2595c2d0bc472336797688cfe73d8c835bc2d1e8da62651d4060feeae95a3cb48694eab67394210a952f6695f7ba41c17d67c
7
- data.tar.gz: 0308d5e79197552f817854ad6827dfe0d8d8a500e34b67afd597381777149b9ae26b54ed86aedec3a68a87a9c948ca3238b7ed465bc35d9a65a3b68cb8355891
6
+ metadata.gz: 1ab74f4da1c783693f827b3245abf4a9d88c75fc92fbaeba78950f29638f36e85e61cef83d936537937e33749237d12b139ec46c1df3d03e8aa0a38cb629be0c
7
+ data.tar.gz: 0afd2f0409c4932453582ab242f8501601528a266411b6bcd1b1fc235da82074832a5d71d9adce682f0dcd099e23286e22342236c132dc9cd73b635b78878b25
@@ -1,7 +1,14 @@
1
- changelog
1
+ CHANGELOG
2
2
  ===========
3
3
 
4
+ Version 1.2.0 (2017/09/13)
5
+ -----------------------------
6
+
7
+ * Exclude symlinks from the gem package to solve Windows issues [#181](https://github.com/tmm1/pygments.rb/pull/181)
8
+ * Upgrade pygments to 2.0.0 [#180](https://github.com/tmm1/pygments.rb/pull/180)
9
+
4
10
  Version 1.1.2 (2017/04/03)
11
+ -----------------------------
5
12
 
6
13
  * Resolves #176 exclude find_error.py symlink from gem [#177](https://github.com/tmm1/pygments.rb/pull/177)
7
14
 
data/Rakefile CHANGED
@@ -63,5 +63,6 @@ namespace :vendor do
63
63
  FileUtils.cd(LEXERS_DIR) { sh "python _mapping.py" }
64
64
  end
65
65
 
66
+ desc 'update vendor/pygments-main'
66
67
  task :update => [:clobber, 'vendor/pygments-main', :load_lexers]
67
68
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
  # frozen_string_literal: true
3
3
  module Pygments
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -21,6 +21,5 @@ Gem::Specification.new do |s|
21
21
  # s.extensions = ['ext/extconf.rb']
22
22
  s.require_paths = ['lib']
23
23
 
24
- exclude = `find . -type l -printf '%P\\0'`.split("\0").map {|f| "':!#{f}'" } * ' '
25
- s.files = `git ls-files -- . #{exclude}`.split("\n")
24
+ s.files = `git ls-files`.split("\n").select { |f| !File.symlink?(f) }
26
25
  end
@@ -155,6 +155,7 @@ Other contributors, listed alphabetically, are:
155
155
  * Dominik Picheta -- Nimrod lexer
156
156
  * Andrew Pinkham -- RTF Formatter Refactoring
157
157
  * Clément Prévost -- UrbiScript lexer
158
+ * Tanner Prynn -- cmdline -x option and loading lexers from files
158
159
  * Oleh Prypin -- Crystal lexer (based on Ruby lexer)
159
160
  * Elias Rabel -- Fortran fixed form lexer
160
161
  * raichoo -- Idris lexer
@@ -173,6 +174,7 @@ Other contributors, listed alphabetically, are:
173
174
  * Matteo Sasso -- Common Lisp lexer
174
175
  * Joe Schafer -- Ada lexer
175
176
  * Ken Schutte -- Matlab lexers
177
+ * René Schwaiger -- Rainbow Dash style
176
178
  * Sebastian Schweizer -- Whiley lexer
177
179
  * Tassilo Schweyer -- Io, MOOCode lexers
178
180
  * Ted Shaw -- AutoIt lexer
@@ -6,9 +6,9 @@ Issue numbers refer to the tracker at
6
6
  pull request numbers to the requests at
7
7
  <https://bitbucket.org/birkenfeld/pygments-main/pull-requests/merged>.
8
8
 
9
- Version 2.2
10
- -----------
11
- (in development)
9
+ Version 2.2.0
10
+ -------------
11
+ (release Jan 22, 2017)
12
12
 
13
13
  - Added lexers:
14
14
 
@@ -24,6 +24,17 @@ Version 2.2
24
24
  * NCAR command language (PR#536)
25
25
  * Extempore (PR#530)
26
26
  * Cap'n Proto (PR#595)
27
+ * Whiley (PR#573)
28
+ * Monte (PR#592)
29
+ * Crystal (PR#576)
30
+ * Snowball (PR#589)
31
+ * CapDL (PR#579)
32
+ * NuSMV (PR#564)
33
+ * SAS, Stata (PR#593)
34
+
35
+ - Added the ability to load lexer and formatter classes directly from files
36
+ with the `-x` command line option and the `lexers.load_lexer_from_file()`
37
+ and `formatters.load_formatter_from_file()` functions. (PR#559)
27
38
 
28
39
  - Added `lexers.find_lexer_class_by_name()`. (#1203)
29
40
 
@@ -41,12 +52,24 @@ Version 2.2
41
52
 
42
53
  - Improved the CSS lexer. (#1083, #1130)
43
54
 
55
+ - Added "Rainbow Dash" style. (PR#623)
56
+
57
+ - Delay loading `pkg_resources`, which takes a long while to import. (PR#690)
58
+
59
+
60
+ Version 2.1.3
61
+ -------------
62
+ (released Mar 2, 2016)
63
+
64
+ - Fixed regression in Bash lexer (PR#563)
65
+
44
66
 
45
67
  Version 2.1.2
46
68
  -------------
47
- (in development)
69
+ (released Feb 29, 2016)
48
70
 
49
71
  - Fixed Python 3 regression in image formatter (#1215)
72
+ - Fixed regression in Bash lexer (PR#562)
50
73
 
51
74
 
52
75
  Version 2.1.1
@@ -1,4 +1,4 @@
1
- Copyright (c) 2006-2015 by the respective authors (see AUTHORS file).
1
+ Copyright (c) 2006-2017 by the respective authors (see AUTHORS file).
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
@@ -1,6 +1,6 @@
1
1
  include pygmentize
2
2
  include external/*
3
- include Makefile CHANGES LICENSE AUTHORS TODO ez_setup.py
3
+ include Makefile CHANGES LICENSE AUTHORS TODO
4
4
  recursive-include tests *
5
5
  recursive-include doc *
6
6
  recursive-include scripts *
@@ -4,7 +4,7 @@
4
4
  #
5
5
  # Combines scripts for common tasks.
6
6
  #
7
- # :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
7
+ # :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
8
8
  # :license: BSD, see LICENSE for details.
9
9
  #
10
10
 
@@ -1 +1 @@
1
- a042025b350c
1
+ 7941677dc77d
@@ -82,7 +82,7 @@
82
82
 
83
83
  {% block footer %}
84
84
  <div class="footer" role="contentinfo">
85
- &copy; Copyright 2006-2015, Georg Brandl and Pygments contributors.
85
+ &copy; Copyright 2006-2017, Georg Brandl and Pygments contributors.
86
86
  Created using <a href="http://sphinx-doc.org/">Sphinx</a> {{
87
87
  sphinx_version }}. <br/>
88
88
  Pygments logo created by <a href="http://joelunger.com">Joel Unger</a>.
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Sphinx stylesheet -- pygments14 theme. Heavily copied from sphinx13.
6
6
  *
7
- * :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
7
+ * :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
8
8
  * :license: BSD, see LICENSE for details.
9
9
  *
10
10
  */
@@ -62,6 +62,18 @@ Functions from :mod:`pygments.lexers`:
62
62
  Will raise :exc:`pygments.util.ClassNotFound` if not lexer for that mimetype
63
63
  is found.
64
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
+
65
77
  .. function:: guess_lexer(text, **options)
66
78
 
67
79
  Return a `Lexer` subclass instance that's guessed from the text in
@@ -125,6 +137,17 @@ Functions from :mod:`pygments.formatters`:
125
137
  Will raise :exc:`pygments.util.ClassNotFound` if no formatter for that filename
126
138
  is found.
127
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
128
151
 
129
152
  .. module:: pygments.styles
130
153
 
@@ -99,6 +99,23 @@ The ``-N`` option guesses a lexer name for a given filename, so that ::
99
99
  will print out ``python``. It won't highlight anything yet. If no specific
100
100
  lexer is known for that filename, ``text`` is printed.
101
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>`.
102
119
 
103
120
  Getting help
104
121
  ------------
@@ -88,8 +88,47 @@ one.
88
88
  Adding and testing a new lexer
89
89
  ==============================
90
90
 
91
- Using a lexer that is not part of Pygments can be done via the Python API. You
92
- can import and instantiate the lexer, and pass it to :func:`pygments.highlight`.
91
+ The easiest way to use a new lexer is to use Pygments' support for loading
92
+ the lexer from a file relative to your current directory.
93
+
94
+ First, change the name of your lexer class to CustomLexer:
95
+
96
+ .. code-block:: python
97
+
98
+ from pygments.lexer import RegexLexer
99
+ from pygments.token import *
100
+
101
+ class CustomLexer(RegexLexer):
102
+ """All your lexer code goes here!"""
103
+
104
+ Then you can load the lexer from the command line with the additional
105
+ flag ``-x``:
106
+
107
+ .. code-block:: console
108
+
109
+ $ pygmentize -l your_lexer_file.py -x
110
+
111
+ To specify a class name other than CustomLexer, append it with a colon:
112
+
113
+ .. code-block:: console
114
+
115
+ $ pygmentize -l your_lexer.py:SomeLexer -x
116
+
117
+ Or, using the Python API:
118
+
119
+ .. code-block:: python
120
+
121
+ # For a lexer named CustomLexer
122
+ your_lexer = load_lexer_from_file(filename, **options)
123
+
124
+ # For a lexer named MyNewLexer
125
+ your_named_lexer = load_lexer_from_file(filename, "MyNewLexer", **options)
126
+
127
+ When loading custom lexers and formatters, be extremely careful to use only
128
+ trusted files; Pygments will perform the equivalent of ``eval`` on them.
129
+
130
+ If you only want to use your lexer with the Pygments API, you can import and
131
+ instantiate the lexer yourself, then pass it to :func:`pygments.highlight`.
93
132
 
94
133
  To prepare your new lexer for inclusion in the Pygments distribution, so that it
95
134
  will be found when passing filenames or lexer aliases from the command line, you
@@ -361,7 +400,7 @@ There are a few more things you can do with states:
361
400
  tokens = {...}
362
401
 
363
402
  def get_tokens_unprocessed(self, text, stack=('root', 'otherstate')):
364
- for item in RegexLexer.get_tokens_unprocessed(text, stack):
403
+ for item in RegexLexer.get_tokens_unprocessed(self, text, stack):
365
404
  yield item
366
405
 
367
406
  Some lexers like the `PhpLexer` use this to make the leading ``<?php``
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
  # Best effort auto-pygmentization with transparent decompression
3
- # by Reuben Thomas 2008-2015
3
+ # by Reuben Thomas 2008-2016
4
4
  # This program is in the public domain.
5
5
 
6
6
  # Strategy: first see if pygmentize can find a lexer; if not, ask file; if that finds nothing, fail
@@ -25,6 +25,7 @@ if [[ "$lexer" == text ]]; then
25
25
  text/x-awk) lexer=awk;;
26
26
  text/x-c) lexer=c;;
27
27
  text/x-c++) lexer=cpp;;
28
+ text/x-crystal) lexer=crystal;;
28
29
  text/x-diff) lexer=diff;;
29
30
  text/x-fortran) lexer=fortran;;
30
31
  text/x-gawk) lexer=gawk;;
@@ -40,7 +41,6 @@ if [[ "$lexer" == text ]]; then
40
41
  text/x-po) lexer=po;;
41
42
  text/x-python) lexer=python;;
42
43
  text/x-ruby) lexer=ruby;;
43
- text/x-crystal) lexer=crystal;;
44
44
  text/x-shellscript) lexer=sh;;
45
45
  text/x-tcl) lexer=tcl;;
46
46
  text/x-tex|text/x-texinfo) lexer=latex;; # FIXME: texinfo really needs its own lexer
@@ -66,19 +66,36 @@ if [[ "$lexer" == text ]]; then
66
66
  esac
67
67
  fi
68
68
 
69
+ # Find a preprocessor for compressed files
70
+ concat=cat
71
+ case $(file $file_common_opts --mime-type "$file") in
72
+ application/x-gzip) concat=zcat;;
73
+ application/x-bzip2) concat=bzcat;;
74
+ application/x-xz) concat=xzcat;;
75
+ esac
76
+
77
+ # Find a suitable lexer, preceded by a hex dump for binary files
78
+ prereader=""
69
79
  encoding=$(file --mime-encoding --uncompress $file_common_opts "$file")
70
80
  if [[ $encoding == "binary" ]]; then
71
- encoding="latin1"
81
+ prereader="od -x" # POSIX fallback
82
+ if [[ -n $(which hd) ]]; then
83
+ prereader="hd" # preferred
84
+ fi
85
+ lexer=hexdump
86
+ encoding=latin1
72
87
  fi
73
-
74
88
  if [[ -n "$lexer" ]]; then
75
- concat=cat
76
- case $(file $file_common_opts --mime-type "$file") in
77
- application/x-gzip) concat=zcat;;
78
- application/x-bzip2) concat=bzcat;;
79
- application/x-xz) concat=xzcat;;
80
- esac
81
- exec $concat "$file" | pygmentize -O inencoding=$encoding $PYGMENTIZE_OPTS $options -l $lexer
89
+ reader="pygmentize -O inencoding=$encoding $PYGMENTIZE_OPTS $options -l $lexer"
90
+ fi
91
+
92
+ # If we found a reader, run it
93
+ if [[ -n "$reader" ]]; then
94
+ if [[ -n "$prereader" ]]; then
95
+ exec $concat "$file" | $prereader | $reader
96
+ else
97
+ exec $concat "$file" | $reader
98
+ fi
82
99
  fi
83
100
 
84
101
  exit 1
@@ -22,7 +22,7 @@
22
22
 
23
23
  .. _Markdown: https://pypi.python.org/pypi/Markdown
24
24
 
25
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
25
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
26
26
  :license: BSD, see LICENSE for details.
27
27
  """
28
28
 
@@ -31,7 +31,7 @@
31
31
  If you do not want to do that and are willing to accept larger HTML
32
32
  output, you can set the INLINESTYLES option below to True.
33
33
 
34
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
34
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
35
35
  :license: BSD, see LICENSE for details.
36
36
  """
37
37
 
@@ -31,7 +31,7 @@
31
31
  .. _directive documentation:
32
32
  http://docutils.sourceforge.net/docs/howto/rst-directives.html
33
33
 
34
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
34
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
35
35
  :license: BSD, see LICENSE for details.
36
36
  """
37
37
 
@@ -22,14 +22,14 @@
22
22
  .. _Pygments tip:
23
23
  http://bitbucket.org/birkenfeld/pygments-main/get/tip.zip#egg=Pygments-dev
24
24
 
25
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
25
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
26
26
  :license: BSD, see LICENSE for details.
27
27
  """
28
28
  import sys
29
29
 
30
30
  from pygments.util import StringIO, BytesIO
31
31
 
32
- __version__ = '2.2a0'
32
+ __version__ = '2.2.0'
33
33
  __docformat__ = 'restructuredtext'
34
34
 
35
35
  __all__ = ['lex', 'format', 'highlight']
@@ -5,12 +5,13 @@
5
5
 
6
6
  Command line interface.
7
7
 
8
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
12
12
  from __future__ import print_function
13
13
 
14
+ import os
14
15
  import sys
15
16
  import getopt
16
17
  from textwrap import dedent
@@ -19,19 +20,20 @@ from pygments import __version__, highlight
19
20
  from pygments.util import ClassNotFound, OptionError, docstring_headline, \
20
21
  guess_decode, guess_decode_from_terminal, terminal_encoding
21
22
  from pygments.lexers import get_all_lexers, get_lexer_by_name, guess_lexer, \
22
- get_lexer_for_filename, find_lexer_class_for_filename
23
+ load_lexer_from_file, get_lexer_for_filename, find_lexer_class_for_filename
23
24
  from pygments.lexers.special import TextLexer
24
25
  from pygments.formatters.latex import LatexEmbeddedLexer, LatexFormatter
25
26
  from pygments.formatters import get_all_formatters, get_formatter_by_name, \
26
- get_formatter_for_filename, find_formatter_class
27
+ load_formatter_from_file, get_formatter_for_filename, find_formatter_class
27
28
  from pygments.formatters.terminal import TerminalFormatter
29
+ from pygments.formatters.terminal256 import Terminal256Formatter
28
30
  from pygments.filters import get_all_filters, find_filter_class
29
31
  from pygments.styles import get_all_styles, get_style_by_name
30
32
 
31
33
 
32
34
  USAGE = """\
33
35
  Usage: %s [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]
34
- [-O <options>] [-P <option=value>] [-s] [-v] [-o <outfile>] [<infile>]
36
+ [-O <options>] [-P <option=value>] [-s] [-v] [-x] [-o <outfile>] [<infile>]
35
37
 
36
38
  %s -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]
37
39
  %s -L [<which> ...]
@@ -57,6 +59,14 @@ Likewise, <formatter> is a formatter name, and will be guessed from
57
59
  the extension of the output file name. If no output file is given,
58
60
  the terminal formatter will be used by default.
59
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
+
60
70
  With the -O option, you can give the lexer and formatter a comma-
61
71
  separated list of options, e.g. ``-O bg=light,python=cool``.
62
72
 
@@ -223,7 +233,7 @@ def main_inner(popts, args, usage):
223
233
  return 0
224
234
 
225
235
  if opts.pop('-V', None) is not None:
226
- print('Pygments version %s, (c) 2006-2015 by Georg Brandl.' % __version__)
236
+ print('Pygments version %s, (c) 2006-2017 by Georg Brandl.' % __version__)
227
237
  return 0
228
238
 
229
239
  # handle ``pygmentize -L``
@@ -314,17 +324,35 @@ def main_inner(popts, args, usage):
314
324
  F_opts = _parse_filters(F_opts)
315
325
  opts.pop('-F', None)
316
326
 
327
+ allow_custom_lexer_formatter = False
328
+ # -x: allow custom (eXternal) lexers and formatters
329
+ if opts.pop('-x', None) is not None:
330
+ allow_custom_lexer_formatter = True
331
+
317
332
  # select lexer
318
333
  lexer = None
319
334
 
320
335
  # given by name?
321
336
  lexername = opts.pop('-l', None)
322
337
  if lexername:
323
- try:
324
- lexer = get_lexer_by_name(lexername, **parsed_opts)
325
- except (OptionError, ClassNotFound) as err:
326
- print('Error:', err, file=sys.stderr)
327
- return 1
338
+ # custom lexer, located relative to user's cwd
339
+ if allow_custom_lexer_formatter and '.py' in lexername:
340
+ try:
341
+ if ':' in lexername:
342
+ filename, name = lexername.rsplit(':', 1)
343
+ lexer = load_lexer_from_file(filename, name,
344
+ **parsed_opts)
345
+ else:
346
+ lexer = load_lexer_from_file(lexername, **parsed_opts)
347
+ except ClassNotFound as err:
348
+ print('Error:', err, file=sys.stderr)
349
+ return 1
350
+ else:
351
+ try:
352
+ lexer = get_lexer_by_name(lexername, **parsed_opts)
353
+ except (OptionError, ClassNotFound) as err:
354
+ print('Error:', err, file=sys.stderr)
355
+ return 1
328
356
 
329
357
  # read input code
330
358
  code = None
@@ -401,11 +429,24 @@ def main_inner(popts, args, usage):
401
429
  outfn = opts.pop('-o', None)
402
430
  fmter = opts.pop('-f', None)
403
431
  if fmter:
404
- try:
405
- fmter = get_formatter_by_name(fmter, **parsed_opts)
406
- except (OptionError, ClassNotFound) as err:
407
- print('Error:', err, file=sys.stderr)
408
- return 1
432
+ # custom formatter, located relative to user's cwd
433
+ if allow_custom_lexer_formatter and '.py' in fmter:
434
+ try:
435
+ if ':' in fmter:
436
+ file, fmtername = fmter.rsplit(':', 1)
437
+ fmter = load_formatter_from_file(file, fmtername,
438
+ **parsed_opts)
439
+ else:
440
+ fmter = load_formatter_from_file(fmter, **parsed_opts)
441
+ except ClassNotFound as err:
442
+ print('Error:', err, file=sys.stderr)
443
+ return 1
444
+ else:
445
+ try:
446
+ fmter = get_formatter_by_name(fmter, **parsed_opts)
447
+ except (OptionError, ClassNotFound) as err:
448
+ print('Error:', err, file=sys.stderr)
449
+ return 1
409
450
 
410
451
  if outfn:
411
452
  if not fmter:
@@ -421,7 +462,10 @@ def main_inner(popts, args, usage):
421
462
  return 1
422
463
  else:
423
464
  if not fmter:
424
- fmter = TerminalFormatter(**parsed_opts)
465
+ if '256' in os.environ.get('TERM', ''):
466
+ fmter = Terminal256Formatter(**parsed_opts)
467
+ else:
468
+ fmter = TerminalFormatter(**parsed_opts)
425
469
  if sys.version_info > (3,):
426
470
  # Python 3: we have to use .buffer to get a binary stream
427
471
  outfile = sys.stdout.buffer
@@ -495,7 +539,7 @@ def main(args=sys.argv):
495
539
  usage = USAGE % ((args[0],) * 6)
496
540
 
497
541
  try:
498
- popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:vhVHgs")
542
+ popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:vhVHgsx")
499
543
  except getopt.GetoptError:
500
544
  print(usage, file=sys.stderr)
501
545
  return 2