class Rouge::Lexers::Escape
Attributes
end[R]
lang[R]
start[R]
Public Class Methods
new(*)
click to toggle source
Calls superclass method
Rouge::Lexer::new
# File lib/rouge/lexers/escape.rb, line 19 def initialize(*) super @start = string_option(:start) { '<!' } @end = string_option(:end) { '!>' } @lang = lexer_option(:lang) { PlainText.new } end
Public Instance Methods
stream_tokens(str) { |Escape, stream| ... }
click to toggle source
# File lib/rouge/lexers/escape.rb, line 34 def stream_tokens(str, &b) stream = StringScanner.new(str) loop do if stream.scan(to_start_regex) puts "pre-escape: #{stream[1].inspect}" if @debug @lang.continue_lex(stream[1], &b) else # no more start delimiters, scan til the end @lang.continue_lex(stream.rest, &b) return end if stream.scan(to_end_regex) yield Token::Tokens::Escape, stream[1] else yield Token::Tokens::Escape, stream.rest return end end end
to_end_regex()
click to toggle source
# File lib/rouge/lexers/escape.rb, line 30 def to_end_regex @to_end_regex ||= /(.*?)(#{Regexp.escape(@end)})/m end
to_start_regex()
click to toggle source
# File lib/rouge/lexers/escape.rb, line 26 def to_start_regex @to_start_regex ||= /(.*?)(#{Regexp.escape(@start)})/m end