Class CodeRay::Scanners::RHTML
In: lib/coderay/scanners/rhtml.rb
Parent: Scanner

Methods

Included Modules

Streamable

Constants

ERB_RUBY_BLOCK = / <%(?!%)[=-]? (?> [^\-%]* # normal* (?> # special (?: %(?!>) | -(?!%>) ) [^\-%]* # normal* )* ) (?: -?%> )? /x
START_OF_ERB = / <%(?!%) /x

Private Instance methods

[Source]

    # File lib/coderay/scanners/rhtml.rb, line 36
36:     def reset_instance
37:       super
38:       @html_scanner.reset
39:     end

[Source]

    # File lib/coderay/scanners/rhtml.rb, line 41
41:     def scan_tokens tokens, options
42: 
43:       until eos?
44: 
45:         if (match = scan_until(/(?=#{START_OF_ERB})/o) || scan_until(/\z/)) and not match.empty?
46:           @html_scanner.tokenize match
47: 
48:         elsif match = scan(/#{ERB_RUBY_BLOCK}/o)
49:           start_tag = match[/\A<%[-=]?/]
50:           end_tag = match[/-?%?>?\z/]
51:           tokens << [:open, :inline]
52:           tokens << [start_tag, :inline_delimiter]
53:           code = match[start_tag.size .. -1 - end_tag.size]
54:           @ruby_scanner.tokenize code
55:           tokens << [end_tag, :inline_delimiter] unless end_tag.empty?
56:           tokens << [:close, :inline]
57: 
58:         else
59:           raise_inspect 'else-case reached!', tokens
60:         end
61: 
62:       end
63: 
64:       tokens
65: 
66:     end

[Source]

    # File lib/coderay/scanners/rhtml.rb, line 31
31:     def setup
32:       @ruby_scanner = CodeRay.scanner :ruby, :tokens => @tokens, :keep_tokens => true
33:       @html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
34:     end

[Validate]