webmisc.py 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  1. # -*- coding: utf-8 -*-
  2. """
  3. pygments.lexers.webmisc
  4. ~~~~~~~~~~~~~~~~~~~~~~~
  5. Lexers for misc. web stuff.
  6. :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
  7. :license: BSD, see LICENSE for details.
  8. """
  9. import re
  10. from pygments.lexer import RegexLexer, ExtendedRegexLexer, include, bygroups, \
  11. default, using
  12. from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
  13. Number, Punctuation, Literal
  14. from pygments.util import unirange
  15. from pygments.lexers.css import _indentation, _starts_block
  16. from pygments.lexers.html import HtmlLexer
  17. from pygments.lexers.javascript import JavascriptLexer
  18. from pygments.lexers.ruby import RubyLexer
  19. __all__ = ['DuelLexer', 'SlimLexer', 'XQueryLexer', 'QmlLexer', 'CirruLexer']
  20. class DuelLexer(RegexLexer):
  21. """
  22. Lexer for Duel Views Engine (formerly JBST) markup with JavaScript code blocks.
  23. See http://duelengine.org/.
  24. See http://jsonml.org/jbst/.
  25. .. versionadded:: 1.4
  26. """
  27. name = 'Duel'
  28. aliases = ['duel', 'jbst', 'jsonml+bst']
  29. filenames = ['*.duel', '*.jbst']
  30. mimetypes = ['text/x-duel', 'text/x-jbst']
  31. flags = re.DOTALL
  32. tokens = {
  33. 'root': [
  34. (r'(<%[@=#!:]?)(.*?)(%>)',
  35. bygroups(Name.Tag, using(JavascriptLexer), Name.Tag)),
  36. (r'(<%\$)(.*?)(:)(.*?)(%>)',
  37. bygroups(Name.Tag, Name.Function, Punctuation, String, Name.Tag)),
  38. (r'(<%--)(.*?)(--%>)',
  39. bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
  40. (r'(<script.*?>)(.*?)(</script>)',
  41. bygroups(using(HtmlLexer),
  42. using(JavascriptLexer), using(HtmlLexer))),
  43. (r'(.+?)(?=<)', using(HtmlLexer)),
  44. (r'.+', using(HtmlLexer)),
  45. ],
  46. }
  47. class XQueryLexer(ExtendedRegexLexer):
  48. """
  49. An XQuery lexer, parsing a stream and outputting the tokens needed to
  50. highlight xquery code.
  51. .. versionadded:: 1.4
  52. """
  53. name = 'XQuery'
  54. aliases = ['xquery', 'xqy', 'xq', 'xql', 'xqm']
  55. filenames = ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm']
  56. mimetypes = ['text/xquery', 'application/xquery']
  57. xquery_parse_state = []
  58. # FIX UNICODE LATER
  59. # ncnamestartchar = (
  60. # ur"[A-Z]|_|[a-z]|[\u00C0-\u00D6]|[\u00D8-\u00F6]|[\u00F8-\u02FF]|"
  61. # ur"[\u0370-\u037D]|[\u037F-\u1FFF]|[\u200C-\u200D]|[\u2070-\u218F]|"
  62. # ur"[\u2C00-\u2FEF]|[\u3001-\uD7FF]|[\uF900-\uFDCF]|[\uFDF0-\uFFFD]|"
  63. # ur"[\u10000-\uEFFFF]"
  64. # )
  65. ncnamestartchar = r"(?:[A-Z]|_|[a-z])"
  66. # FIX UNICODE LATER
  67. # ncnamechar = ncnamestartchar + (ur"|-|\.|[0-9]|\u00B7|[\u0300-\u036F]|"
  68. # ur"[\u203F-\u2040]")
  69. ncnamechar = r"(?:" + ncnamestartchar + r"|-|\.|[0-9])"
  70. ncname = "(?:%s+%s*)" % (ncnamestartchar, ncnamechar)
  71. pitarget_namestartchar = r"(?:[A-KN-WYZ]|_|:|[a-kn-wyz])"
  72. pitarget_namechar = r"(?:" + pitarget_namestartchar + r"|-|\.|[0-9])"
  73. pitarget = "%s+%s*" % (pitarget_namestartchar, pitarget_namechar)
  74. prefixedname = "%s:%s" % (ncname, ncname)
  75. unprefixedname = ncname
  76. qname = "(?:%s|%s)" % (prefixedname, unprefixedname)
  77. entityref = r'(?:&(?:lt|gt|amp|quot|apos|nbsp);)'
  78. charref = r'(?:&#[0-9]+;|&#x[0-9a-fA-F]+;)'
  79. stringdouble = r'(?:"(?:' + entityref + r'|' + charref + r'|""|[^&"])*")'
  80. stringsingle = r"(?:'(?:" + entityref + r"|" + charref + r"|''|[^&'])*')"
  81. # FIX UNICODE LATER
  82. # elementcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
  83. # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
  84. elementcontentchar = r'[A-Za-z]|\s|\d|[!"#$%()*+,\-./:;=?@\[\\\]^_\'`|~]'
  85. # quotattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0021]|[\u0023-\u0025]|'
  86. # ur'[\u0027-\u003b]|[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
  87. quotattrcontentchar = r'[A-Za-z]|\s|\d|[!#$%()*+,\-./:;=?@\[\\\]^_\'`|~]'
  88. # aposattrcontentchar = (ur'\t|\r|\n|[\u0020-\u0025]|[\u0028-\u003b]|'
  89. # ur'[\u003d-\u007a]|\u007c|[\u007e-\u007F]')
  90. aposattrcontentchar = r'[A-Za-z]|\s|\d|[!"#$%()*+,\-./:;=?@\[\\\]^_`|~]'
  91. # CHAR elements - fix the above elementcontentchar, quotattrcontentchar,
  92. # aposattrcontentchar
  93. # x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
  94. flags = re.DOTALL | re.MULTILINE | re.UNICODE
  95. def punctuation_root_callback(lexer, match, ctx):
  96. yield match.start(), Punctuation, match.group(1)
  97. # transition to root always - don't pop off stack
  98. ctx.stack = ['root']
  99. ctx.pos = match.end()
  100. def operator_root_callback(lexer, match, ctx):
  101. yield match.start(), Operator, match.group(1)
  102. # transition to root always - don't pop off stack
  103. ctx.stack = ['root']
  104. ctx.pos = match.end()
  105. def popstate_tag_callback(lexer, match, ctx):
  106. yield match.start(), Name.Tag, match.group(1)
  107. ctx.stack.append(lexer.xquery_parse_state.pop())
  108. ctx.pos = match.end()
  109. def popstate_xmlcomment_callback(lexer, match, ctx):
  110. yield match.start(), String.Doc, match.group(1)
  111. ctx.stack.append(lexer.xquery_parse_state.pop())
  112. ctx.pos = match.end()
  113. def popstate_kindtest_callback(lexer, match, ctx):
  114. yield match.start(), Punctuation, match.group(1)
  115. next_state = lexer.xquery_parse_state.pop()
  116. if next_state == 'occurrenceindicator':
  117. if re.match("[?*+]+", match.group(2)):
  118. yield match.start(), Punctuation, match.group(2)
  119. ctx.stack.append('operator')
  120. ctx.pos = match.end()
  121. else:
  122. ctx.stack.append('operator')
  123. ctx.pos = match.end(1)
  124. else:
  125. ctx.stack.append(next_state)
  126. ctx.pos = match.end(1)
  127. def popstate_callback(lexer, match, ctx):
  128. yield match.start(), Punctuation, match.group(1)
  129. # if we have run out of our state stack, pop whatever is on the pygments
  130. # state stack
  131. if len(lexer.xquery_parse_state) == 0:
  132. ctx.stack.pop()
  133. elif len(ctx.stack) > 1:
  134. ctx.stack.append(lexer.xquery_parse_state.pop())
  135. else:
  136. # i don't know if i'll need this, but in case, default back to root
  137. ctx.stack = ['root']
  138. ctx.pos = match.end()
  139. def pushstate_element_content_starttag_callback(lexer, match, ctx):
  140. yield match.start(), Name.Tag, match.group(1)
  141. lexer.xquery_parse_state.append('element_content')
  142. ctx.stack.append('start_tag')
  143. ctx.pos = match.end()
  144. def pushstate_cdata_section_callback(lexer, match, ctx):
  145. yield match.start(), String.Doc, match.group(1)
  146. ctx.stack.append('cdata_section')
  147. lexer.xquery_parse_state.append(ctx.state.pop)
  148. ctx.pos = match.end()
  149. def pushstate_starttag_callback(lexer, match, ctx):
  150. yield match.start(), Name.Tag, match.group(1)
  151. lexer.xquery_parse_state.append(ctx.state.pop)
  152. ctx.stack.append('start_tag')
  153. ctx.pos = match.end()
  154. def pushstate_operator_order_callback(lexer, match, ctx):
  155. yield match.start(), Keyword, match.group(1)
  156. yield match.start(), Text, match.group(2)
  157. yield match.start(), Punctuation, match.group(3)
  158. ctx.stack = ['root']
  159. lexer.xquery_parse_state.append('operator')
  160. ctx.pos = match.end()
  161. def pushstate_operator_map_callback(lexer, match, ctx):
  162. yield match.start(), Keyword, match.group(1)
  163. yield match.start(), Text, match.group(2)
  164. yield match.start(), Punctuation, match.group(3)
  165. ctx.stack = ['root']
  166. lexer.xquery_parse_state.append('operator')
  167. ctx.pos = match.end()
  168. def pushstate_operator_root_validate(lexer, match, ctx):
  169. yield match.start(), Keyword, match.group(1)
  170. yield match.start(), Text, match.group(2)
  171. yield match.start(), Punctuation, match.group(3)
  172. ctx.stack = ['root']
  173. lexer.xquery_parse_state.append('operator')
  174. ctx.pos = match.end()
  175. def pushstate_operator_root_validate_withmode(lexer, match, ctx):
  176. yield match.start(), Keyword, match.group(1)
  177. yield match.start(), Text, match.group(2)
  178. yield match.start(), Keyword, match.group(3)
  179. ctx.stack = ['root']
  180. lexer.xquery_parse_state.append('operator')
  181. ctx.pos = match.end()
  182. def pushstate_operator_processing_instruction_callback(lexer, match, ctx):
  183. yield match.start(), String.Doc, match.group(1)
  184. ctx.stack.append('processing_instruction')
  185. lexer.xquery_parse_state.append('operator')
  186. ctx.pos = match.end()
  187. def pushstate_element_content_processing_instruction_callback(lexer, match, ctx):
  188. yield match.start(), String.Doc, match.group(1)
  189. ctx.stack.append('processing_instruction')
  190. lexer.xquery_parse_state.append('element_content')
  191. ctx.pos = match.end()
  192. def pushstate_element_content_cdata_section_callback(lexer, match, ctx):
  193. yield match.start(), String.Doc, match.group(1)
  194. ctx.stack.append('cdata_section')
  195. lexer.xquery_parse_state.append('element_content')
  196. ctx.pos = match.end()
  197. def pushstate_operator_cdata_section_callback(lexer, match, ctx):
  198. yield match.start(), String.Doc, match.group(1)
  199. ctx.stack.append('cdata_section')
  200. lexer.xquery_parse_state.append('operator')
  201. ctx.pos = match.end()
  202. def pushstate_element_content_xmlcomment_callback(lexer, match, ctx):
  203. yield match.start(), String.Doc, match.group(1)
  204. ctx.stack.append('xml_comment')
  205. lexer.xquery_parse_state.append('element_content')
  206. ctx.pos = match.end()
  207. def pushstate_operator_xmlcomment_callback(lexer, match, ctx):
  208. yield match.start(), String.Doc, match.group(1)
  209. ctx.stack.append('xml_comment')
  210. lexer.xquery_parse_state.append('operator')
  211. ctx.pos = match.end()
  212. def pushstate_kindtest_callback(lexer, match, ctx):
  213. yield match.start(), Keyword, match.group(1)
  214. yield match.start(), Text, match.group(2)
  215. yield match.start(), Punctuation, match.group(3)
  216. lexer.xquery_parse_state.append('kindtest')
  217. ctx.stack.append('kindtest')
  218. ctx.pos = match.end()
  219. def pushstate_operator_kindtestforpi_callback(lexer, match, ctx):
  220. yield match.start(), Keyword, match.group(1)
  221. yield match.start(), Text, match.group(2)
  222. yield match.start(), Punctuation, match.group(3)
  223. lexer.xquery_parse_state.append('operator')
  224. ctx.stack.append('kindtestforpi')
  225. ctx.pos = match.end()
  226. def pushstate_operator_kindtest_callback(lexer, match, ctx):
  227. yield match.start(), Keyword, match.group(1)
  228. yield match.start(), Text, match.group(2)
  229. yield match.start(), Punctuation, match.group(3)
  230. lexer.xquery_parse_state.append('operator')
  231. ctx.stack.append('kindtest')
  232. ctx.pos = match.end()
  233. def pushstate_occurrenceindicator_kindtest_callback(lexer, match, ctx):
  234. yield match.start(), Name.Tag, match.group(1)
  235. yield match.start(), Text, match.group(2)
  236. yield match.start(), Punctuation, match.group(3)
  237. lexer.xquery_parse_state.append('occurrenceindicator')
  238. ctx.stack.append('kindtest')
  239. ctx.pos = match.end()
  240. def pushstate_operator_starttag_callback(lexer, match, ctx):
  241. yield match.start(), Name.Tag, match.group(1)
  242. lexer.xquery_parse_state.append('operator')
  243. ctx.stack.append('start_tag')
  244. ctx.pos = match.end()
  245. def pushstate_operator_root_callback(lexer, match, ctx):
  246. yield match.start(), Punctuation, match.group(1)
  247. lexer.xquery_parse_state.append('operator')
  248. ctx.stack = ['root']
  249. ctx.pos = match.end()
  250. def pushstate_operator_root_construct_callback(lexer, match, ctx):
  251. yield match.start(), Keyword, match.group(1)
  252. yield match.start(), Text, match.group(2)
  253. yield match.start(), Punctuation, match.group(3)
  254. lexer.xquery_parse_state.append('operator')
  255. ctx.stack = ['root']
  256. ctx.pos = match.end()
  257. def pushstate_root_callback(lexer, match, ctx):
  258. yield match.start(), Punctuation, match.group(1)
  259. cur_state = ctx.stack.pop()
  260. lexer.xquery_parse_state.append(cur_state)
  261. ctx.stack = ['root']
  262. ctx.pos = match.end()
  263. def pushstate_operator_attribute_callback(lexer, match, ctx):
  264. yield match.start(), Name.Attribute, match.group(1)
  265. ctx.stack.append('operator')
  266. ctx.pos = match.end()
  267. def pushstate_operator_callback(lexer, match, ctx):
  268. yield match.start(), Keyword, match.group(1)
  269. yield match.start(), Text, match.group(2)
  270. yield match.start(), Punctuation, match.group(3)
  271. lexer.xquery_parse_state.append('operator')
  272. ctx.pos = match.end()
  273. tokens = {
  274. 'comment': [
  275. # xquery comments
  276. (r'(:\))', Comment, '#pop'),
  277. (r'(\(:)', Comment, '#push'),
  278. (r'[^:)]', Comment),
  279. (r'([^:)]|:|\))', Comment),
  280. ],
  281. 'whitespace': [
  282. (r'\s+', Text),
  283. ],
  284. 'operator': [
  285. include('whitespace'),
  286. (r'(\})', popstate_callback),
  287. (r'\(:', Comment, 'comment'),
  288. (r'(\{)', pushstate_root_callback),
  289. (r'then|else|external|at|div|except', Keyword, 'root'),
  290. (r'order by', Keyword, 'root'),
  291. (r'group by', Keyword, 'root'),
  292. (r'is|mod|order\s+by|stable\s+order\s+by', Keyword, 'root'),
  293. (r'and|or', Operator.Word, 'root'),
  294. (r'(eq|ge|gt|le|lt|ne|idiv|intersect|in)(?=\b)',
  295. Operator.Word, 'root'),
  296. (r'return|satisfies|to|union|where|count|preserve\s+strip',
  297. Keyword, 'root'),
  298. (r'(>=|>>|>|<=|<<|<|-|\*|!=|\+|\|\||\||:=|=|!)',
  299. operator_root_callback),
  300. (r'(::|:|;|\[|//|/|,)',
  301. punctuation_root_callback),
  302. (r'(castable|cast)(\s+)(as)\b',
  303. bygroups(Keyword, Text, Keyword), 'singletype'),
  304. (r'(instance)(\s+)(of)\b',
  305. bygroups(Keyword, Text, Keyword), 'itemtype'),
  306. (r'(treat)(\s+)(as)\b',
  307. bygroups(Keyword, Text, Keyword), 'itemtype'),
  308. (r'(case)(\s+)(' + stringdouble + ')',
  309. bygroups(Keyword, Text, String.Double), 'itemtype'),
  310. (r'(case)(\s+)(' + stringsingle + ')',
  311. bygroups(Keyword, Text, String.Single), 'itemtype'),
  312. (r'(case|as)\b', Keyword, 'itemtype'),
  313. (r'(\))(\s*)(as)',
  314. bygroups(Punctuation, Text, Keyword), 'itemtype'),
  315. (r'\$', Name.Variable, 'varname'),
  316. (r'(for|let|previous|next)(\s+)(\$)',
  317. bygroups(Keyword, Text, Name.Variable), 'varname'),
  318. (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
  319. bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable),
  320. 'varname'),
  321. # (r'\)|\?|\]', Punctuation, '#push'),
  322. (r'\)|\?|\]', Punctuation),
  323. (r'(empty)(\s+)(greatest|least)', bygroups(Keyword, Text, Keyword)),
  324. (r'ascending|descending|default', Keyword, '#push'),
  325. (r'(allowing)(\s+)(empty)', bygroups(Keyword, Text, Keyword)),
  326. (r'external', Keyword),
  327. (r'(start|when|end)', Keyword, 'root'),
  328. (r'(only)(\s+)(end)', bygroups(Keyword, Text, Keyword), 'root'),
  329. (r'collation', Keyword, 'uritooperator'),
  330. # eXist specific XQUF
  331. (r'(into|following|preceding|with)', Keyword, 'root'),
  332. # support for current context on rhs of Simple Map Operator
  333. (r'\.', Operator),
  334. # finally catch all string literals and stay in operator state
  335. (stringdouble, String.Double),
  336. (stringsingle, String.Single),
  337. (r'(catch)(\s*)', bygroups(Keyword, Text), 'root'),
  338. ],
  339. 'uritooperator': [
  340. (stringdouble, String.Double, '#pop'),
  341. (stringsingle, String.Single, '#pop'),
  342. ],
  343. 'namespacedecl': [
  344. include('whitespace'),
  345. (r'\(:', Comment, 'comment'),
  346. (r'(at)(\s+)('+stringdouble+')', bygroups(Keyword, Text, String.Double)),
  347. (r"(at)(\s+)("+stringsingle+')', bygroups(Keyword, Text, String.Single)),
  348. (stringdouble, String.Double),
  349. (stringsingle, String.Single),
  350. (r',', Punctuation),
  351. (r'=', Operator),
  352. (r';', Punctuation, 'root'),
  353. (ncname, Name.Namespace),
  354. ],
  355. 'namespacekeyword': [
  356. include('whitespace'),
  357. (r'\(:', Comment, 'comment'),
  358. (stringdouble, String.Double, 'namespacedecl'),
  359. (stringsingle, String.Single, 'namespacedecl'),
  360. (r'inherit|no-inherit', Keyword, 'root'),
  361. (r'namespace', Keyword, 'namespacedecl'),
  362. (r'(default)(\s+)(element)', bygroups(Keyword, Text, Keyword)),
  363. (r'preserve|no-preserve', Keyword),
  364. (r',', Punctuation),
  365. ],
  366. 'annotationname': [
  367. (r'\(:', Comment, 'comment'),
  368. (qname, Name.Decorator),
  369. (r'(\()(' + stringdouble + ')', bygroups(Punctuation, String.Double)),
  370. (r'(\()(' + stringsingle + ')', bygroups(Punctuation, String.Single)),
  371. (r'(\,)(\s+)(' + stringdouble + ')',
  372. bygroups(Punctuation, Text, String.Double)),
  373. (r'(\,)(\s+)(' + stringsingle + ')',
  374. bygroups(Punctuation, Text, String.Single)),
  375. (r'\)', Punctuation),
  376. (r'(\s+)(\%)', bygroups(Text, Name.Decorator), 'annotationname'),
  377. (r'(\s+)(variable)(\s+)(\$)',
  378. bygroups(Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
  379. (r'(\s+)(function)(\s+)',
  380. bygroups(Text, Keyword.Declaration, Text), 'root')
  381. ],
  382. 'varname': [
  383. (r'\(:', Comment, 'comment'),
  384. (r'(' + qname + r')(\()?', bygroups(Name, Punctuation), 'operator'),
  385. ],
  386. 'singletype': [
  387. include('whitespace'),
  388. (r'\(:', Comment, 'comment'),
  389. (ncname + r'(:\*)', Name.Variable, 'operator'),
  390. (qname, Name.Variable, 'operator'),
  391. ],
  392. 'itemtype': [
  393. include('whitespace'),
  394. (r'\(:', Comment, 'comment'),
  395. (r'\$', Name.Variable, 'varname'),
  396. (r'(void)(\s*)(\()(\s*)(\))',
  397. bygroups(Keyword, Text, Punctuation, Text, Punctuation), 'operator'),
  398. (r'(element|attribute|schema-element|schema-attribute|comment|text|'
  399. r'node|binary|document-node|empty-sequence)(\s*)(\()',
  400. pushstate_occurrenceindicator_kindtest_callback),
  401. # Marklogic specific type?
  402. (r'(processing-instruction)(\s*)(\()',
  403. bygroups(Keyword, Text, Punctuation),
  404. ('occurrenceindicator', 'kindtestforpi')),
  405. (r'(item)(\s*)(\()(\s*)(\))(?=[*+?])',
  406. bygroups(Keyword, Text, Punctuation, Text, Punctuation),
  407. 'occurrenceindicator'),
  408. (r'(\(\#)(\s*)', bygroups(Punctuation, Text), 'pragma'),
  409. (r';', Punctuation, '#pop'),
  410. (r'then|else', Keyword, '#pop'),
  411. (r'(at)(\s+)(' + stringdouble + ')',
  412. bygroups(Keyword, Text, String.Double), 'namespacedecl'),
  413. (r'(at)(\s+)(' + stringsingle + ')',
  414. bygroups(Keyword, Text, String.Single), 'namespacedecl'),
  415. (r'except|intersect|in|is|return|satisfies|to|union|where|count',
  416. Keyword, 'root'),
  417. (r'and|div|eq|ge|gt|le|lt|ne|idiv|mod|or', Operator.Word, 'root'),
  418. (r':=|=|,|>=|>>|>|\[|\(|<=|<<|<|-|!=|\|\||\|', Operator, 'root'),
  419. (r'external|at', Keyword, 'root'),
  420. (r'(stable)(\s+)(order)(\s+)(by)',
  421. bygroups(Keyword, Text, Keyword, Text, Keyword), 'root'),
  422. (r'(castable|cast)(\s+)(as)',
  423. bygroups(Keyword, Text, Keyword), 'singletype'),
  424. (r'(treat)(\s+)(as)', bygroups(Keyword, Text, Keyword)),
  425. (r'(instance)(\s+)(of)', bygroups(Keyword, Text, Keyword)),
  426. (r'(case)(\s+)(' + stringdouble + ')',
  427. bygroups(Keyword, Text, String.Double), 'itemtype'),
  428. (r'(case)(\s+)(' + stringsingle + ')',
  429. bygroups(Keyword, Text, String.Single), 'itemtype'),
  430. (r'case|as', Keyword, 'itemtype'),
  431. (r'(\))(\s*)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
  432. (ncname + r':\*', Keyword.Type, 'operator'),
  433. (r'(function|map|array)(\()', bygroups(Keyword.Type, Punctuation)),
  434. (qname, Keyword.Type, 'occurrenceindicator'),
  435. ],
  436. 'kindtest': [
  437. (r'\(:', Comment, 'comment'),
  438. (r'\{', Punctuation, 'root'),
  439. (r'(\))([*+?]?)', popstate_kindtest_callback),
  440. (r'\*', Name, 'closekindtest'),
  441. (qname, Name, 'closekindtest'),
  442. (r'(element|schema-element)(\s*)(\()', pushstate_kindtest_callback),
  443. ],
  444. 'kindtestforpi': [
  445. (r'\(:', Comment, 'comment'),
  446. (r'\)', Punctuation, '#pop'),
  447. (ncname, Name.Variable),
  448. (stringdouble, String.Double),
  449. (stringsingle, String.Single),
  450. ],
  451. 'closekindtest': [
  452. (r'\(:', Comment, 'comment'),
  453. (r'(\))', popstate_callback),
  454. (r',', Punctuation),
  455. (r'(\{)', pushstate_operator_root_callback),
  456. (r'\?', Punctuation),
  457. ],
  458. 'xml_comment': [
  459. (r'(-->)', popstate_xmlcomment_callback),
  460. (r'[^-]{1,2}', Literal),
  461. (u'\\t|\\r|\\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
  462. unirange(0x10000, 0x10ffff), Literal),
  463. ],
  464. 'processing_instruction': [
  465. (r'\s+', Text, 'processing_instruction_content'),
  466. (r'\?>', String.Doc, '#pop'),
  467. (pitarget, Name),
  468. ],
  469. 'processing_instruction_content': [
  470. (r'\?>', String.Doc, '#pop'),
  471. (u'\\t|\\r|\\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
  472. unirange(0x10000, 0x10ffff), Literal),
  473. ],
  474. 'cdata_section': [
  475. (r']]>', String.Doc, '#pop'),
  476. (u'\\t|\\r|\\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
  477. unirange(0x10000, 0x10ffff), Literal),
  478. ],
  479. 'start_tag': [
  480. include('whitespace'),
  481. (r'(/>)', popstate_tag_callback),
  482. (r'>', Name.Tag, 'element_content'),
  483. (r'"', Punctuation, 'quot_attribute_content'),
  484. (r"'", Punctuation, 'apos_attribute_content'),
  485. (r'=', Operator),
  486. (qname, Name.Tag),
  487. ],
  488. 'quot_attribute_content': [
  489. (r'"', Punctuation, 'start_tag'),
  490. (r'(\{)', pushstate_root_callback),
  491. (r'""', Name.Attribute),
  492. (quotattrcontentchar, Name.Attribute),
  493. (entityref, Name.Attribute),
  494. (charref, Name.Attribute),
  495. (r'\{\{|\}\}', Name.Attribute),
  496. ],
  497. 'apos_attribute_content': [
  498. (r"'", Punctuation, 'start_tag'),
  499. (r'\{', Punctuation, 'root'),
  500. (r"''", Name.Attribute),
  501. (aposattrcontentchar, Name.Attribute),
  502. (entityref, Name.Attribute),
  503. (charref, Name.Attribute),
  504. (r'\{\{|\}\}', Name.Attribute),
  505. ],
  506. 'element_content': [
  507. (r'</', Name.Tag, 'end_tag'),
  508. (r'(\{)', pushstate_root_callback),
  509. (r'(<!--)', pushstate_element_content_xmlcomment_callback),
  510. (r'(<\?)', pushstate_element_content_processing_instruction_callback),
  511. (r'(<!\[CDATA\[)', pushstate_element_content_cdata_section_callback),
  512. (r'(<)', pushstate_element_content_starttag_callback),
  513. (elementcontentchar, Literal),
  514. (entityref, Literal),
  515. (charref, Literal),
  516. (r'\{\{|\}\}', Literal),
  517. ],
  518. 'end_tag': [
  519. include('whitespace'),
  520. (r'(>)', popstate_tag_callback),
  521. (qname, Name.Tag),
  522. ],
  523. 'xmlspace_decl': [
  524. include('whitespace'),
  525. (r'\(:', Comment, 'comment'),
  526. (r'preserve|strip', Keyword, '#pop'),
  527. ],
  528. 'declareordering': [
  529. (r'\(:', Comment, 'comment'),
  530. include('whitespace'),
  531. (r'ordered|unordered', Keyword, '#pop'),
  532. ],
  533. 'xqueryversion': [
  534. include('whitespace'),
  535. (r'\(:', Comment, 'comment'),
  536. (stringdouble, String.Double),
  537. (stringsingle, String.Single),
  538. (r'encoding', Keyword),
  539. (r';', Punctuation, '#pop'),
  540. ],
  541. 'pragma': [
  542. (qname, Name.Variable, 'pragmacontents'),
  543. ],
  544. 'pragmacontents': [
  545. (r'#\)', Punctuation, 'operator'),
  546. (u'\\t|\\r|\\n|[\u0020-\uD7FF]|[\uE000-\uFFFD]|' +
  547. unirange(0x10000, 0x10ffff), Literal),
  548. (r'(\s+)', Text),
  549. ],
  550. 'occurrenceindicator': [
  551. include('whitespace'),
  552. (r'\(:', Comment, 'comment'),
  553. (r'\*|\?|\+', Operator, 'operator'),
  554. (r':=', Operator, 'root'),
  555. default('operator'),
  556. ],
  557. 'option': [
  558. include('whitespace'),
  559. (qname, Name.Variable, '#pop'),
  560. ],
  561. 'qname_braren': [
  562. include('whitespace'),
  563. (r'(\{)', pushstate_operator_root_callback),
  564. (r'(\()', Punctuation, 'root'),
  565. ],
  566. 'element_qname': [
  567. (qname, Name.Variable, 'root'),
  568. ],
  569. 'attribute_qname': [
  570. (qname, Name.Variable, 'root'),
  571. ],
  572. 'root': [
  573. include('whitespace'),
  574. (r'\(:', Comment, 'comment'),
  575. # handle operator state
  576. # order on numbers matters - handle most complex first
  577. (r'\d+(\.\d*)?[eE][+-]?\d+', Number.Float, 'operator'),
  578. (r'(\.\d+)[eE][+-]?\d+', Number.Float, 'operator'),
  579. (r'(\.\d+|\d+\.\d*)', Number.Float, 'operator'),
  580. (r'(\d+)', Number.Integer, 'operator'),
  581. (r'(\.\.|\.|\))', Punctuation, 'operator'),
  582. (r'(declare)(\s+)(construction)',
  583. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
  584. (r'(declare)(\s+)(default)(\s+)(order)',
  585. bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
  586. (r'(declare)(\s+)(context)(\s+)(item)',
  587. bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration), 'operator'),
  588. (ncname + r':\*', Name, 'operator'),
  589. (r'\*:'+ncname, Name.Tag, 'operator'),
  590. (r'\*', Name.Tag, 'operator'),
  591. (stringdouble, String.Double, 'operator'),
  592. (stringsingle, String.Single, 'operator'),
  593. (r'(\}|\])', popstate_callback),
  594. # NAMESPACE DECL
  595. (r'(declare)(\s+)(default)(\s+)(collation)',
  596. bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration)),
  597. (r'(module|declare)(\s+)(namespace)',
  598. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacedecl'),
  599. (r'(declare)(\s+)(base-uri)',
  600. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacedecl'),
  601. # NAMESPACE KEYWORD
  602. (r'(declare)(\s+)(default)(\s+)(element|function)',
  603. bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Keyword.Declaration),
  604. 'namespacekeyword'),
  605. (r'(import)(\s+)(schema|module)',
  606. bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'namespacekeyword'),
  607. (r'(declare)(\s+)(copy-namespaces)',
  608. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'namespacekeyword'),
  609. # VARNAMEs
  610. (r'(for|let|some|every)(\s+)(\$)',
  611. bygroups(Keyword, Text, Name.Variable), 'varname'),
  612. (r'(for)(\s+)(tumbling|sliding)(\s+)(window)(\s+)(\$)',
  613. bygroups(Keyword, Text, Keyword, Text, Keyword, Text, Name.Variable), 'varname'),
  614. (r'\$', Name.Variable, 'varname'),
  615. (r'(declare)(\s+)(variable)(\s+)(\$)',
  616. bygroups(Keyword.Declaration, Text, Keyword.Declaration, Text, Name.Variable), 'varname'),
  617. # ANNOTATED GLOBAL VARIABLES AND FUNCTIONS
  618. (r'(declare)(\s+)(\%)', bygroups(Keyword.Declaration, Text, Name.Decorator), 'annotationname'),
  619. # ITEMTYPE
  620. (r'(\))(\s+)(as)', bygroups(Operator, Text, Keyword), 'itemtype'),
  621. (r'(element|attribute|schema-element|schema-attribute|comment|'
  622. r'text|node|document-node|empty-sequence)(\s+)(\()',
  623. pushstate_operator_kindtest_callback),
  624. (r'(processing-instruction)(\s+)(\()',
  625. pushstate_operator_kindtestforpi_callback),
  626. (r'(<!--)', pushstate_operator_xmlcomment_callback),
  627. (r'(<\?)', pushstate_operator_processing_instruction_callback),
  628. (r'(<!\[CDATA\[)', pushstate_operator_cdata_section_callback),
  629. # (r'</', Name.Tag, 'end_tag'),
  630. (r'(<)', pushstate_operator_starttag_callback),
  631. (r'(declare)(\s+)(boundary-space)',
  632. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'xmlspace_decl'),
  633. (r'(validate)(\s+)(lax|strict)',
  634. pushstate_operator_root_validate_withmode),
  635. (r'(validate)(\s*)(\{)', pushstate_operator_root_validate),
  636. (r'(typeswitch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
  637. (r'(switch)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
  638. (r'(element|attribute|namespace)(\s*)(\{)',
  639. pushstate_operator_root_construct_callback),
  640. (r'(document|text|processing-instruction|comment)(\s*)(\{)',
  641. pushstate_operator_root_construct_callback),
  642. # ATTRIBUTE
  643. (r'(attribute)(\s+)(?=' + qname + r')',
  644. bygroups(Keyword, Text), 'attribute_qname'),
  645. # ELEMENT
  646. (r'(element)(\s+)(?=' + qname + r')',
  647. bygroups(Keyword, Text), 'element_qname'),
  648. # PROCESSING_INSTRUCTION
  649. (r'(processing-instruction|namespace)(\s+)(' + ncname + r')(\s*)(\{)',
  650. bygroups(Keyword, Text, Name.Variable, Text, Punctuation),
  651. 'operator'),
  652. (r'(declare|define)(\s+)(function)',
  653. bygroups(Keyword.Declaration, Text, Keyword.Declaration)),
  654. (r'(\{|\[)', pushstate_operator_root_callback),
  655. (r'(unordered|ordered)(\s*)(\{)',
  656. pushstate_operator_order_callback),
  657. (r'(map|array)(\s*)(\{)',
  658. pushstate_operator_map_callback),
  659. (r'(declare)(\s+)(ordering)',
  660. bygroups(Keyword.Declaration, Text, Keyword.Declaration), 'declareordering'),
  661. (r'(xquery)(\s+)(version)',
  662. bygroups(Keyword.Pseudo, Text, Keyword.Pseudo), 'xqueryversion'),
  663. (r'(\(#)(\s*)', bygroups(Punctuation, Text), 'pragma'),
  664. # sometimes return can occur in root state
  665. (r'return', Keyword),
  666. (r'(declare)(\s+)(option)', bygroups(Keyword.Declaration, Text, Keyword.Declaration),
  667. 'option'),
  668. # URI LITERALS - single and double quoted
  669. (r'(at)(\s+)('+stringdouble+')', String.Double, 'namespacedecl'),
  670. (r'(at)(\s+)('+stringsingle+')', String.Single, 'namespacedecl'),
  671. (r'(ancestor-or-self|ancestor|attribute|child|descendant-or-self)(::)',
  672. bygroups(Keyword, Punctuation)),
  673. (r'(descendant|following-sibling|following|parent|preceding-sibling'
  674. r'|preceding|self)(::)', bygroups(Keyword, Punctuation)),
  675. (r'(if)(\s*)(\()', bygroups(Keyword, Text, Punctuation)),
  676. (r'then|else', Keyword),
  677. # eXist specific XQUF
  678. (r'(update)(\s*)(insert|delete|replace|value|rename)', bygroups(Keyword, Text, Keyword)),
  679. (r'(into|following|preceding|with)', Keyword),
  680. # Marklogic specific
  681. (r'(try)(\s*)', bygroups(Keyword, Text), 'root'),
  682. (r'(catch)(\s*)(\()(\$)',
  683. bygroups(Keyword, Text, Punctuation, Name.Variable), 'varname'),
  684. (r'(@'+qname+')', Name.Attribute, 'operator'),
  685. (r'(@'+ncname+')', Name.Attribute, 'operator'),
  686. (r'@\*:'+ncname, Name.Attribute, 'operator'),
  687. (r'@\*', Name.Attribute, 'operator'),
  688. (r'(@)', Name.Attribute, 'operator'),
  689. (r'//|/|\+|-|;|,|\(|\)', Punctuation),
  690. # STANDALONE QNAMES
  691. (qname + r'(?=\s*\{)', Name.Tag, 'qname_braren'),
  692. (qname + r'(?=\s*\([^:])', Name.Function, 'qname_braren'),
  693. (r'(' + qname + ')(#)([0-9]+)', bygroups(Name.Function, Keyword.Type, Number.Integer)),
  694. (qname, Name.Tag, 'operator'),
  695. ]
  696. }
  697. class QmlLexer(RegexLexer):
  698. """
  699. For QML files. See http://doc.qt.digia.com/4.7/qdeclarativeintroduction.html.
  700. .. versionadded:: 1.6
  701. """
  702. # QML is based on javascript, so much of this is taken from the
  703. # JavascriptLexer above.
  704. name = 'QML'
  705. aliases = ['qml', 'qbs']
  706. filenames = ['*.qml', '*.qbs']
  707. mimetypes = ['application/x-qml', 'application/x-qt.qbs+qml']
  708. # pasted from JavascriptLexer, with some additions
  709. flags = re.DOTALL | re.MULTILINE
  710. tokens = {
  711. 'commentsandwhitespace': [
  712. (r'\s+', Text),
  713. (r'<!--', Comment),
  714. (r'//.*?\n', Comment.Single),
  715. (r'/\*.*?\*/', Comment.Multiline)
  716. ],
  717. 'slashstartsregex': [
  718. include('commentsandwhitespace'),
  719. (r'/(\\.|[^[/\\\n]|\[(\\.|[^\]\\\n])*])+/'
  720. r'([gim]+\b|\B)', String.Regex, '#pop'),
  721. (r'(?=/)', Text, ('#pop', 'badregex')),
  722. default('#pop')
  723. ],
  724. 'badregex': [
  725. (r'\n', Text, '#pop')
  726. ],
  727. 'root': [
  728. (r'^(?=\s|/|<!--)', Text, 'slashstartsregex'),
  729. include('commentsandwhitespace'),
  730. (r'\+\+|--|~|&&|\?|:|\|\||\\(?=\n)|'
  731. r'(<<|>>>?|==?|!=?|[-<>+*%&|^/])=?', Operator, 'slashstartsregex'),
  732. (r'[{(\[;,]', Punctuation, 'slashstartsregex'),
  733. (r'[})\].]', Punctuation),
  734. # QML insertions
  735. (r'\bid\s*:\s*[A-Za-z][\w.]*', Keyword.Declaration,
  736. 'slashstartsregex'),
  737. (r'\b[A-Za-z][\w.]*\s*:', Keyword, 'slashstartsregex'),
  738. # the rest from JavascriptLexer
  739. (r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
  740. r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
  741. r'this)\b', Keyword, 'slashstartsregex'),
  742. (r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
  743. (r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
  744. r'extends|final|float|goto|implements|import|int|interface|long|native|'
  745. r'package|private|protected|public|short|static|super|synchronized|throws|'
  746. r'transient|volatile)\b', Keyword.Reserved),
  747. (r'(true|false|null|NaN|Infinity|undefined)\b', Keyword.Constant),
  748. (r'(Array|Boolean|Date|Error|Function|Math|netscape|'
  749. r'Number|Object|Packages|RegExp|String|sun|decodeURI|'
  750. r'decodeURIComponent|encodeURI|encodeURIComponent|'
  751. r'Error|eval|isFinite|isNaN|parseFloat|parseInt|document|this|'
  752. r'window)\b', Name.Builtin),
  753. (r'[$a-zA-Z_]\w*', Name.Other),
  754. (r'[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?', Number.Float),
  755. (r'0x[0-9a-fA-F]+', Number.Hex),
  756. (r'[0-9]+', Number.Integer),
  757. (r'"(\\\\|\\"|[^"])*"', String.Double),
  758. (r"'(\\\\|\\'|[^'])*'", String.Single),
  759. ]
  760. }
  761. class CirruLexer(RegexLexer):
  762. r"""
  763. Syntax rules of Cirru can be found at:
  764. http://cirru.org/
  765. * using ``()`` for expressions, but restricted in a same line
  766. * using ``""`` for strings, with ``\`` for escaping chars
  767. * using ``$`` as folding operator
  768. * using ``,`` as unfolding operator
  769. * using indentations for nested blocks
  770. .. versionadded:: 2.0
  771. """
  772. name = 'Cirru'
  773. aliases = ['cirru']
  774. filenames = ['*.cirru']
  775. mimetypes = ['text/x-cirru']
  776. flags = re.MULTILINE
  777. tokens = {
  778. 'string': [
  779. (r'[^"\\\n]', String),
  780. (r'\\', String.Escape, 'escape'),
  781. (r'"', String, '#pop'),
  782. ],
  783. 'escape': [
  784. (r'.', String.Escape, '#pop'),
  785. ],
  786. 'function': [
  787. (r'\,', Operator, '#pop'),
  788. (r'[^\s"()]+', Name.Function, '#pop'),
  789. (r'\)', Operator, '#pop'),
  790. (r'(?=\n)', Text, '#pop'),
  791. (r'\(', Operator, '#push'),
  792. (r'"', String, ('#pop', 'string')),
  793. (r'[ ]+', Text.Whitespace),
  794. ],
  795. 'line': [
  796. (r'(?<!\w)\$(?!\w)', Operator, 'function'),
  797. (r'\(', Operator, 'function'),
  798. (r'\)', Operator),
  799. (r'\n', Text, '#pop'),
  800. (r'"', String, 'string'),
  801. (r'[ ]+', Text.Whitespace),
  802. (r'[+-]?[\d.]+\b', Number),
  803. (r'[^\s"()]+', Name.Variable)
  804. ],
  805. 'root': [
  806. (r'^\n+', Text.Whitespace),
  807. default(('line', 'function')),
  808. ]
  809. }
  810. class SlimLexer(ExtendedRegexLexer):
  811. """
  812. For Slim markup.
  813. .. versionadded:: 2.0
  814. """
  815. name = 'Slim'
  816. aliases = ['slim']
  817. filenames = ['*.slim']
  818. mimetypes = ['text/x-slim']
  819. flags = re.IGNORECASE
  820. _dot = r'(?: \|\n(?=.* \|)|.)'
  821. tokens = {
  822. 'root': [
  823. (r'[ \t]*\n', Text),
  824. (r'[ \t]*', _indentation),
  825. ],
  826. 'css': [
  827. (r'\.[\w:-]+', Name.Class, 'tag'),
  828. (r'\#[\w:-]+', Name.Function, 'tag'),
  829. ],
  830. 'eval-or-plain': [
  831. (r'([ \t]*==?)(.*\n)',
  832. bygroups(Punctuation, using(RubyLexer)),
  833. 'root'),
  834. (r'[ \t]+[\w:-]+(?==)', Name.Attribute, 'html-attributes'),
  835. default('plain'),
  836. ],
  837. 'content': [
  838. include('css'),
  839. (r'[\w:-]+:[ \t]*\n', Text, 'plain'),
  840. (r'(-)(.*\n)',
  841. bygroups(Punctuation, using(RubyLexer)),
  842. '#pop'),
  843. (r'\|' + _dot + r'*\n', _starts_block(Text, 'plain'), '#pop'),
  844. (r'/' + _dot + r'*\n', _starts_block(Comment.Preproc, 'slim-comment-block'), '#pop'),
  845. (r'[\w:-]+', Name.Tag, 'tag'),
  846. include('eval-or-plain'),
  847. ],
  848. 'tag': [
  849. include('css'),
  850. (r'[<>]{1,2}(?=[ \t=])', Punctuation),
  851. (r'[ \t]+\n', Punctuation, '#pop:2'),
  852. include('eval-or-plain'),
  853. ],
  854. 'plain': [
  855. (r'([^#\n]|#[^{\n]|(\\\\)*\\#\{)+', Text),
  856. (r'(#\{)(.*?)(\})',
  857. bygroups(String.Interpol, using(RubyLexer), String.Interpol)),
  858. (r'\n', Text, 'root'),
  859. ],
  860. 'html-attributes': [
  861. (r'=', Punctuation),
  862. (r'"[^"]+"', using(RubyLexer), 'tag'),
  863. (r'\'[^\']+\'', using(RubyLexer), 'tag'),
  864. (r'\w+', Text, 'tag'),
  865. ],
  866. 'slim-comment-block': [
  867. (_dot + '+', Comment.Preproc),
  868. (r'\n', Text, 'root'),
  869. ],
  870. }