ui: add support for blink style attribute
[vis.git] / lexers / asp.lua
blobdc1b0e92666dd1c6fb71368a06685455a720e4b2
1 -- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- ASP LPeg lexer.
4 local l = require('lexer')
5 local token, word_match = l.token, l.word_match
6 local P, R, S = lpeg.P, lpeg.R, lpeg.S
8 local M = {_NAME = 'asp'}
10 -- Embedded in HTML.
11 local html = l.load('html')
13 -- Embedded VB.
14 local vb = l.load('vb')
15 local vb_start_rule = token('asp_tag', '<%' * P('=')^-1)
16 local vb_end_rule = token('asp_tag', '%>')
17 l.embed_lexer(html, vb, vb_start_rule, vb_end_rule)
19 -- Embedded VBScript.
20 local vbs = l.load('vbscript')
21 local script_element = word_match({'script'}, nil, html.case_insensitive_tags)
22 local vbs_start_rule = #(P('<') * script_element * (P(function(input, index)
23 if input:find('^%s+language%s*=%s*(["\'])vbscript%1', index) or
24 input:find('^%s+type%s*=%s*(["\'])text/vbscript%1', index) then
25 return index
26 end
27 end) + '>')) * html.embed_start_tag -- <script language="vbscript">
28 local vbs_end_rule = #('</' * script_element * l.space^0 * '>') *
29 html.embed_end_tag -- </script>
30 l.embed_lexer(html, vbs, vbs_start_rule, vbs_end_rule)
32 M._tokenstyles = {
33 asp_tag = l.STYLE_EMBEDDED
36 local _foldsymbols = html._foldsymbols
37 _foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%'
38 _foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>'
39 _foldsymbols.asp_tag = {['<%'] = 1, ['%>'] = -1}
40 M._foldsymbols = _foldsymbols
42 return M