blob: e89d22a3d62fd9db90bb97088f96a2afdd8246bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# -*- coding: utf-8 -*- #
module Rouge
module Lexers
class EEX < TemplateLexer
title "EEX"
desc "Embedded Elixir"
tag 'eex'
aliases 'leex', 'heex'
filenames '*.eex', '*.leex', '*.heex'
def initialize(opts={})
@elixir_lexer = Elixir.new(opts)
super(opts)
end
start do
parent.reset!
@elixir_lexer.reset!
end
open = /<%%|<%=|<%#|<%/
close = /%%>|%>/
state :root do
rule %r/<%#/, Comment, :comment
rule open, Comment::Preproc, :elixir
rule %r/.+?(?=#{open})|.+/mo do
delegate parent
end
end
state :comment do
rule close, Comment, :pop!
rule %r/.+?(?=#{close})|.+/mo, Comment
end
state :elixir do
rule close, Comment::Preproc, :pop!
rule %r/.+?(?=#{close})|.+/mo do
delegate @elixir_lexer
end
end
end
end
end
|