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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for various shells.
7
7
 
8
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -27,13 +27,13 @@ class BashLexer(RegexLexer):
27
27
  """
28
28
  Lexer for (ba|k|)sh shell scripts.
29
29
 
30
- *New in Pygments 0.6.*
30
+ .. versionadded:: 0.6
31
31
  """
32
32
 
33
33
  name = 'Bash'
34
34
  aliases = ['bash', 'sh', 'ksh']
35
35
  filenames = ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass',
36
- '.bashrc', 'bashrc', '.bash_*', 'bash_*']
36
+ '.bashrc', 'bashrc', '.bash_*', 'bash_*', 'PKGBUILD']
37
37
  mimetypes = ['application/x-sh', 'application/x-shellscript']
38
38
 
39
39
  tokens = {
@@ -47,8 +47,8 @@ class BashLexer(RegexLexer):
47
47
  ],
48
48
  'basic': [
49
49
  (r'\b(if|fi|else|while|do|done|for|then|return|function|case|'
50
- r'select|continue|until|esac|elif)\s*\b',
51
- Keyword),
50
+ r'select|continue|until|esac|elif)(\s*)\b',
51
+ bygroups(Keyword, Text)),
52
52
  (r'\b(alias|bg|bind|break|builtin|caller|cd|command|compgen|'
53
53
  r'complete|declare|dirs|disown|echo|enable|eval|exec|exit|'
54
54
  r'export|false|fc|fg|getopts|hash|help|history|jobs|kill|let|'
@@ -71,15 +71,15 @@ class BashLexer(RegexLexer):
71
71
  (r'&', Punctuation),
72
72
  (r'\|', Punctuation),
73
73
  (r'\s+', Text),
74
- (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
75
74
  (r'\d+(?= |\Z)', Number),
75
+ (r'[^=\s\[\]{}()$"\'`\\<&|;]+', Text),
76
76
  (r'\$#?(\w+|.)', Name.Variable),
77
77
  (r'<', Text),
78
78
  ],
79
79
  'curly': [
80
80
  (r'}', Keyword, '#pop'),
81
81
  (r':-', Keyword),
82
- (r'[a-zA-Z0-9_]+', Name.Variable),
82
+ (r'\w+', Name.Variable),
83
83
  (r'[^}:"\'`$]+', Punctuation),
84
84
  (r':', Punctuation),
85
85
  include('root'),
@@ -91,6 +91,8 @@ class BashLexer(RegexLexer):
91
91
  'math': [
92
92
  (r'\)\)', Keyword, '#pop'),
93
93
  (r'[-+*/%^|&]|\*\*|\|\|', Operator),
94
+ (r'\d+#\d+', Number),
95
+ (r'\d+#(?! )', Number),
94
96
  (r'\d+', Number),
95
97
  include('root'),
96
98
  ],
@@ -111,7 +113,7 @@ class BashSessionLexer(Lexer):
111
113
  """
112
114
  Lexer for simplistic shell sessions.
113
115
 
114
- *New in Pygments 1.1.*
116
+ .. versionadded:: 1.1
115
117
  """
116
118
 
117
119
  name = 'Bash Session'
@@ -162,7 +164,7 @@ class ShellSessionLexer(Lexer):
162
164
  """
163
165
  Lexer for shell sessions that works with different command prompts
164
166
 
165
- *New in Pygments 1.6.*
167
+ .. versionadded:: 1.6
166
168
  """
167
169
 
168
170
  name = 'Shell Session'
@@ -179,7 +181,7 @@ class ShellSessionLexer(Lexer):
179
181
 
180
182
  for match in line_re.finditer(text):
181
183
  line = match.group()
182
- m = re.match(r'^((?:\[?\S+@[^$#%]+)[$#%])(.*\n?)', line)
184
+ m = re.match(r'^((?:\[?\S+@[^$#%]+\]?\s*)[$#%])(.*\n?)', line)
183
185
  if m:
184
186
  # To support output lexers (say diff output), the output
185
187
  # needs to be broken by prompts whenever the output lexer
@@ -208,10 +210,10 @@ class BatchLexer(RegexLexer):
208
210
  """
209
211
  Lexer for the DOS/Windows Batch file format.
210
212
 
211
- *New in Pygments 0.7.*
213
+ .. versionadded:: 0.7
212
214
  """
213
215
  name = 'Batchfile'
214
- aliases = ['bat', 'dosbatch', 'winbatch']
216
+ aliases = ['bat', 'batch', 'dosbatch', 'winbatch']
215
217
  filenames = ['*.bat', '*.cmd']
216
218
  mimetypes = ['application/x-dos-batch']
217
219
 
@@ -228,9 +230,9 @@ class BatchLexer(RegexLexer):
228
230
  # like %~$VAR:zlt
229
231
  (r'%%?[~$:\w]+%?', Name.Variable),
230
232
  (r'::.*', Comment), # Technically :: only works at BOL
231
- (r'(set)(\s+)(\w+)', bygroups(Keyword, Text, Name.Variable)),
232
- (r'(call)(\s+)(:\w+)', bygroups(Keyword, Text, Name.Label)),
233
- (r'(goto)(\s+)(\w+)', bygroups(Keyword, Text, Name.Label)),
233
+ (r'\b(set)(\s+)(\w+)', bygroups(Keyword, Text, Name.Variable)),
234
+ (r'\b(call)(\s+)(:\w+)', bygroups(Keyword, Text, Name.Label)),
235
+ (r'\b(goto)(\s+)(\w+)', bygroups(Keyword, Text, Name.Label)),
234
236
  (r'\b(set|call|echo|on|off|endlocal|for|do|goto|if|pause|'
235
237
  r'setlocal|shift|errorlevel|exist|defined|cmdextversion|'
236
238
  r'errorlevel|else|cd|md|del|deltree|cls|choice)\b', Keyword),
@@ -264,7 +266,7 @@ class TcshLexer(RegexLexer):
264
266
  """
265
267
  Lexer for tcsh scripts.
266
268
 
267
- *New in Pygments 0.10.*
269
+ .. versionadded:: 0.10
268
270
  """
269
271
 
270
272
  name = 'Tcsh'
@@ -294,24 +296,25 @@ class TcshLexer(RegexLexer):
294
296
  r'umask|unalias|uncomplete|unhash|universe|unlimit|unset|unsetenv|'
295
297
  r'ver|wait|warp|watchlog|where|which)\s*\b',
296
298
  Name.Builtin),
297
- (r'#.*\n', Comment),
299
+ (r'#.*', Comment),
298
300
  (r'\\[\w\W]', String.Escape),
299
301
  (r'(\b\w+)(\s*)(=)', bygroups(Name.Variable, Text, Operator)),
300
302
  (r'[\[\]{}()=]+', Operator),
301
303
  (r'<<\s*(\'?)\\?(\w+)[\w\W]+?\2', String),
304
+ (r';', Punctuation),
302
305
  ],
303
306
  'data': [
304
307
  (r'(?s)"(\\\\|\\[0-7]+|\\.|[^"\\])*"', String.Double),
305
308
  (r"(?s)'(\\\\|\\[0-7]+|\\.|[^'\\])*'", String.Single),
306
309
  (r'\s+', Text),
307
- (r'[^=\s\[\]{}()$"\'`\\]+', Text),
310
+ (r'[^=\s\[\]{}()$"\'`\\;#]+', Text),
308
311
  (r'\d+(?= |\Z)', Number),
309
312
  (r'\$#?(\w+|.)', Name.Variable),
310
313
  ],
