Sha256: 227f2c4e8f74bdcd3eb4b996b3ba5f0ca202f099a1a0d7e123efd642dc33b088
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 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 attr_reader :parent attr_reader :ruby_lexer 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 open = /<%%|<%=|<%#|<%-|<%/ close = /%%>|-%>|%>/ state :root do rule /<%#/, 'Comment', :comment rule open, 'Comment.Preproc', :ruby rule /.+?(?=#{open})|.+/m do delegate lexer.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 lexer.ruby_lexer end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rouge-0.1.0.rc1 | lib/rouge/lexers/erb.rb |
rouge-0.0.14 | lib/rouge/lexers/erb.rb |