diff options
Diffstat (limited to 'lua/lexers/rhtml.lua')
| -rw-r--r-- | lua/lexers/rhtml.lua | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/lua/lexers/rhtml.lua b/lua/lexers/rhtml.lua index 8506bff..16c7706 100644 --- a/lua/lexers/rhtml.lua +++ b/lua/lexers/rhtml.lua @@ -1,29 +1,20 @@ --- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE. +-- Copyright 2006-2022 Mitchell. See LICENSE. -- RHTML LPeg lexer. -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, S = lpeg.P, lpeg.S -local M = {_NAME = 'rhtml'} - --- Embedded in HTML. -local html = l.load('html') +local lex = lexer.new('rhtml', {inherit = lexer.load('html')}) -- Embedded Ruby. -local ruby = l.load('rails') +local ruby = lexer.load('rails') local ruby_start_rule = token('rhtml_tag', '<%' * P('=')^-1) local ruby_end_rule = token('rhtml_tag', '%>') -l.embed_lexer(html, ruby, ruby_start_rule, ruby_end_rule) - -M._tokenstyles = { - rhtml_tag = l.STYLE_EMBEDDED -} +lex:embed(ruby, ruby_start_rule, ruby_end_rule) +lex:add_style('rhtml_tag', lexer.styles.embedded) -local _foldsymbols = html._foldsymbols -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '<%%' -_foldsymbols._patterns[#_foldsymbols._patterns + 1] = '%%>' -_foldsymbols.rhtml_tag = {['<%'] = 1, ['%>'] = -1} -M._foldsymbols = _foldsymbols +-- Fold points. +lex:add_fold_point('rhtml_tag', '<%', '%>') -return M +return lex |