311
314
  'curly': [
312
315
  (r'}', Keyword, '#pop'),
313
316
  (r':-', Keyword),
314
- (r'[a-zA-Z0-9_]+', Name.Variable),
317
+ (r'\w+', Name.Variable),
315
318
  (r'[^}:"\'`$]+', Punctuation),
316
319
  (r':', Punctuation),
317
320
  include('root'),
@@ -331,7 +334,7 @@ class PowerShellLexer(RegexLexer):
331
334
  """
332
335
  For Windows PowerShell code.
333
336
 
334
- *New in Pygments 1.5.*
337
+ .. versionadded:: 1.5
335
338
  """
336
339
  name = 'PowerShell'
337
340
  aliases = ['powershell', 'posh', 'ps1', 'psm1']
@@ -387,13 +390,13 @@ class PowerShellLexer(RegexLexer):
387
390
  (r'`[\'"$@-]', Punctuation),
388
391
  (r'"', String.Double, 'string'),
389
392
  (r"'([^']|'')*'", String.Single),
390
- (r'(\$|@@|@)((global|script|private|env):)?[a-z0-9_]+',
393
+ (r'(\$|@@|@)((global|script|private|env):)?\w+',
391
394
  Name.Variable),
392
395
  (r'(%s)\b' % '|'.join(keywords), Keyword),
393
396
  (r'-(%s)\b' % '|'.join(operators), Operator),
394
- (r'(%s)-[a-z_][a-z0-9_]*\b' % '|'.join(verbs), Name.Builtin),
395
- (r'\[[a-z_\[][a-z0-9_. `,\[\]]*\]', Name.Constant), # .net [type]s
396
- (r'-[a-z_][a-z0-9_]*', Name),
397
+ (r'(%s)-[a-z_]\w*\b' % '|'.join(verbs), Name.Builtin),
398
+ (r'\[[a-z_\[][\w. `,\[\]]*\]', Name.Constant), # .net [type]s
399
+ (r'-[a-z_]\w*', Name),
397
400
  (r'\w+', Name),
398
401
  (r'[.,;@{}\[\]$()=+*/\\&%!~?^`|<>-]|::', Punctuation),
399
402
  ],
@@ -408,7 +411,7 @@ class PowerShellLexer(RegexLexer):
408
411
  (r'[#&.]', Comment.Multiline),
409
412
  ],
410
413
  'string': [
411
- (r"`[0abfnrtv'\"\$]", String.Escape),
414
+ (r"`[0abfnrtv'\"\$`]", String.Escape),
412
415
  (r'[^$`"]+', String.Double),
413
416
  (r'\$\(', Punctuation, 'child'),
414
417
  (r'""', String.Double),
@@ -5,16 +5,15 @@
5
5
 
6
6
  Special lexers.
7
7
 
8
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
12
12
  import re
13
- import cStringIO
14
13
 
15
14
  from pygments.lexer import Lexer
16
15
  from pygments.token import Token, Error, Text
17
- from pygments.util import get_choice_opt, b
16
+ from pygments.util import get_choice_opt, text_type, BytesIO
18
17
 
19
18
 
20
19
  __all__ = ['TextLexer', 'RawTokenLexer']
@@ -35,7 +34,7 @@ class TextLexer(Lexer):
35
34
 
36
35
  _ttype_cache = {}
37
36
 
38
- line_re = re.compile(b('.*?\n'))
37
+ line_re = re.compile(b'.*?\n')
39
38
 
40
39
  class RawTokenLexer(Lexer):
41
40
  """
@@ -60,12 +59,12 @@ class RawTokenLexer(Lexer):
60
59
  Lexer.__init__(self, **options)
61
60
 
62
61
  def get_tokens(self, text):
63
- if isinstance(text, unicode):
62
+ if isinstance(text, text_type):
64
63
  # raw token stream never has any non-ASCII characters
65
64
  text = text.encode('ascii')
66
65
  if self.compress == 'gz':
67
66
  import gzip
68
- gzipfile = gzip.GzipFile('', 'rb', 9, cStringIO.StringIO(text))
67
+ gzipfile = gzip.GzipFile('', 'rb', 9, BytesIO(text))
69
68
  text = gzipfile.read()
70
69
  elif self.compress == 'bz2':
71
70
  import bz2
@@ -73,7 +72,7 @@ class RawTokenLexer(Lexer):
73
72
 
74
73
  # do not call Lexer.get_tokens() because we do not want Unicode
75
74
  # decoding to occur, and stripping is not optional.
76
- text = text.strip(b('\n')) + b('\n')
75
+ text = text.strip(b'\n') + b'\n'
77
76
  for i, t, v in self.get_tokens_unprocessed(text):
78
77
  yield t, v
79
78
 
@@ -81,7 +80,7 @@ class RawTokenLexer(Lexer):
81
80
  length = 0
82
81
  for match in line_re.finditer(text):
83
82
  try:
84
- ttypestr, val = match.group().split(b('\t'), 1)
83
+ ttypestr, val = match.group().split(b'\t', 1)
85
84
  except ValueError:
86
85
  val = match.group().decode(self.encoding)
87
86
  ttype = Error
@@ -34,7 +34,7 @@
34
34
  The ``tests/examplefiles`` contains a few test files with data to be
35
35
  parsed by these lexers.
36
36
 
37
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
37
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
38
38
  :license: BSD, see LICENSE for details.
39
39
  """
40
40
 
@@ -42,15 +42,16 @@ import re
42
42
 
43
43
  from pygments.lexer import Lexer, RegexLexer, do_insertions, bygroups
44
44
  from pygments.token import Punctuation, \
45
- Text, Comment, Operator, Keyword, Name, String, Number, Generic
45
+ Text, Comment, Operator, Keyword, Name, String, Number, Generic
46
46
  from pygments.lexers import get_lexer_by_name, ClassNotFound
47
+ from pygments.util import iteritems
47
48
 
48
49
  from pygments.lexers._postgres_builtins import KEYWORDS, DATATYPES, \
49
50
  PSEUDO_TYPES, PLPGSQL_KEYWORDS
50
51
 
51
52
 
52
53
  __all__ = ['PostgresLexer', 'PlPgsqlLexer', 'PostgresConsoleLexer',
53
- 'SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer']
54
+ 'SqlLexer', 'MySqlLexer', 'SqliteConsoleLexer', 'RqlLexer']
54
55
 
55
56
  line_re = re.compile('.*?\n')
56
57
 
@@ -124,7 +125,7 @@ class PostgresLexer(PostgresBase, RegexLexer):
124
125
  """
125
126
  Lexer for the PostgreSQL dialect of SQL.
126
127
 
127
- *New in Pygments 1.5.*
128
+ .. versionadded:: 1.5
128
129
  """
129
130
 
130
131
  name = 'PostgreSQL SQL dialect'
@@ -149,10 +150,10 @@ class PostgresLexer(PostgresBase, RegexLexer):
149
150
  (r"(E|U&)?'(''|[^'])*'", String.Single),
150
151
  (r'(U&)?"(""|[^"])*"', String.Name), # quoted identifier
151
152
  (r'(?s)(\$[^\$]*\$)(.*?)(\1)', language_callback),
152
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
153
+ (r'[a-z_]\w*', Name),
153
154
 
154
155
  # psql variable in SQL
155
- (r""":(['"]?)[a-z][a-z0-9_]*\b\1""", Name.Variable),
156
+ (r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
156
157
 
157
158
  (r'[;:()\[\]\{\},\.]', Punctuation),
158
159
  ],
