Class: Rouge::Lexers::Escape
- Inherits:
-
Rouge::Lexer
- Object
- Rouge::Lexer
- Rouge::Lexers::Escape
- Defined in:
- lib/rouge/lexers/escape.rb
Constant Summary
Constants included from Token::Tokens
Token::Tokens::Num, Token::Tokens::Str
Instance Attribute Summary collapse
-
#end ⇒ Object
readonly
Returns the value of attribute end.
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Attributes inherited from Rouge::Lexer
Instance Method Summary collapse
-
#initialize ⇒ Escape
constructor
A new instance of Escape.
- #stream_tokens(str, &b) ⇒ Object
- #to_end_regex ⇒ Object
- #to_start_regex ⇒ Object
Methods inherited from Rouge::Lexer
aliases, all, #as_bool, #as_lexer, #as_list, #as_string, #as_token, #bool_option, continue_lex, #continue_lex, debug_enabled?, demo, demo_file, desc, detect?, detectable?, disable_debug!, enable_debug!, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, guesses, #hash_option, #lex, lex, #lexer_option, #list_option, lookup_fancy, mimetypes, option, option_docs, #reset!, #string_option, tag, #tag, title, #token_option, #with
Methods included from Token::Tokens
Constructor Details
Instance Attribute Details
#end ⇒ Object (readonly)
Returns the value of attribute end.
17 18 19 |
# File 'lib/rouge/lexers/escape.rb', line 17 def end @end end |
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
18 19 20 |
# File 'lib/rouge/lexers/escape.rb', line 18 def lang @lang end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
16 17 18 |
# File 'lib/rouge/lexers/escape.rb', line 16 def start @start end |
Instance Method Details
#stream_tokens(str, &b) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rouge/lexers/escape.rb', line 35 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 ⇒ Object
31 32 33 |
# File 'lib/rouge/lexers/escape.rb', line 31 def to_end_regex @to_end_regex ||= /(.*?)(#{Regexp.escape(@end)})/m end |
#to_start_regex ⇒ Object
27 28 29 |
# File 'lib/rouge/lexers/escape.rb', line 27 def to_start_regex @to_start_regex ||= /(.*?)(#{Regexp.escape(@start)})/m end |