Sha256: 761732837af7678ae8039655d9938cac8fc1f5aed96644bd199fd786d645f38f
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
module Rouge module Lexers class ERB < RegexLexer tag 'erb' aliases 'eruby', 'rhtml' filenames '*.erb', '*.erubis', '*.rhtml', '*.eruby' def self.analyze_text(text) return 0.4 if text =~ /<%.*%>/ end def initialize(opts={}) @parent = opts.delete(:parent) || 'html' if @parent.is_a? String lexer_class = Lexer.find(@parent) @parent = lexer_class.new(opts) end @ruby_lexer = Ruby.new(opts) super(opts) end start do @parent.reset! @ruby_lexer.reset! end open = /<%%|<%=|<%#|<%-|<%/ close = /%%>|-%>|%>/ state :root do rule /<%#/, 'Comment', :comment rule open, 'Comment.Preproc', :ruby rule /.+?(?=#{open})|.+/m do delegate @parent end end state :comment do rule close, 'Comment', :pop! rule /.+(?=#{close})|.+/m, 'Comment' end state :ruby do rule close, 'Comment.Preproc', :pop! rule /.+?(?=#{close})|.+/m do delegate @ruby_lexer end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rouge-0.1.2 | lib/rouge/lexers/erb.rb |
rouge-0.1.1 | lib/rouge/lexers/erb.rb |
rouge-0.1.0 | lib/rouge/lexers/erb.rb |