@@ -169,14 +170,14 @@ class PlPgsqlLexer(PostgresBase, RegexLexer):
169
170
  """
170
171
  Handle the extra syntax in Pl/pgSQL language.
171
172
 
172
- *New in Pygments 1.5.*
173
+ .. versionadded:: 1.5
173
174
  """
174
175
  name = 'PL/pgSQL'
175
176
  aliases = ['plpgsql']
176
177
  mimetypes = ['text/x-plpgsql']
177
178
 
178
179
  flags = re.IGNORECASE
179
- tokens = dict((k, l[:]) for (k, l) in PostgresLexer.tokens.iteritems())
180
+ tokens = dict((k, l[:]) for (k, l) in iteritems(PostgresLexer.tokens))
180
181
 
181
182
  # extend the keywords list
182
183
  for i, pattern in enumerate(tokens['root']):
@@ -191,10 +192,10 @@ class PlPgsqlLexer(PostgresBase, RegexLexer):
191
192
 
192
193
  # Add specific PL/pgSQL rules (before the SQL ones)
193
194
  tokens['root'][:0] = [
194
- (r'\%[a-z][a-z0-9_]*\b', Name.Builtin), # actually, a datatype
195
+ (r'\%[a-z]\w*\b', Name.Builtin), # actually, a datatype
195
196
  (r':=', Operator),
196
- (r'\<\<[a-z][a-z0-9_]*\>\>', Name.Label),
197
- (r'\#[a-z][a-z0-9_]*\b', Keyword.Pseudo), # #variable_conflict
197
+ (r'\<\<[a-z]\w*\>\>', Name.Label),
198
+ (r'\#[a-z]\w*\b', Keyword.Pseudo), # #variable_conflict
198
199
  ]
199
200
 
200
201
 
@@ -210,7 +211,7 @@ class PsqlRegexLexer(PostgresBase, RegexLexer):
210
211
  aliases = [] # not public
211
212
 
212
213
  flags = re.IGNORECASE
213
- tokens = dict((k, l[:]) for (k, l) in PostgresLexer.tokens.iteritems())
214
+ tokens = dict((k, l[:]) for (k, l) in iteritems(PostgresLexer.tokens))
214
215
 
215
216
  tokens['root'].append(
216
217
  (r'\\[^\s]+', Keyword.Pseudo, 'psql-command'))
@@ -218,7 +219,7 @@ class PsqlRegexLexer(PostgresBase, RegexLexer):
218
219
  (r'\n', Text, 'root'),
219
220
  (r'\s+', Text),
220
221
  (r'\\[^\s]+', Keyword.Pseudo),
221
- (r""":(['"]?)[a-z][a-z0-9_]*\b\1""", Name.Variable),
222
+ (r""":(['"]?)[a-z]\w*\b\1""", Name.Variable),
222
223
  (r"'(''|[^'])*'", String.Single),
223
224
  (r"`([^`])*`", String.Backtick),
224
225
  (r"[^\s]+", String.Symbol),
@@ -244,19 +245,20 @@ class lookahead(object):
244
245
  def send(self, i):
245
246
  self._nextitem = i
246
247
  return i
247
- def next(self):
248
+ def __next__(self):
248
249
  if self._nextitem is not None:
249
250
  ni = self._nextitem
250
251
  self._nextitem = None
251
252
  return ni
252
- return self.iter.next()
253
+ return next(self.iter)
254
+ next = __next__
253
255
 
254
256
 
255
257
  class PostgresConsoleLexer(Lexer):
256
258
  """
257
259
  Lexer for psql sessions.
258
260
 
259
- *New in Pygments 1.5.*
261
+ .. versionadded:: 1.5
260
262
  """
261
263
 
262
264
  name = 'PostgreSQL console (psql)'
@@ -277,7 +279,7 @@ class PostgresConsoleLexer(Lexer):
277
279
  insertions = []
278
280
  while 1:
279
281
  try:
280
- line = lines.next()
282
+ line = next(lines)
281
283
  except StopIteration:
282
284
  # allow the emission of partially collected items
283
285
  # the repl loop will be broken below
@@ -314,7 +316,7 @@ class PostgresConsoleLexer(Lexer):
314
316
  # Emit the output lines
315
317
  out_token = Generic.Output
316
318
  while 1:
317
- line = lines.next()
319
+ line = next(lines)
318
320
  mprompt = re_prompt.match(line)
319
321
  if mprompt is not None:
320
322
  # push the line back to have it processed by the prompt
@@ -433,7 +435,7 @@ class SqlLexer(RegexLexer):
433
435
  # TODO: Backslash escapes?
434
436
  (r"'(''|[^'])*'", String.Single),
435
437
  (r'"(""|[^"])*"', String.Symbol), # not a real string literal in ANSI SQL
436
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
438
+ (r'[a-z_]\w*', Name),
437
439
  (r'[;:()\[\],\.]', Punctuation)
438
440
  ],
439
441
  'multiline-comments': [
@@ -504,10 +506,10 @@ class MySqlLexer(RegexLexer):
504
506
  # TODO: this list is not complete
505
507
  (r'\b(auto_increment|engine|charset|tables)\b', Keyword.Pseudo),
506
508
  (r'(true|false|null)', Name.Constant),
507
- (r'([a-zA-Z_][a-zA-Z0-9_]*)(\s*)(\()',
509
+ (r'([a-z_]\w*)(\s*)(\()',
508
510
  bygroups(Name.Function, Text, Punctuation)),
509
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name),
510
- (r'@[A-Za-z0-9]*[._]*[A-Za-z0-9]*', Name.Variable),
511
+ (r'[a-z_]\w*', Name),
512
+ (r'@[a-z0-9]*[._]*[a-z0-9]*', Name.Variable),
511
513
  (r'[;:()\[\],\.]', Punctuation)
512
514
  ],
