pygments.rb 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +3 -0
  4. data/lexers +0 -0
  5. data/lib/pygments/popen.rb +3 -2
  6. data/lib/pygments/version.rb +1 -1
  7. data/pygments.rb.gemspec +2 -1
  8. data/vendor/pygments-main/AUTHORS +20 -1
  9. data/vendor/pygments-main/CHANGES +55 -3
  10. data/vendor/pygments-main/LICENSE +1 -1
  11. data/vendor/pygments-main/MANIFEST.in +1 -1
  12. data/vendor/pygments-main/Makefile +5 -8
  13. data/vendor/pygments-main/REVISION +1 -1
  14. data/vendor/pygments-main/doc/Makefile +153 -0
  15. data/vendor/pygments-main/doc/_static/favicon.ico +0 -0
  16. data/vendor/pygments-main/doc/_static/logo_new.png +0 -0
  17. data/vendor/pygments-main/doc/_static/logo_only.png +0 -0
  18. data/vendor/pygments-main/doc/_templates/docssidebar.html +3 -0
  19. data/vendor/pygments-main/doc/_templates/indexsidebar.html +25 -0
  20. data/vendor/pygments-main/doc/_themes/pygments14/layout.html +98 -0
  21. data/vendor/pygments-main/doc/_themes/pygments14/static/bodybg.png +0 -0
  22. data/vendor/pygments-main/doc/_themes/pygments14/static/docbg.png +0 -0
  23. data/vendor/pygments-main/doc/_themes/pygments14/static/listitem.png +0 -0
  24. data/vendor/pygments-main/doc/_themes/pygments14/static/logo.png +0 -0
  25. data/vendor/pygments-main/doc/_themes/pygments14/static/pocoo.png +0 -0
  26. data/vendor/pygments-main/doc/_themes/pygments14/static/pygments14.css_t +401 -0
  27. data/vendor/pygments-main/doc/_themes/pygments14/theme.conf +15 -0
  28. data/vendor/pygments-main/doc/conf.py +249 -0
  29. data/vendor/pygments-main/doc/docs/api.rst +316 -0
  30. data/vendor/pygments-main/doc/docs/authors.rst +4 -0
  31. data/vendor/pygments-main/doc/docs/changelog.rst +1 -0
  32. data/vendor/pygments-main/{docs/src/cmdline.txt → doc/docs/cmdline.rst} +9 -11
  33. data/vendor/pygments-main/{docs/src/filterdevelopment.txt → doc/docs/filterdevelopment.rst} +1 -1
  34. data/vendor/pygments-main/{docs/src/filters.txt → doc/docs/filters.rst} +4 -5
  35. data/vendor/pygments-main/{docs/src/formatterdevelopment.txt → doc/docs/formatterdevelopment.rst} +1 -1
  36. data/vendor/pygments-main/{docs/src/formatters.txt → doc/docs/formatters.rst} +6 -6
  37. data/vendor/pygments-main/doc/docs/index.rst +66 -0
  38. data/vendor/pygments-main/{docs/src/integrate.txt → doc/docs/integrate.rst} +3 -7
  39. data/vendor/pygments-main/{docs/src/java.txt → doc/docs/java.rst} +0 -0
  40. data/vendor/pygments-main/{docs/src/lexerdevelopment.txt → doc/docs/lexerdevelopment.rst} +13 -14
  41. data/vendor/pygments-main/{docs/src/lexers.txt → doc/docs/lexers.rst} +7 -5
  42. data/vendor/pygments-main/{docs/src/moinmoin.txt → doc/docs/moinmoin.rst} +0 -0
  43. data/vendor/pygments-main/{docs/src/plugins.txt → doc/docs/plugins.rst} +0 -0
  44. data/vendor/pygments-main/{docs/src/quickstart.txt → doc/docs/quickstart.rst} +22 -19
  45. data/vendor/pygments-main/{docs/src/rstdirective.txt → doc/docs/rstdirective.rst} +0 -0
  46. data/vendor/pygments-main/{docs/src/styles.txt → doc/docs/styles.rst} +2 -2
  47. data/vendor/pygments-main/{docs/src/tokens.txt → doc/docs/tokens.rst} +10 -7
  48. data/vendor/pygments-main/{docs/src/unicode.txt → doc/docs/unicode.rst} +8 -7
  49. data/vendor/pygments-main/doc/download.rst +41 -0
  50. data/vendor/pygments-main/doc/faq.rst +143 -0
  51. data/vendor/pygments-main/doc/index.rst +53 -0
  52. data/vendor/pygments-main/doc/languages.rst +151 -0
  53. data/vendor/pygments-main/doc/make.bat +190 -0
  54. data/vendor/pygments-main/{docs → doc}/pygmentize.1 +0 -0
  55. data/vendor/pygments-main/external/autopygmentize +65 -48
  56. data/vendor/pygments-main/external/markdown-processor.py +15 -15
  57. data/vendor/pygments-main/external/moin-parser.py +1 -1
  58. data/vendor/pygments-main/external/rst-directive.py +2 -3
  59. data/vendor/pygments-main/ez_setup.py +340 -234
  60. data/vendor/pygments-main/pygments/__init__.py +4 -4
  61. data/vendor/pygments-main/pygments/cmdline.py +81 -68
  62. data/vendor/pygments-main/pygments/console.py +1 -1
  63. data/vendor/pygments-main/pygments/filter.py +1 -1
  64. data/vendor/pygments-main/pygments/filters/__init__.py +11 -9
  65. data/vendor/pygments-main/pygments/formatter.py +3 -3
  66. data/vendor/pygments-main/pygments/formatters/__init__.py +5 -3
  67. data/vendor/pygments-main/pygments/formatters/_mapping.py +16 -5
  68. data/vendor/pygments-main/pygments/formatters/bbcode.py +1 -1
  69. data/vendor/pygments-main/pygments/formatters/html.py +44 -26
  70. data/vendor/pygments-main/pygments/formatters/img.py +21 -14
  71. data/vendor/pygments-main/pygments/formatters/latex.py +104 -12
  72. data/vendor/pygments-main/pygments/formatters/other.py +53 -6
  73. data/vendor/pygments-main/pygments/formatters/rtf.py +30 -16
  74. data/vendor/pygments-main/pygments/formatters/svg.py +2 -2
  75. data/vendor/pygments-main/pygments/formatters/terminal.py +41 -1
  76. data/vendor/pygments-main/pygments/formatters/terminal256.py +2 -2
  77. data/vendor/pygments-main/pygments/lexer.py +59 -39
  78. data/vendor/pygments-main/pygments/lexers/__init__.py +38 -15
  79. data/vendor/pygments-main/pygments/lexers/_asybuiltins.py +1 -1
  80. data/vendor/pygments-main/pygments/lexers/_clbuiltins.py +15 -15
  81. data/vendor/pygments-main/pygments/lexers/_cocoabuiltins.py +73 -0
  82. data/vendor/pygments-main/pygments/lexers/_lassobuiltins.py +11 -1
  83. data/vendor/pygments-main/pygments/lexers/_luabuiltins.py +14 -8
  84. data/vendor/pygments-main/pygments/lexers/_mapping.py +81 -30
  85. data/vendor/pygments-main/pygments/lexers/_openedgebuiltins.py +1 -1
  86. data/vendor/pygments-main/pygments/lexers/_phpbuiltins.py +1067 -95
  87. data/vendor/pygments-main/pygments/lexers/_postgres_builtins.py +7 -7
  88. data/vendor/pygments-main/pygments/lexers/_robotframeworklexer.py +5 -4
  89. data/vendor/pygments-main/pygments/lexers/_scilab_builtins.py +1 -1
  90. data/vendor/pygments-main/pygments/lexers/_sourcemodbuiltins.py +12 -7
  91. data/vendor/pygments-main/pygments/lexers/_stan_builtins.py +112 -18
  92. data/vendor/pygments-main/pygments/lexers/_vimbuiltins.py +1 -1
  93. data/vendor/pygments-main/pygments/lexers/agile.py +644 -382
  94. data/vendor/pygments-main/pygments/lexers/asm.py +66 -29
  95. data/vendor/pygments-main/pygments/lexers/compiled.py +1643 -174
  96. data/vendor/pygments-main/pygments/lexers/dalvik.py +27 -6
  97. data/vendor/pygments-main/pygments/lexers/dotnet.py +45 -33
  98. data/vendor/pygments-main/pygments/lexers/foxpro.py +3 -3
  99. data/vendor/pygments-main/pygments/lexers/functional.py +1510 -570
  100. data/vendor/pygments-main/pygments/lexers/graph.py +81 -0
  101. data/vendor/pygments-main/pygments/lexers/hdl.py +29 -30
  102. data/vendor/pygments-main/pygments/lexers/inferno.py +96 -0
  103. data/vendor/pygments-main/pygments/lexers/jvm.py +622 -207
  104. data/vendor/pygments-main/pygments/lexers/math.py +438 -70
  105. data/vendor/pygments-main/pygments/lexers/other.py +885 -171
  106. data/vendor/pygments-main/pygments/lexers/parsers.py +24 -24
  107. data/vendor/pygments-main/pygments/lexers/qbasic.py +157 -0
  108. data/vendor/pygments-main/pygments/lexers/rdf.py +99 -0
  109. data/vendor/pygments-main/pygments/lexers/shell.py +28 -25
  110. data/vendor/pygments-main/pygments/lexers/special.py +7 -8
  111. data/vendor/pygments-main/pygments/lexers/sql.py +56 -23
  112. data/vendor/pygments-main/pygments/lexers/templates.py +377 -59
  113. data/vendor/pygments-main/pygments/lexers/text.py +208 -46
  114. data/vendor/pygments-main/pygments/lexers/web.py +729 -264
  115. data/vendor/pygments-main/pygments/modeline.py +1 -1
  116. data/vendor/pygments-main/pygments/plugin.py +1 -1
  117. data/vendor/pygments-main/pygments/scanner.py +1 -1
  118. data/vendor/pygments-main/pygments/sphinxext.py +153 -0
  119. data/vendor/pygments-main/pygments/style.py +3 -2
  120. data/vendor/pygments-main/pygments/styles/__init__.py +5 -1
  121. data/vendor/pygments-main/pygments/styles/autumn.py +1 -1
  122. data/vendor/pygments-main/pygments/styles/borland.py +1 -1
  123. data/vendor/pygments-main/pygments/styles/bw.py +1 -1
  124. data/vendor/pygments-main/pygments/styles/colorful.py +1 -1
  125. data/vendor/pygments-main/pygments/styles/default.py +1 -1
  126. data/vendor/pygments-main/pygments/styles/emacs.py +1 -1
  127. data/vendor/pygments-main/pygments/styles/friendly.py +1 -1
  128. data/vendor/pygments-main/pygments/styles/fruity.py +1 -1
  129. data/vendor/pygments-main/pygments/styles/igor.py +29 -0
  130. data/vendor/pygments-main/pygments/styles/manni.py +1 -1
  131. data/vendor/pygments-main/pygments/styles/monokai.py +4 -4
  132. data/vendor/pygments-main/pygments/styles/murphy.py +1 -1
  133. data/vendor/pygments-main/pygments/styles/native.py +1 -1
  134. data/vendor/pygments-main/pygments/styles/paraiso_dark.py +125 -0
  135. data/vendor/pygments-main/pygments/styles/paraiso_light.py +125 -0
  136. data/vendor/pygments-main/pygments/styles/pastie.py +1 -1
  137. data/vendor/pygments-main/pygments/styles/perldoc.py +1 -1
  138. data/vendor/pygments-main/pygments/styles/rrt.py +1 -1
  139. data/vendor/pygments-main/pygments/styles/tango.py +1 -1
  140. data/vendor/pygments-main/pygments/styles/trac.py +1 -1
  141. data/vendor/pygments-main/pygments/styles/vim.py +1 -1
  142. data/vendor/pygments-main/pygments/styles/vs.py +1 -1
  143. data/vendor/pygments-main/pygments/styles/xcode.py +51 -0
  144. data/vendor/pygments-main/pygments/token.py +4 -1
  145. data/vendor/pygments-main/pygments/unistring.py +6 -5
  146. data/vendor/pygments-main/pygments/util.py +35 -21
  147. data/vendor/pygments-main/scripts/check_sources.py +28 -44
  148. data/vendor/pygments-main/scripts/detect_missing_analyse_text.py +5 -4
  149. data/vendor/pygments-main/scripts/find_codetags.py +27 -19
  150. data/vendor/pygments-main/scripts/find_error.py +16 -13
  151. data/vendor/pygments-main/scripts/get_vimkw.py +3 -3
  152. data/vendor/pygments-main/scripts/vim2pygments.py +9 -7
  153. data/vendor/pygments-main/setup.py +19 -19
  154. data/vendor/pygments-main/tests/examplefiles/99_bottles_of_beer.chpl +118 -0
  155. data/vendor/pygments-main/tests/examplefiles/Error.pmod +38 -0
  156. data/vendor/pygments-main/tests/examplefiles/FakeFile.pike +360 -0
  157. data/vendor/pygments-main/tests/examplefiles/{ANTLRv3.g → antlr_ANTLRv3.g} +0 -0
  158. data/vendor/pygments-main/tests/examplefiles/clojure-weird-keywords.clj +5 -0
  159. data/vendor/pygments-main/tests/examplefiles/core.cljs +52 -0
  160. data/vendor/pygments-main/tests/examplefiles/demo.cfm +13 -1
  161. data/vendor/pygments-main/tests/examplefiles/demo.hbs +12 -0
  162. data/vendor/pygments-main/tests/examplefiles/ember.handlebars +33 -0
  163. data/vendor/pygments-main/tests/examplefiles/example.als +217 -0
  164. data/vendor/pygments-main/tests/examplefiles/example.c +1 -1
  165. data/vendor/pygments-main/tests/examplefiles/example.chai +6 -0
  166. data/vendor/pygments-main/tests/examplefiles/example.coffee +27 -0
  167. data/vendor/pygments-main/tests/examplefiles/example.e +124 -0
  168. data/vendor/pygments-main/tests/examplefiles/example.f90 +8 -0
  169. data/vendor/pygments-main/tests/examplefiles/example.feature +16 -0
  170. data/vendor/pygments-main/tests/examplefiles/example.gd +23 -0
  171. data/vendor/pygments-main/tests/examplefiles/example.gi +64 -0
  172. data/vendor/pygments-main/tests/examplefiles/example.groovy +2 -0
  173. data/vendor/pygments-main/tests/examplefiles/example.hs +27 -0
  174. data/vendor/pygments-main/tests/examplefiles/example.hx +44 -1
  175. data/vendor/pygments-main/tests/examplefiles/example.i6t +32 -0
  176. data/vendor/pygments-main/tests/examplefiles/example.i7x +45 -0
  177. data/vendor/pygments-main/tests/examplefiles/example.inf +374 -0
  178. data/vendor/pygments-main/tests/examplefiles/example.j +564 -0
  179. data/vendor/pygments-main/tests/examplefiles/example.java +16 -0
  180. data/vendor/pygments-main/tests/examplefiles/example.kal +75 -0
  181. data/vendor/pygments-main/tests/examplefiles/example.liquid +42 -0
  182. data/vendor/pygments-main/tests/examplefiles/example.ma +8 -0
  183. data/vendor/pygments-main/tests/examplefiles/example.mq4 +187 -0
  184. data/vendor/pygments-main/tests/examplefiles/example.mqh +123 -0
  185. data/vendor/pygments-main/tests/examplefiles/example.ni +57 -0
  186. data/vendor/pygments-main/tests/examplefiles/example.nix +80 -0
  187. data/vendor/pygments-main/tests/examplefiles/example.pp +8 -0
  188. data/vendor/pygments-main/tests/examplefiles/example.red +257 -0
  189. data/vendor/pygments-main/tests/examplefiles/example.reds +150 -0
  190. data/vendor/pygments-main/tests/examplefiles/example.rkt +677 -29
  191. data/vendor/pygments-main/tests/examplefiles/example.sh +22 -0
  192. data/vendor/pygments-main/tests/examplefiles/example.slim +31 -0
  193. data/vendor/pygments-main/tests/examplefiles/example.sls +51 -0
  194. data/vendor/pygments-main/tests/examplefiles/example.stan +2 -0
  195. data/vendor/pygments-main/tests/examplefiles/example.todotxt +9 -0
  196. data/vendor/pygments-main/tests/examplefiles/exampleScript.cfc +241 -0
  197. data/vendor/pygments-main/tests/examplefiles/exampleTag.cfc +18 -0
  198. data/vendor/pygments-main/tests/examplefiles/example_elixir.ex +192 -350
  199. data/vendor/pygments-main/tests/examplefiles/hash_syntax.rb +5 -0
  200. data/vendor/pygments-main/tests/examplefiles/hello.at +6 -0
  201. data/vendor/pygments-main/tests/examplefiles/hello.golo +5 -0
  202. data/vendor/pygments-main/tests/examplefiles/hello.lsl +12 -0
  203. data/vendor/pygments-main/tests/examplefiles/{File.hy → hybris_File.hy} +0 -0
  204. data/vendor/pygments-main/tests/examplefiles/{mg_sample.pro → idl_sample.pro} +0 -0
  205. data/vendor/pygments-main/tests/examplefiles/iex_example +23 -0
  206. data/vendor/pygments-main/tests/examplefiles/inet_pton6.dg +24 -24
  207. data/vendor/pygments-main/tests/examplefiles/language.hy +165 -0
  208. data/vendor/pygments-main/tests/examplefiles/limbo.b +456 -0
  209. data/vendor/pygments-main/tests/examplefiles/livescript-demo.ls +3 -1
  210. data/vendor/pygments-main/tests/examplefiles/main.cmake +2 -0
  211. data/vendor/pygments-main/tests/examplefiles/objc_example.m +163 -16
  212. data/vendor/pygments-main/tests/examplefiles/{example.p → openedge_example} +0 -0
  213. data/vendor/pygments-main/tests/examplefiles/pawn_example +25 -0
  214. data/vendor/pygments-main/tests/examplefiles/qbasic_example +2 -0
  215. data/vendor/pygments-main/tests/examplefiles/r6rs-comments.scm +23 -0
  216. data/vendor/pygments-main/tests/examplefiles/{robotframework.txt → robotframework_test.txt} +0 -0
  217. data/vendor/pygments-main/tests/examplefiles/rql-queries.rql +34 -0
  218. data/vendor/pygments-main/tests/examplefiles/scope.cirru +43 -0
  219. data/vendor/pygments-main/tests/examplefiles/sparql.rq +23 -0
  220. data/vendor/pygments-main/tests/examplefiles/test.R +37 -5
  221. data/vendor/pygments-main/tests/examplefiles/test.apl +26 -0
  222. data/vendor/pygments-main/tests/examplefiles/test.cyp +123 -0
  223. data/vendor/pygments-main/tests/examplefiles/test.idr +93 -0
  224. data/vendor/pygments-main/tests/examplefiles/test.mask +41 -0
  225. data/vendor/pygments-main/tests/examplefiles/test.pan +54 -0
  226. data/vendor/pygments-main/tests/examplefiles/test.php +3 -1
  227. data/vendor/pygments-main/tests/examplefiles/test.pig +148 -0
  228. data/vendor/pygments-main/tests/examplefiles/test.pwn +253 -0
  229. data/vendor/pygments-main/tests/examplefiles/test.r3 +27 -7
  230. data/vendor/pygments-main/tests/examplefiles/test.rsl +111 -0
  231. data/vendor/pygments-main/tests/examplefiles/test.swift +65 -0
  232. data/vendor/pygments-main/tests/examplefiles/test.zep +33 -0
  233. data/vendor/pygments-main/tests/examplefiles/unicode.go +10 -0
  234. data/vendor/pygments-main/tests/examplefiles/{test.bas → vbnet_test.bas} +0 -0
  235. data/vendor/pygments-main/tests/examplefiles/vctreestatus_hg +4 -0
  236. data/vendor/pygments-main/tests/examplefiles/vimrc +21 -0
  237. data/vendor/pygments-main/tests/run.py +14 -19
  238. data/vendor/pygments-main/tests/string_asserts.py +22 -0
  239. data/vendor/pygments-main/tests/test_basic_api.py +28 -14
  240. data/vendor/pygments-main/tests/test_cfm.py +46 -0
  241. data/vendor/pygments-main/tests/test_clexer.py +208 -3
  242. data/vendor/pygments-main/tests/test_cmdline.py +6 -5
  243. data/vendor/pygments-main/tests/test_examplefiles.py +30 -19
  244. data/vendor/pygments-main/tests/test_html_formatter.py +15 -13
  245. data/vendor/pygments-main/tests/test_latex_formatter.py +4 -2
  246. data/vendor/pygments-main/tests/test_lexers_other.py +11 -11
  247. data/vendor/pygments-main/tests/test_objectiveclexer.py +81 -0
  248. data/vendor/pygments-main/tests/test_perllexer.py +1 -1
  249. data/vendor/pygments-main/tests/test_qbasiclexer.py +43 -0
  250. data/vendor/pygments-main/tests/test_regexlexer.py +8 -1
  251. data/vendor/pygments-main/tests/test_rtf_formatter.py +109 -0
  252. data/vendor/pygments-main/tests/test_string_asserts.py +39 -0
  253. data/vendor/pygments-main/tests/test_token.py +3 -3
  254. data/vendor/pygments-main/tests/test_using_api.py +1 -1
  255. data/vendor/pygments-main/tests/test_util.py +1 -1
  256. metadata +138 -51
  257. data/vendor/pygments-main/docs/generate.py +0 -472
  258. data/vendor/pygments-main/docs/src/api.txt +0 -270
  259. data/vendor/pygments-main/docs/src/authors.txt +0 -5
  260. data/vendor/pygments-main/docs/src/changelog.txt +0 -5
  261. data/vendor/pygments-main/docs/src/index.txt +0 -69
  262. data/vendor/pygments-main/docs/src/installation.txt +0 -71
  263. data/vendor/pygments-main/external/rst-directive-old.py +0 -77
  264. data/vendor/pygments-main/scripts/reindent.py +0 -291
  265. data/vendor/pygments-main/tests/examplefiles/import.hs +0 -4
  266. data/vendor/pygments-main/tests/examplefiles/objc_example2.m +0 -24
  267. data/vendor/pygments-main/tests/old_run.py +0 -138
