webmisc.py 39 KB

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