513
515
  'multiline-comments': [
@@ -523,7 +525,7 @@ class SqliteConsoleLexer(Lexer):
523
525
  """
524
526
  Lexer for example sessions using sqlite3.
525
527
 
526
- *New in Pygments 0.11.*
528
+ .. versionadded:: 0.11
527
529
  """
528
530
 
529
531
  name = 'sqlite3con'
@@ -557,3 +559,34 @@ class SqliteConsoleLexer(Lexer):
557
559
  for item in do_insertions(insertions,
558
560
  sql.get_tokens_unprocessed(curcode)):
559
561
  yield item
562
+
563
+
564
+ class RqlLexer(RegexLexer):
565
+ """
566
+ Lexer for Relation Query Language.
567
+
568
+ `RQL <http://www.logilab.org/project/rql>`_
569
+
570
+ .. versionadded:: 2.0
571
+ """
572
+ name = 'RQL'
573
+ aliases = ['rql']
574
+ filenames = ['*.rql']
575
+ mimetypes = ['text/x-rql']
576
+
577
+ flags = re.IGNORECASE
578
+ tokens = {
579
+ 'root': [
580
+ (r'\s+', Text),
581
+ (r'(DELETE|SET|INSERT|UNION|DISTINCT|WITH|WHERE|BEING|OR'
582
+ r'|AND|NOT|GROUPBY|HAVING|ORDERBY|ASC|DESC|LIMIT|OFFSET'
583
+ r'|TODAY|NOW|TRUE|FALSE|NULL|EXISTS)\b', Keyword),
584
+ (r'[+*/<>=%-]', Operator),
585
+ (r'(Any|is|instance_of|CWEType|CWRelation)\b', Name.Builtin),
586
+ (r'[0-9]+', Number.Integer),
587
+ (r'[A-Z_]\w*\??', Name),
588
+ (r"'(''|[^'])*'", String.Single),
589
+ (r'"(""|[^"])*"', String.Single),
590
+ (r'[;:()\[\],\.]', Punctuation)
591
+ ],
592
+ }
@@ -5,7 +5,7 @@
5
5
 
6
6
  Lexers for various template engines' markup.
7
7
 
8
- :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
8
+ :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS.
9
9
  :license: BSD, see LICENSE for details.
10
10
  """
11
11
 
@@ -16,10 +16,12 @@ from pygments.lexers.web import \
16
16
  from pygments.lexers.agile import PythonLexer, PerlLexer
17
17
  from pygments.lexers.compiled import JavaLexer
18
18
  from pygments.lexers.jvm import TeaLangLexer
19
+ from pygments.lexers.text import YamlLexer
19
20
  from pygments.lexer import Lexer, DelegatingLexer, RegexLexer, bygroups, \
20
- include, using, this
21
+ include, using, this, default, combined
21
22
  from pygments.token import Error, Punctuation, \
22
- Text, Comment, Operator, Keyword, Name, String, Number, Other, Token
23
+ Text, Comment, Operator, Keyword, Name, String, Number, Other, Token, \
24
+ Whitespace
23
25
  from pygments.util import html_doctype_matches, looks_like_xml
24
26
 
25
27
  __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
@@ -36,9 +38,11 @@ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
36
38
  'MakoCssLexer', 'JspLexer', 'CheetahLexer', 'CheetahHtmlLexer',
37
39
  'CheetahXmlLexer', 'CheetahJavascriptLexer', 'EvoqueLexer',
38
40
  'EvoqueHtmlLexer', 'EvoqueXmlLexer', 'ColdfusionLexer',
39
- 'ColdfusionHtmlLexer', 'VelocityLexer', 'VelocityHtmlLexer',
40
- 'VelocityXmlLexer', 'SspLexer', 'TeaTemplateLexer', 'LassoHtmlLexer',
41
- 'LassoXmlLexer', 'LassoCssLexer', 'LassoJavascriptLexer']
41
+ 'ColdfusionHtmlLexer', 'ColdfusionCFCLexer', 'VelocityLexer',
42
+ 'VelocityHtmlLexer', 'VelocityXmlLexer', 'SspLexer',
43
+ 'TeaTemplateLexer', 'LassoHtmlLexer', 'LassoXmlLexer',
44
+ 'LassoCssLexer', 'LassoJavascriptLexer', 'HandlebarsLexer',
45
+ 'HandlebarsHtmlLexer', 'YamlJinjaLexer', 'LiquidLexer']
42
46
 
43
47
 
44
48
  class ErbLexer(Lexer):
@@ -159,22 +163,22 @@ class SmartyLexer(RegexLexer):
159
163
  (r'(\{php\})(.*?)(\{/php\})',
160
164
  bygroups(Comment.Preproc, using(PhpLexer, startinline=True),
161
165
  Comment.Preproc)),
162
- (r'(\{)(/?[a-zA-Z_][a-zA-Z0-9_]*)(\s*)',
166
+ (r'(\{)(/?[a-zA-Z_]\w*)(\s*)',
163
167
  bygroups(Comment.Preproc, Name.Function, Text), 'smarty'),
164
168
  (r'\{', Comment.Preproc, 'smarty')
165
169
  ],
166
170
  'smarty': [
167
171
  (r'\s+', Text),
168
172
  (r'\}', Comment.Preproc, '#pop'),
169
- (r'#[a-zA-Z_][a-zA-Z0-9_]*#', Name.Variable),
170
- (r'\$[a-zA-Z_][a-zA-Z0-9_]*(\.[a-zA-Z0-9_]+)*', Name.Variable),
173
+ (r'#[a-zA-Z_]\w*#', Name.Variable),
174
+ (r'\$[a-zA-Z_]\w*(\.\w+)*', Name.Variable),
171
175
  (r'[~!%^&*()+=|\[\]:;,.<>/?{}@-]', Operator),
172
176
  (r'(true|false|null)\b', Keyword.Constant),
173
177
  (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
174
178
  r"0[xX][0-9a-fA-F]+[Ll]?", Number),
175
179
  (r'"(\\\\|\\"|[^"])*"', String.Double),
176
180
  (r"'(\\\\|\\'|[^'])*'", String.Single),
177
- (r'[a-zA-Z_][a-zA-Z0-9_]*', Name.Attribute)
181
+ (r'[a-zA-Z_]\w*', Name.Attribute)
178
182
  ]
179
183
  }
180
184
 
@@ -205,7 +209,7 @@ class VelocityLexer(RegexLexer):
205
209
 
206
210
  flags = re.MULTILINE | re.DOTALL
207
211
 
208
- identifier = r'[a-zA-Z_][a-zA-Z0-9_]*'
212
+ identifier = r'[a-zA-Z_]\w*'
209
213
 
210
214
  tokens = {
211
215
  'root': [
@@ -227,7 +231,7 @@ class VelocityLexer(RegexLexer):
227
231
  (r'(\.)(' + identifier + r')',
228
232
  bygroups(Punctuation, Name.Variable), '#push'),
229
233
  (r'\}', Punctuation, '#pop'),
230
- (r'', Other, '#pop')
234
+ default('#pop')
231
235
  ],
232
236
  'directiveparams': [
233
237
  (r'(&&|\|\||==?|!=?|[-<>+*%&\|\^/])|\b(eq|ne|gt|lt|ge|le|not|in)\b',
@@ -251,7 +255,9 @@ class VelocityLexer(RegexLexer):
251
255
  (r"\b[0-9]+\b", Number),
252
256
  (r'(true|false|null)\b', Keyword.Constant),
253
257
  (r'\(', Punctuation, '#push'),
254
- (r'\)', Punctuation, '#pop')
258
+ (r'\)', Punctuation, '#pop'),
259
+ (r'\[', Punctuation, '#push'),
260
+ (r'\]', Punctuation, '#pop'),
255
261
  ]
256
262
  }
257
263
 
@@ -263,8 +269,8 @@ class VelocityLexer(RegexLexer):
263
269
  rv += 0.15
264
270
  if re.search(r'#\{?foreach\}?\(.+?\).*?#\{?end\}?', text):
265
271
  rv += 0.15
266
- if re.search(r'\$\{?[a-zA-Z_][a-zA-Z0-9_]*(\([^)]*\))?'
267
- r'(\.[a-zA-Z0-9_]+(\([^)]*\))?)*\}?', text):
272
+ if re.search(r'\$\{?[a-zA-Z_]\w*(\([^)]*\))?'
273
+ r'(\.\w+(\([^)]*\))?)*\}?', text):
268
274
  rv += 0.01
269
275
  return rv
270
276
 
@@ -343,25 +349,25 @@ class DjangoLexer(RegexLexer):
343
349
  Text, Comment.Preproc, Text, Keyword, Text,
344
350
  Comment.Preproc)),
345
351
  # filter blocks
346
- (r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)',
352
+ (r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)',
347
353
  bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
348
354
  'block'),
349
- (r'(\{%)(-?\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
355
+ (r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
350
356
  bygroups(Comment.Preproc, Text, Keyword), 'block'),
351
357
  (r'\{', Other)
352
358
  ],
353
359
  'varnames': [
354
- (r'(\|)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)',
360
+ (r'(\|)(\s*)([a-zA-Z_]\w*)',
355
361
  bygroups(Operator, Text, Name.Function)),
356
- (r'(is)(\s+)(not)?(\s+)?([a-zA-Z_][a-zA-Z0-9_]*)',
362
+ (r'(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)',
357
363
  bygroups(Keyword, Text, Keyword, Text, Name.Function)),
358
364
  (r'(_|true|false|none|True|False|None)\b', Keyword.Pseudo),
359
365
  (r'(in|as|reversed|recursive|not|and|or|is|if|else|import|'
360
366
  r'with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b',
361
367
  Keyword),
362
368
  (r'(loop|block|super|forloop)\b', Name.Builtin),
363
- (r'[a-zA-Z][a-zA-Z0-9_-]*', Name.Variable),
364
- (r'\.[a-zA-Z0-9_]+', Name.Variable),
369
+ (r'[a-zA-Z][\w-]*', Name.Variable),
370
+ (r'\.\w+', Name.Variable),
365
371
  (r':?"(\\\\|\\"|[^"])*"', String.Double),
366
372
  (r":?'(\\\\|\\'|[^'])*'", String.Single),
367
373
  (r'([{}()\[\]+\-*/,:~]|[><=]=?)', Operator),
@@ -397,7 +403,7 @@ class MyghtyLexer(RegexLexer):
397
403
  Generic `myghty templates`_ lexer. Code that isn't Myghty
398
404
  markup is yielded as `Token.Other`.
399
405
 
400
- *New in Pygments 0.6.*
406
+ .. versionadded:: 0.6
401
407
 
402
408
  .. _myghty templates: http://www.myghty.org/
403
409
  """
@@ -445,7 +451,7 @@ class MyghtyHtmlLexer(DelegatingLexer):
445
451
  Subclass of the `MyghtyLexer` that highlights unlexer data
446
452
  with the `HtmlLexer`.
447
453
 
448
- *New in Pygments 0.6.*
454
+ .. versionadded:: 0.6
449
455
  """
450
456
 
451
457
  name = 'HTML+Myghty'
@@ -462,7 +468,7 @@ class MyghtyXmlLexer(DelegatingLexer):
462
468
  Subclass of the `MyghtyLexer` that highlights unlexer data
463
469
  with the `XmlLexer`.
464
470
 
465
- *New in Pygments 0.6.*
471
+ .. versionadded:: 0.6
466
472
  """
467
473
 
468
474
  name = 'XML+Myghty'
@@ -479,7 +485,7 @@ class MyghtyJavascriptLexer(DelegatingLexer):
479
485
  Subclass of the `MyghtyLexer` that highlights unlexer data
480
486
  with the `JavascriptLexer`.
481
487
 
482
- *New in Pygments 0.6.*
488
+ .. versionadded:: 0.6
483
489
  """
484
490
 
485
491
  name = 'JavaScript+Myghty'
@@ -498,7 +504,7 @@ class MyghtyCssLexer(DelegatingLexer):
498
504
  Subclass of the `MyghtyLexer` that highlights unlexer data
499
505
  with the `CssLexer`.
500
506
 
501
- *New in Pygments 0.6.*
507
+ .. versionadded:: 0.6
502
508
  """
503
509
 
504
510
  name = 'CSS+Myghty'
@@ -517,7 +523,7 @@ class MasonLexer(RegexLexer):
517
523
 
518
524
  .. _mason templates: http://www.masonhq.com/
519
525
 
520
- *New in Pygments 1.4.*
526
+ .. versionadded:: 1.4
521
527
  """
522
528
  name = 'Mason'
523
529
  aliases = ['mason']
@@ -570,7 +576,7 @@ class MakoLexer(RegexLexer):
570
576
  Generic `mako templates`_ lexer. Code that isn't Mako
571
577
  markup is yielded as `Token.Other`.
572
578
 
573
- *New in Pygments 0.7.*
579
+ .. versionadded:: 0.7
574
580
 
575
581
  .. _mako templates: http://www.makotemplates.org/
576
582
  """
@@ -638,7 +644,7 @@ class MakoHtmlLexer(DelegatingLexer):
638
644
  Subclass of the `MakoLexer` that highlights unlexed data
639
645
  with the `HtmlLexer`.
640
646
 
641
- *New in Pygments 0.7.*
647
+ .. versionadded:: 0.7
642
648
  """
643
649
 
644
650
  name = 'HTML+Mako'
@@ -654,7 +660,7 @@ class MakoXmlLexer(DelegatingLexer):
654
660
  Subclass of the `MakoLexer` that highlights unlexer data
655
661
  with the `XmlLexer`.
656
662
 
657
- *New in Pygments 0.7.*
663
+ .. versionadded:: 0.7
658
664
  """
659
665
 
660
666
  name = 'XML+Mako'
@@ -670,7 +676,7 @@ class MakoJavascriptLexer(DelegatingLexer):
670
676
  Subclass of the `MakoLexer` that highlights unlexer data
671
677
  with the `JavascriptLexer`.
672
678
 
673
- *New in Pygments 0.7.*
679
+ .. versionadded:: 0.7
674
680
  """
675
681
 
676
682
  name = 'JavaScript+Mako'
@@ -688,7 +694,7 @@ class MakoCssLexer(DelegatingLexer):
688
694
  Subclass of the `MakoLexer` that highlights unlexer data
689
695
  with the `CssLexer`.
690
696
 
691
- *New in Pygments 0.7.*
697
+ .. versionadded:: 0.7
692
698
  """
693
699
 
694
700
  name = 'CSS+Mako'
@@ -741,7 +747,7 @@ class CheetahLexer(RegexLexer):
741
747
  (bygroups(Comment.Preproc, using(CheetahPythonLexer),
742
748
  Comment.Preproc))),