@@ -1,270 +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
- Functions from the `pygments` module:
13
-
14
- def `lex(code, lexer):`
15
- Lex `code` with the `lexer` (must be a `Lexer` instance)
16
- and return an iterable of tokens. Currently, this only calls
17
- `lexer.get_tokens()`.
18
-
19
- def `format(tokens, formatter, outfile=None):`
20
- Format a token stream (iterable of tokens) `tokens` with the
21
- `formatter` (must be a `Formatter` instance). The result is
22
- written to `outfile`, or if that is ``None``, returned as a
23
- string.
24
-
25
- def `highlight(code, lexer, formatter, outfile=None):`
26
- This is the most high-level highlighting function.
27
- It combines `lex` and `format` in one function.
28
-
29
-
30
- Functions from `pygments.lexers`:
31
-
32
- def `get_lexer_by_name(alias, **options):`
33
- Return an instance of a `Lexer` subclass that has `alias` in its
34
- aliases list. The lexer is given the `options` at its
35
- instantiation.
36
-
37
- Will raise `pygments.util.ClassNotFound` if no lexer with that alias is
38
- found.
39
-
40
- def `get_lexer_for_filename(fn, **options):`
41
- Return a `Lexer` subclass instance that has a filename pattern
42
- matching `fn`. The lexer is given the `options` at its
43
- instantiation.
44
-
45
- Will raise `pygments.util.ClassNotFound` if no lexer for that filename is
46
- found.
47
-
48
- def `get_lexer_for_mimetype(mime, **options):`
49
- Return a `Lexer` subclass instance that has `mime` in its mimetype
50
- list. The lexer is given the `options` at its instantiation.
51
-
52
- Will raise `pygments.util.ClassNotFound` if not lexer for that mimetype is
53
- found.
54
-
55
- def `guess_lexer(text, **options):`
56
- Return a `Lexer` subclass instance that's guessed from the text
57
- in `text`. For that, the `analyse_text()` method of every known
58
- lexer class is called with the text as argument, and the lexer
59
- which returned the highest value will be instantiated and returned.
60
-
61
- `pygments.util.ClassNotFound` is raised if no lexer thinks it can handle the
62
- content.
63
-
64
- def `guess_lexer_for_filename(filename, text, **options):`
65
- As `guess_lexer()`, but only lexers which have a pattern in `filenames`
66
- or `alias_filenames` that matches `filename` are taken into consideration.
67
-
68
- `pygments.util.ClassNotFound` is raised if no lexer thinks it can handle the
69
- content.
70
-
71
- def `get_all_lexers():`
72
- Return an iterable over all registered lexers, yielding tuples in the
73
- format::
74
-
75
- (longname, tuple of aliases, tuple of filename patterns, tuple of mimetypes)
76
-
77
- *New in Pygments 0.6.*
78
-
79
-
80
- Functions from `pygments.formatters`:
81
-
82
- def `get_formatter_by_name(alias, **options):`
83
- Return an instance of a `Formatter` subclass that has `alias` in its
84
- aliases list. The formatter is given the `options` at its
85
- instantiation.
86
-
87
- Will raise `pygments.util.ClassNotFound` if no formatter with that alias is
88
- found.
89
-
90
- def `get_formatter_for_filename(fn, **options):`
91
- Return a `Formatter` subclass instance that has a filename pattern
92
- matching `fn`. The formatter is given the `options` at its
93
- instantiation.
94
-
95
- Will raise `pygments.util.ClassNotFound` if no formatter for that filename
96
- is found.
97
-
98
-
99
- Functions from `pygments.styles`:
100
-
101
- def `get_style_by_name(name):`
102
- Return a style class by its short name. The names of the builtin styles
103
- are listed in `pygments.styles.STYLE_MAP`.
104
-
105
- Will raise `pygments.util.ClassNotFound` if no style of that name is found.
106
-
107
- def `get_all_styles():`
108
- Return an iterable over all registered styles, yielding their names.
109
-
110
- *New in Pygments 0.6.*
111
-
112
-
113
- Lexers
114
- ======
115
-
116
- A lexer (derived from `pygments.lexer.Lexer`) has the following functions:
117
-
118
- def `__init__(self, **options):`
119
- The constructor. Takes a \*\*keywords dictionary of options.
120
- Every subclass must first process its own options and then call
121
- the `Lexer` constructor, since it processes the `stripnl`,
122
- `stripall` and `tabsize` options.
123
-
124
- An example looks like this:
125
-
126
- .. sourcecode:: python
127
-
128
- def __init__(self, **options):
129
- self.compress = options.get('compress', '')
130
- Lexer.__init__(self, **options)
131
-
132
- As these options must all be specifiable as strings (due to the
133
- command line usage), there are various utility functions
134
- available to help with that, see `Option processing`_.
135
-
136
- def `get_tokens(self, text):`
137
- This method is the basic interface of a lexer. It is called by
138
- the `highlight()` function. It must process the text and return an
139
- iterable of ``(tokentype, value)`` pairs from `text`.
140
-
141
- Normally, you don't need to override this method. The default
142
- implementation processes the `stripnl`, `stripall` and `tabsize`
143
- options and then yields all tokens from `get_tokens_unprocessed()`,
144
- with the ``index`` dropped.
145
-
146
- def `get_tokens_unprocessed(self, text):`
147
- This method should process the text and return an iterable of
148
- ``(index, tokentype, value)`` tuples where ``index`` is the starting
149
- position of the token within the input text.
150
-
151
- This method must be overridden by subclasses.
152
-
153
- def `analyse_text(text):`
154
- A static method which is called for lexer guessing. It should analyse
155
- the text and return a float in the range from ``0.0`` to ``1.0``.
156
- If it returns ``0.0``, the lexer will not be selected as the most
157
- probable one, if it returns ``1.0``, it will be selected immediately.
158
-
159
- For a list of known tokens have a look at the `Tokens`_ page.
160
-
161
- A lexer also can have the following attributes (in fact, they are mandatory
162
- except `alias_filenames`) that are used by the builtin lookup mechanism.
163
-
164
- `name`
165
- Full name for the lexer, in human-readable form.
166
-
167
- `aliases`
168
- A list of short, unique identifiers that can be used to lookup
169
- the lexer from a list, e.g. using `get_lexer_by_name()`.
170
-
171
- `filenames`
172
- A list of `fnmatch` patterns that match filenames which contain
173
- content for this lexer. The patterns in this list should be unique among
174
- all lexers.
175
-
176
- `alias_filenames`
177
- A list of `fnmatch` patterns that match filenames which may or may not
178
- contain content for this lexer. This list is used by the
179
- `guess_lexer_for_filename()` function, to determine which lexers are
180
- then included in guessing the correct one. That means that e.g. every
181
- lexer for HTML and a template language should include ``\*.html`` in
182
- this list.
183
-
184
- `mimetypes`
185
- A list of MIME types for content that can be lexed with this
186
- lexer.
187
-
188
-
189
- .. _Tokens: tokens.txt
190
-
191
-
192
- Formatters
193
- ==========
194
-
195
- A formatter (derived from `pygments.formatter.Formatter`) has the following
196
- functions:
197
-
198
- def `__init__(self, **options):`
199
- As with lexers, this constructor processes options and then must call
200
- the base class `__init__`.
201
-
202
- The `Formatter` class recognizes the options `style`, `full` and
203
- `title`. It is up to the formatter class whether it uses them.
204
-
205
- def `get_style_defs(self, arg=''):`
206
- This method must return statements or declarations suitable to define
207
- the current style for subsequent highlighted text (e.g. CSS classes
208
- in the `HTMLFormatter`).
209
-
210
- The optional argument `arg` can be used to modify the generation and
211
- is formatter dependent (it is standardized because it can be given on
212
- the command line).
213
-
214
- This method is called by the ``-S`` `command-line option`_, the `arg`
215
- is then given by the ``-a`` option.
216
-
217
- def `format(self, tokensource, outfile):`
218
- This method must format the tokens from the `tokensource` iterable and
219
- write the formatted version to the file object `outfile`.
220
-
221
- Formatter options can control how exactly the tokens are converted.
222
-
223
- .. _command-line option: cmdline.txt
224
-
225
- A formatter must have the following attributes that are used by the
226
- builtin lookup mechanism. (*New in Pygments 0.7.*)
227
-
228
- `name`
229
- Full name for the formatter, in human-readable form.
230
-
231
- `aliases`
232
- A list of short, unique identifiers that can be used to lookup
233
- the formatter from a list, e.g. using `get_formatter_by_name()`.
234
-
235
- `filenames`
236
- A list of `fnmatch` patterns that match filenames for which this formatter
237
- can produce output. The patterns in this list should be unique among
238
- all formatters.
239
-
240
-
241
- Option processing
242
- =================
243
-
244
- The `pygments.util` module has some utility functions usable for option
245
- processing:
246
-
247
- class `OptionError`
248
- This exception will be raised by all option processing functions if
249
- the type or value of the argument is not correct.
250
-
251
- def `get_bool_opt(options, optname, default=None):`
252
- Interpret the key `optname` from the dictionary `options`
253
- as a boolean and return it. Return `default` if `optname`
254
- is not in `options`.
255
-
256
- The valid string values for ``True`` are ``1``, ``yes``,
257
- ``true`` and ``on``, the ones for ``False`` are ``0``,
258
- ``no``, ``false`` and ``off`` (matched case-insensitively).
259
-
260
- def `get_int_opt(options, optname, default=None):`
261
- As `get_bool_opt`, but interpret the value as an integer.
262
-
263
- def `get_list_opt(options, optname, default=None):`
264
- If the key `optname` from the dictionary `options` is a string,
265
- split it at whitespace and return it. If it is already a list
266
- or a tuple, it is returned as a list.
267
-
268
- def `get_choice_opt(options, optname, allowed, default=None):`
269
- If the key `optname` from the dictionary is not in the sequence
270
- `allowed`, raise an error, otherwise return it. *New in Pygments 0.8.*
@@ -1,5 +0,0 @@
1
- =======
2
- Authors
3
- =======
4
-
5
- [authors]
@@ -1,5 +0,0 @@
1
- =========
2
- Changelog
3
- =========
4
-
5
- [changelog]
@@ -1,69 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- ========
4
- Overview
5
- ========
6
-
7
- Welcome to the Pygments documentation.
8
-
9
- - Starting with Pygments
10
-
11
- - `Installation <installation.txt>`_
12
-
13
- - `Introduction and Quickstart <quickstart.txt>`_
14
-
15
- - `Command line interface <cmdline.txt>`_
16
-
17
- - Builtin components
18
-
19
- - `Lexers <lexers.txt>`_
20
-
21
- - `Formatters <formatters.txt>`_
22
-
23
- - `Filters <filters.txt>`_
24
-
25
- - `Styles <styles.txt>`_
26
-
27
- - Reference
28
-
29
- - `Unicode and encodings <unicode.txt>`_
30
-
31
- - `Builtin tokens <tokens.txt>`_
32
-
33
- - `API documentation <api.txt>`_
34
-
35
- - Hacking for Pygments
36
-
37
- - `Write your own lexer <lexerdevelopment.txt>`_
38
-
39
- - `Write your own formatter <formatterdevelopment.txt>`_
40
-
41
- - `Write your own filter <filterdevelopment.txt>`_
42
-
43
- - `Register plugins <plugins.txt>`_
44
-
45
- - Hints and Tricks
46
-
47
- - `Using Pygments in ReST documents <rstdirective.txt>`_
48
-
49
- - `Using Pygments with MoinMoin <moinmoin.txt>`_
50
-
51
- - `Using Pygments in other contexts <integrate.txt>`_
52
-
53
- - About Pygments
54
-
55
- - `Changelog <changelog.txt>`_
56
-
57
- - `Authors <authors.txt>`_
58
-
59
-
60
- --------------
61
-
62
- If you find bugs or have suggestions for the documentation, please
63
- look `here`_ for info on how to contact the team.
64
-
65
- You can download an offline version of this documentation from the
66
- `download page`_.
67
-
68
- .. _here: http://pygments.org/contribute/
69
- .. _download page: http://pygments.org/download/
@@ -1,71 +0,0 @@
1
- .. -*- mode: rst -*-
2
-
3
- ============
4
- Installation
5
- ============
6
-
7
- Pygments requires at least Python 2.4 to work correctly. Just to clarify:
8
- there *won't* ever be support for Python versions below 2.4. However, there
9
- are no other dependencies.
10
-
11
-
12
- Installing a released version
13
- =============================
14
-
15
- As a Python egg (via easy_install)
16
- ----------------------------------
17
-
18
- You can install the most recent Pygments version using `easy_install`_::
19
-
20
- sudo easy_install Pygments
21
-
22
- This will install a Pygments egg in your Python installation's site-packages
23
- directory.
24
-
25
-
26
- From the tarball release
27
- -------------------------
28
-
29
- 1. Download the most recent tarball from the `download page`_
30
- 2. Unpack the tarball
31
- 3. ``sudo python setup.py install``
32
-
33
- Note that the last command will automatically download and install
34
- `setuptools`_ if you don't already have it installed. This requires a working
35
- internet connection.
36
-
37
- This will install Pygments into your Python installation's site-packages directory.
38
-
39
-
40
- Installing the development version
41
- ==================================
42
-
43
- If you want to play around with the code
44
- ----------------------------------------
45
-
46
- 1. Install `Mercurial`_
47
- 2. ``hg clone http://bitbucket.org/birkenfeld/pygments-main pygments``
48
- 3. ``cd pygments``
49
- 4. ``ln -s pygments /usr/lib/python2.X/site-packages``
50
- 5. ``ln -s pygmentize /usr/local/bin``
51
-
52
- As an alternative to steps 4 and 5 you can also do ``python setup.py develop``
53
- which will install the package via setuptools in development mode.
54
-
55
- ..
56
- If you just want the latest features and use them
57
- -------------------------------------------------
58
-
59
- ::
60
-
61
- sudo easy_install Pygments==dev
62
-
63
- This will install a Pygments egg containing the latest Subversion trunk code
64
- in your Python installation's site-packages directory. Every time the command
65
- is run, the sources are updated from Subversion.
66
-
67
-
68
- .. _download page: http://pygments.org/download/
69
- .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools
70
- .. _easy_install: http://peak.telecommunity.com/DevCenter/EasyInstall
71
- .. _Mercurial: http://selenic.com/mercurial/
@@ -1,77 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- The Pygments reStructuredText directive
4
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
-
6
- This fragment is a Docutils_ 0.4 directive that renders source code
7
- (to HTML only, currently) via Pygments.
8
-
9
- To use it, adjust the options below and copy the code into a module
10
- that you import on initialization. The code then automatically
11
- registers a ``sourcecode`` directive that you can use instead of
12
- normal code blocks like this::
13
-
14
- .. sourcecode:: python
15
-
16
- My code goes here.
17
-
18
- If you want to have different code styles, e.g. one with line numbers
19
- and one without, add formatters with their names in the VARIANTS dict
20
- below. You can invoke them instead of the DEFAULT one by using a
21
- directive option::
22
-
23
- .. sourcecode:: python
24
- :linenos:
25
-
26
- My code goes here.
27
-
28
- Look at the `directive documentation`_ to get all the gory details.
29
-
30
- .. _Docutils: http://docutils.sf.net/
31
- .. _directive documentation:
32
- http://docutils.sourceforge.net/docs/howto/rst-directives.html
33
-
34
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
35
- :license: BSD, see LICENSE for details.
36
- """
37
-
38
- # Options
39
- # ~~~~~~~
40
-
41
- # Set to True if you want inline CSS styles instead of classes
42
- INLINESTYLES = False
43
-
44
- from pygments.formatters import HtmlFormatter
45
-
46
- # The default formatter
47
- DEFAULT = HtmlFormatter(noclasses=INLINESTYLES)
48
-
49
- # Add name -> formatter pairs for every variant you want to use
50
- VARIANTS = {
51
- # 'linenos': HtmlFormatter(noclasses=INLINESTYLES, linenos=True),
52
- }
53
-
54
-
55
- from docutils import nodes
56
- from docutils.parsers.rst import directives
57
-
58
- from pygments import highlight
59
- from pygments.lexers import get_lexer_by_name, TextLexer
60
-
61
- def pygments_directive(name, arguments, options, content, lineno,
62
- content_offset, block_text, state, state_machine):
63
- try:
64
- lexer = get_lexer_by_name(arguments[0])
65
- except ValueError:
66
- # no lexer found - use the text one instead of an exception
67
- lexer = TextLexer()
68
- # take an arbitrary option if more than one is given
69
- formatter = options and VARIANTS[options.keys()[0]] or DEFAULT
70
- parsed = highlight(u'\n'.join(content), lexer, formatter)
71
- return [nodes.raw('', parsed, format='html')]
72
-
73
- pygments_directive.arguments = (1, 0, 1)
74
- pygments_directive.content = 1
75
- pygments_directive.options = dict([(key, directives.flag) for key in VARIANTS])
76
-
77
- directives.register_directive('sourcecode', pygments_directive)