743
749
  # TODO support other Python syntax like $foo['bar']
744
- (r'(\$)([a-zA-Z_][a-zA-Z0-9_\.]*[a-zA-Z0-9_])',
750
+ (r'(\$)([a-zA-Z_][\w\.]*\w)',
745
751
  bygroups(Comment.Preproc, using(CheetahPythonLexer))),
746
752
  (r'(\$\{!?)(.*?)(\})(?s)',
747
753
  bygroups(Comment.Preproc, using(CheetahPythonLexer),
@@ -749,7 +755,7 @@ class CheetahLexer(RegexLexer):
749
755
  (r'''(?sx)
750
756
  (.+?) # anything, followed by:
751
757
  (?:
752
- (?=[#][#a-zA-Z]*) | # an eval comment
758
+ (?=\#[#a-zA-Z]*) | # an eval comment
753
759
  (?=\$[a-zA-Z_{]) | # a substitution
754
760
  \Z # end of string
755
761
  )
@@ -839,7 +845,7 @@ class GenshiTextLexer(RegexLexer):
839
845
  'variable': [
840
846
  (r'(?<!\$)(\$\{)(.+?)(\})',
841
847
  bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
842
- (r'(?<!\$)(\$)([a-zA-Z_][a-zA-Z0-9_\.]*)',
848
+ (r'(?<!\$)(\$)([a-zA-Z_][\w\.]*)',
843
849
  Name.Variable),
844
850
  ]
845
851
  }
@@ -867,7 +873,7 @@ class GenshiMarkupLexer(RegexLexer):
867
873
  ],
868
874
  'pytag': [
869
875
  (r'\s+', Text),
870
- (r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'pyattr'),
876
+ (r'[\w:-]+\s*=', Name.Attribute, 'pyattr'),
871
877
  (r'/?\s*>', Name.Tag, '#pop'),
872
878
  ],
873
879
  'pyattr': [
@@ -877,8 +883,8 @@ class GenshiMarkupLexer(RegexLexer):
877
883
  ],
878
884
  'tag': [
879
885
  (r'\s+', Text),
880
- (r'py:[a-zA-Z0-9_-]+\s*=', Name.Attribute, 'pyattr'),
881
- (r'[a-zA-Z0-9_:-]+\s*=', Name.Attribute, 'attr'),
886
+ (r'py:[\w-]+\s*=', Name.Attribute, 'pyattr'),
887
+ (r'[\w:-]+\s*=', Name.Attribute, 'attr'),
882
888
  (r'/?\s*>', Name.Tag, '#pop'),
883
889
  ],
884
890
  'attr': [
@@ -903,7 +909,7 @@ class GenshiMarkupLexer(RegexLexer):
903
909
  'variable': [
904
910
  (r'(?<!\$)(\$\{)(.+?)(\})',
905
911
  bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
906
- (r'(?<!\$)(\$)([a-zA-Z_][a-zA-Z0-9_\.]*)',
912
+ (r'(?<!\$)(\$)([a-zA-Z_][\w\.]*)',
907
913
  Name.Variable),
908
914
  ]
909
915
  }
@@ -1341,7 +1347,7 @@ class JspRootLexer(RegexLexer):
1341
1347
  Base for the `JspLexer`. Yields `Token.Other` for area outside of
1342
1348
  JSP tags.
1343
1349
 
1344
- *New in Pygments 0.7.*
1350
+ .. versionadded:: 0.7
1345
1351
  """
1346
1352
 
1347
1353
  tokens = {
@@ -1365,7 +1371,7 @@ class JspLexer(DelegatingLexer):
1365
1371
  """
1366
1372
  Lexer for Java Server Pages.
1367
1373
 
1368
- *New in Pygments 0.7.*
1374
+ .. versionadded:: 0.7
1369
1375
  """
1370
1376
  name = 'Java Server Page'
1371
1377
  aliases = ['jsp']
@@ -1388,7 +1394,7 @@ class EvoqueLexer(RegexLexer):
1388
1394
  """
1389
1395
  For files using the Evoque templating system.
1390
1396
 
1391
- *New in Pygments 1.1.*
1397
+ .. versionadded:: 1.1
1392
1398
  """
1393
1399
  name = 'Evoque'
1394
1400
  aliases = ['evoque']
@@ -1441,7 +1447,7 @@ class EvoqueHtmlLexer(DelegatingLexer):
1441
1447
  Subclass of the `EvoqueLexer` that highlights unlexed data with the
1442
1448
  `HtmlLexer`.
1443
1449
 
1444
- *New in Pygments 1.1.*
1450
+ .. versionadded:: 1.1
1445
1451
  """
1446
1452
  name = 'HTML+Evoque'
1447
1453
  aliases = ['html+evoque']
@@ -1457,7 +1463,7 @@ class EvoqueXmlLexer(DelegatingLexer):
1457
1463
  Subclass of the `EvoqueLexer` that highlights unlexed data with the
1458
1464
  `XmlLexer`.
1459
1465
 
1460
- *New in Pygments 1.1.*
1466
+ .. versionadded:: 1.1
1461
1467
  """
1462
1468
  name = 'XML+Evoque'
1463
1469
  aliases = ['xml+evoque']
@@ -1476,26 +1482,33 @@ class ColdfusionLexer(RegexLexer):
1476
1482
  aliases = ['cfs']
1477
1483
  filenames = []
1478
1484
  mimetypes = []
1479
- flags = re.IGNORECASE | re.MULTILINE
1485
+ flags = re.IGNORECASE
1480
1486
 
1481
1487
  tokens = {
1482
1488
  'root': [
1483
- (r'//.*', Comment),
1489
+ (r'//.*?\n', Comment.Single),
1490
+ (r'/\*(?:.|\n)*?\*/', Comment.Multiline),
1484
1491
  (r'\+\+|--', Operator),
1485
1492
  (r'[-+*/^&=!]', Operator),
1486
- (r'<=|>=|<|>', Operator),
1493
+ (r'<=|>=|<|>|==', Operator),
1487
1494
  (r'mod\b', Operator),
1488
1495
  (r'(eq|lt|gt|lte|gte|not|is|and|or)\b', Operator),
1489
1496
  (r'\|\||&&', Operator),
1497
+ (r'\?', Operator),
1490
1498
  (r'"', String.Double, 'string'),
1491
1499
  # There is a special rule for allowing html in single quoted
1492
1500
  # strings, evidently.
1493
1501
  (r"'.*?'", String.Single),
1494
1502
  (r'\d+', Number),
1495
- (r'(if|else|len|var|case|default|break|switch)\b', Keyword),
1496
- (r'([A-Za-z_$][A-Za-z0-9_.]*)(\s*)(\()',
1503
+ (r'(if|else|len|var|xml|default|break|switch|component|property|function|do|'
1504
+ r'try|catch|in|continue|for|return|while|required|any|array|binary|boolean|'
1505
+ r'component|date|guid|numeric|query|string|struct|uuid|case)\b', Keyword),
1506
+ (r'(true|false|null)\b', Keyword.Constant),
1507
+ (r'(application|session|client|cookie|super|this|variables|arguments)\b',
1508
+ Name.Constant),
1509
+ (r'([a-z_$][\w.]*)(\s*)(\()',
1497
1510
  bygroups(Name.Function, Text, Punctuation)),
1498
- (r'[A-Za-z_$][A-Za-z0-9_.]*', Name.Variable),
1511
+ (r'[a-z_$][\w.]*', Name.Variable),
1499
1512
  (r'[()\[\]{};:,.\\]', Punctuation),
1500
1513
  (r'\s+', Text),
1501
1514
  ],
@@ -1525,7 +1538,7 @@ class ColdfusionMarkupLexer(RegexLexer):
1525
1538
  (r'<[^<>]*', Other),
1526
1539
  ],
1527
1540
  'tags': [
1528
- (r'(?s)<!---.*?--->', Comment.Multiline),
1541
+ (r'<!---', Comment.Multiline, 'cfcomment'),
1529
1542
  (r'(?s)<!--.*?-->', Comment),
1530
1543
  (r'<cfoutput.*?>', Name.Builtin, 'cfoutput'),
1531
1544
  (r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)',
@@ -1547,6 +1560,11 @@ class ColdfusionMarkupLexer(RegexLexer):
1547
1560
  (r'(?s)<[^<>]*', Other),
1548
1561
  (r'#', Other),
1549
1562
  ],
1563
+ 'cfcomment': [
1564
+ (r'<!---', Comment.Multiline, '#push'),
1565
+ (r'--->', Comment.Multiline, '#pop'),
1566
+ (r'([^<-]|<(?!!---)|-(?!-->))+', Comment.Multiline),
1567
+ ],
1550
1568
  }
1551
1569
 
1552
1570
 
@@ -1556,7 +1574,7 @@ class ColdfusionHtmlLexer(DelegatingLexer):
1556
1574
  """
1557
1575
  name = 'Coldfusion HTML'
1558
1576
  aliases = ['cfm']
1559
- filenames = ['*.cfm', '*.cfml', '*.cfc']
1577
+ filenames = ['*.cfm', '*.cfml']
1560
1578
  mimetypes = ['application/x-coldfusion']
1561
1579
 
1562
1580
  def __init__(self, **options):
@@ -1564,11 +1582,25 @@ class ColdfusionHtmlLexer(DelegatingLexer):
1564
1582
  **options)
1565
1583
 
1566
1584
 
1585
+ class ColdfusionCFCLexer(DelegatingLexer):
1586
+ """
1587
+ Coldfusion markup/script components
1588
+ """
1589
+ name = 'Coldfusion CFC'
1590
+ aliases = ['cfc']
1591
+ filenames = ['*.cfc']
1592
+ mimetypes = []
1593
+
1594
+ def __init__(self, **options):
1595
+ super(ColdfusionCFCLexer, self).__init__(ColdfusionHtmlLexer, ColdfusionLexer,
1596
+ **options)
1597
+
1598
+
1567
1599
  class SspLexer(DelegatingLexer):
1568
1600
  """
1569
1601
  Lexer for Scalate Server Pages.
1570
1602
 
1571
- *New in Pygments 1.4.*
1603
+ .. versionadded:: 1.4
1572
1604
  """
1573
1605
  name = 'Scalate Server Page'
1574
1606
  aliases = ['ssp']
@@ -1594,7 +1626,7 @@ class TeaTemplateRootLexer(RegexLexer):
1594
1626
  Base for the `TeaTemplateLexer`. Yields `Token.Other` for area outside of
1595
1627
  code blocks.
1596
1628
 
1597
- *New in Pygments 1.5.*
1629
+ .. versionadded:: 1.5
1598
1630
  """
1599
1631
 
1600
1632
  tokens = {
@@ -1615,7 +1647,7 @@ class TeaTemplateLexer(DelegatingLexer):
1615
1647
  """
1616
1648
  Lexer for `Tea Templates <http://teatrove.org/>`_.
1617
1649
 
1618
- *New in Pygments 1.5.*
1650
+ .. versionadded:: 1.5
1619
1651
  """
1620
1652
  name = 'Tea'
1621
1653
  aliases = ['tea']
@@ -1642,7 +1674,7 @@ class LassoHtmlLexer(DelegatingLexer):
1642
1674
 
1643
1675
  Nested JavaScript and CSS is also highlighted.
1644
1676
 
1645
- *New in Pygments 1.6.*
1677
+ .. versionadded:: 1.6
1646
1678
  """
1647
1679
 
1648
1680
  name = 'HTML+Lasso'
@@ -1670,7 +1702,7 @@ class LassoXmlLexer(DelegatingLexer):
1670
1702
  Subclass of the `LassoLexer` which highlights unhandled data with the
1671
1703
  `XmlLexer`.
1672
1704
 
1673
- *New in Pygments 1.6.*
1705
+ .. versionadded:: 1.6
1674
1706
  """
1675
1707
 
1676
1708
  name = 'XML+Lasso'
@@ -1694,7 +1726,7 @@ class LassoCssLexer(DelegatingLexer):
1694
1726
  Subclass of the `LassoLexer` which highlights unhandled data with the
1695
1727
  `CssLexer`.
1696
1728
 
1697
- *New in Pygments 1.6.*
1729
+ .. versionadded:: 1.6
1698
1730
  """
1699
1731
 
1700
1732
  name = 'CSS+Lasso'
@@ -1720,7 +1752,7 @@ class LassoJavascriptLexer(DelegatingLexer):
1720
1752
  Subclass of the `LassoLexer` which highlights unhandled data with the
1721
1753
  `JavascriptLexer`.
1722
1754
 
1723
- *New in Pygments 1.6.*
1755
+ .. versionadded:: 1.6
1724
1756
  """
1725
1757
 
1726
1758
  name = 'JavaScript+Lasso'
@@ -1740,3 +1772,289 @@ class LassoJavascriptLexer(DelegatingLexer):
1740
1772
  if 'function' in text:
1741
1773
  rv += 0.2
1742
1774
  return rv
1775
+
1776
+ class HandlebarsLexer(RegexLexer):
1777
+ """
1778
+ Generic `handlebars <http://handlebarsjs.com/>` template lexer.
1779
+
1780
+ Highlights only the Handlebars template tags (stuff between `{{` and `}}`).
1781
+ Everything else is left for a delegating lexer.
1782
+ """
1783
+
1784
+ name = "Handlebars"
1785
+ aliases = ['handlebars']
1786
+
1787
+ tokens = {
1788
+ 'root': [
1789
+ (r'[^{]+', Other),
1790
+
1791
+ (r'{{!.*}}', Comment),
1792
+
1793
+ (r'({{{)(\s*)', bygroups(Comment.Special, Text), 'tag'),
1794
+ (r'({{)(\s*)', bygroups(Comment.Preproc, Text), 'tag'),
1795
+ ],
1796
+
1797
+ 'tag': [
1798
+ (r'\s+', Text),
1799
+ (r'\}\}\}', Comment.Special, '#pop'),
1800
+ (r'\}\}', Comment.Preproc, '#pop'),
1801
+
1802
+ # Handlebars
1803
+ (r'([\#/]*)(each|if|unless|else|with|log|in)', bygroups(Keyword,
1804
+ Keyword)),
1805
+
1806
+ # General {{#block}}
1807
+ (r'([\#/])(\w+)', bygroups(Name.Function, Name.Function)),
1808
+
1809
+ # {{opt=something}}
1810
+ (r'(\w+)(=)', bygroups(Name.Attribute, Operator)),
1811
+
1812
+ # borrowed from DjangoLexer
1813
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
1814
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
1815
+ (r'[a-zA-Z][\w-]*', Name.Variable),
1816
+ (r'\.\w+', Name.Variable),
1817
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
1818
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1819
+ ]
1820
+ }
1821
+
1822
+
1823
+ class HandlebarsHtmlLexer(DelegatingLexer):
1824
+ """
1825
+ Subclass of the `HandlebarsLexer` that highlights unlexed data with the
1826
+ `HtmlLexer`.
1827
+ """
1828
+
1829
+ name = "HTML+Handlebars"
1830
+ aliases = ["html+handlebars"]
1831
+ filenames = ['*.handlebars', '*.hbs']
1832
+ mimetypes = ['text/html+handlebars', 'text/x-handlebars-template']
1833
+
1834
+ def __init__(self, **options):
1835
+ super(HandlebarsHtmlLexer, self).__init__(HtmlLexer, HandlebarsLexer, **options)
1836
+
1837
+
1838
+ class YamlJinjaLexer(DelegatingLexer):
1839
+ """
1840
+ Subclass of the `DjangoLexer` that highighlights unlexed data with the
1841
+ `YamlLexer`.
1842
+
1843
+ Commonly used in Saltstack salt states.
1844
+
1845
+ .. versionadded:: 2.0
1846
+ """
1847
+
1848
+ name = 'YAML+Jinja'
1849
+ aliases = ['yaml+jinja', 'salt', 'sls']
1850
+ filenames = ['*.sls']
1851
+ mimetypes = ['text/x-yaml+jinja', 'text/x-sls']
1852
+
1853
+ def __init__(self, **options):
1854
+ super(YamlJinjaLexer, self).__init__(YamlLexer, DjangoLexer, **options)
1855
+
1856
+
1857
+ class LiquidLexer(RegexLexer):
1858
+ """
1859
+ Lexer for `Liquid templates
1860
+ <http://www.rubydoc.info/github/Shopify/liquid>`_.
1861
+
1862
+ .. versionadded:: 2.0
1863
+ """
1864
+ name = 'liquid'
1865
+ aliases = ['liquid']
1866
+ filenames = ['*.liquid']
1867
+
1868
+ tokens = {
1869
+ 'root': [
1870
+ (r'[^{]+', Text),
1871
+ # tags and block tags
1872
+ (r'(\{%)(\s*)', bygroups(Punctuation, Whitespace), 'tag-or-block'),
1873
+ # output tags
1874
+ (r'({{)(\s*)([^\s}]+)',
1875
+ bygroups(Punctuation, Whitespace, using(this, state = 'generic')),
1876
+ 'output'),
1877
+ (r'{', Text)
1878
+ ],
1879
+
1880
+ 'tag-or-block': [
1881
+ # builtin logic blocks
1882
+ (r'(if|unless|elsif|case)(?=\s+)', Keyword.Reserved, 'condition'),
1883
+ (r'(when)(\s+)', bygroups(Keyword.Reserved, Whitespace),
1884
+ combined('end-of-block', 'whitespace', 'generic')),
1885
+ (r'(else)(\s*)(%\})',
1886
+ bygroups(Keyword.Reserved, Whitespace, Punctuation), '#pop'),
1887
+
1888
+ # other builtin blocks
1889
+ (r'(capture)(\s+)([^\s%]+)(\s*)(%\})',
1890
+ bygroups(Name.Tag, Whitespace, using(this, state = 'variable'),
1891
+ Whitespace, Punctuation), '#pop'),
1892
+ (r'(comment)(\s*)(%\})',
1893
+ bygroups(Name.Tag, Whitespace, Punctuation), 'comment'),
1894
+ (r'(raw)(\s*)(%\})',
1895
+ bygroups(Name.Tag, Whitespace, Punctuation), 'raw'),
1896
+
1897
+ # end of block
1898
+ (r'(end(case|unless|if))(\s*)(%\})',
1899
+ bygroups(Keyword.Reserved, None, Whitespace, Punctuation), '#pop'),
1900
+ (r'(end([^\s%]+))(\s*)(%\})',
1901
+ bygroups(Name.Tag, None, Whitespace, Punctuation), '#pop'),
1902
+
1903
+ # builtin tags (assign and include are handled together with usual tags)
1904
+ (r'(cycle)(\s+)(?:([^\s:]*)(:))?(\s*)',
1905
+ bygroups(Name.Tag, Whitespace,
1906
+ using(this, state='generic'), Punctuation, Whitespace),
1907
+ 'variable-tag-markup'),
1908
+
1909
+ # other tags or blocks
1910
+ (r'([^\s%]+)(\s*)', bygroups(Name.Tag, Whitespace), 'tag-markup')
1911
+ ],
1912
+
1913
+ 'output': [
1914
+ include('whitespace'),
1915
+ ('\}\}', Punctuation, '#pop'), # end of output
1916
+
1917
+ (r'\|', Punctuation, 'filters')
1918
+ ],
1919
+
1920
+ 'filters': [
1921
+ include('whitespace'),
1922
+ (r'\}\}', Punctuation, ('#pop', '#pop')), # end of filters and output
1923
+
1924
+ (r'([^\s\|:]+)(:?)(\s*)',
1925
+ bygroups(Name.Function, Punctuation, Whitespace), 'filter-markup')
1926
+ ],
1927
+
1928
+ 'filter-markup': [
1929
+ (r'\|', Punctuation, '#pop'),
1930
+ include('end-of-tag'),
1931
+ include('default-param-markup')
1932
+ ],
1933
+
1934
+ 'condition': [
1935
+ include('end-of-block'),
1936
+ include('whitespace'),
1937
+
1938
+ (r'([^\s=!><]+)(\s*)([=!><]=?)(\s*)(\S+)(\s*)(%\})',
1939
+ bygroups(using(this, state = 'generic'), Whitespace, Operator,
1940
+ Whitespace, using(this, state = 'generic'), Whitespace,
1941
+ Punctuation)),
1942
+ (r'\b!', Operator),
1943
+ (r'\bnot\b', Operator.Word),
1944
+ (r'([\w\.\'"]+)(\s+)(contains)(\s+)([\w\.\'"]+)',
1945
+ bygroups(using(this, state = 'generic'), Whitespace, Operator.Word,
1946
+ Whitespace, using(this, state = 'generic'))),
1947
+
1948
+ include('generic'),
1949
+ include('whitespace')
1950
+ ],
1951
+
1952
+ 'generic-value': [
1953
+ include('generic'),
1954
+ include('end-at-whitespace')
1955
+ ],
1956
+
1957
+ 'operator': [
1958
+ (r'(\s*)((=|!|>|<)=?)(\s*)',
1959
+ bygroups(Whitespace, Operator, None, Whitespace), '#pop'),
1960
+ (r'(\s*)(\bcontains\b)(\s*)',
1961
+ bygroups(Whitespace, Operator.Word, Whitespace), '#pop'),
1962
+ ],
1963
+
1964
+ 'end-of-tag': [
1965
+ (r'\}\}', Punctuation, '#pop')
1966
+ ],
1967
+
1968
+ 'end-of-block': [
1969
+ (r'%\}', Punctuation, ('#pop', '#pop'))
1970
+ ],
1971
+
1972
+ 'end-at-whitespace': [
1973
+ (r'\s+', Whitespace, '#pop')
1974
+ ],
1975
+
1976
+ # states for unknown markup
1977
+ 'param-markup': [
1978
+ include('whitespace'),
1979
+ # params with colons or equals
1980
+ (r'([^\s=:]+)(\s*)(=|:)',
1981
+ bygroups(Name.Attribute, Whitespace, Operator)),
1982
+ # explicit variables
1983
+ (r'(\{\{)(\s*)([^\s\}])(\s*)(\}\})',
1984
+ bygroups(Punctuation, Whitespace, using(this, state = 'variable'),
1985
+ Whitespace, Punctuation)),
1986
+
1987
+ include('string'),
1988
+ include('number'),
1989
+ include('keyword'),
1990
+ (r',', Punctuation)
1991
+ ],
1992
+
1993
+ 'default-param-markup': [
1994
+ include('param-markup'),
1995
+ (r'.', Text) # fallback for switches / variables / un-quoted strings / ...
1996
+ ],
1997
+
1998
+ 'variable-param-markup': [
1999
+ include('param-markup'),
2000
+ include('variable'),
2001
+ (r'.', Text) # fallback
2002
+ ],
2003
+
2004
+ 'tag-markup': [
2005
+ (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
2006
+ include('default-param-markup')
2007
+ ],
2008
+
2009
+ 'variable-tag-markup': [
2010
+ (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
2011
+ include('variable-param-markup')
2012
+ ],
2013
+
2014
+ # states for different values types
2015
+ 'keyword': [
2016
+ (r'\b(false|true)\b', Keyword.Constant)
2017
+ ],
2018
+
2019
+ 'variable': [
2020
+ (r'[a-zA-Z_]\w*', Name.Variable),
2021
+ (r'(?<=\w)\.(?=\w)', Punctuation)
2022
+ ],
2023
+
2024
+ 'string': [
2025
+ (r"'[^']*'", String.Single),
2026
+ (r'"[^"]*"', String.Double)
2027
+ ],
2028
+
2029
+ 'number': [
2030
+ (r'\d+\.\d+', Number.Float),
2031
+ (r'\d+', Number.Integer)
2032
+ ],
2033
+
2034
+ 'generic': [ # decides for variable, string, keyword or number
2035
+ include('keyword'),
2036
+ include('string'),
2037
+ include('number'),
2038
+ include('variable')
2039
+ ],
2040
+
2041
+ 'whitespace': [
2042
+ (r'[ \t]+', Whitespace)
2043
+ ],
2044
+
2045
+ # states for builtin blocks
2046
+ 'comment': [
2047
+ (r'(\{%)(\s*)(endcomment)(\s*)(%\})',
2048
+ bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
2049
+ Punctuation), ('#pop', '#pop')),
2050
+ (r'.', Comment)
2051
+ ],
2052
+
2053
+ 'raw': [
2054
+ (r'[^\{]+', Text),
2055
+ (r'(\{%)(\s*)(endraw)(\s*)(%\})',
2056
+ bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
2057
+ Punctuation), '#pop'),
2058
+ (r'\{', Text)
2059
+ ]
2060
+ }