Class: Rouge::Lexers::Session
- Inherits:
-
TemplateLexer
- Object
- Rouge::Lexer
- RegexLexer
- TemplateLexer
- Rouge::Lexers::Session
- Defined in:
- lib/rouge/lexers/session.rb
Constant Summary
Constants inherited from RegexLexer
Instance Method Summary collapse
Methods inherited from TemplateLexer
Methods inherited from RegexLexer
#delegate, get_state, #get_state, #group, #in_state?, #pop!, #push, #reset!, #reset_stack, #run_callback, #run_rule, #stack, start, start_procs, #state, state, #state?, states, #step, #token
Methods inherited from Rouge::Lexer
aliases, all, analyze_text, assert_utf8!, #debug, default_options, demo, demo_file, desc, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, #initialize, lex, #lex, mimetypes, #option, #options, register, #reset!, tag, #tag
Constructor Details
This class inherits a constructor from Rouge::Lexer
Instance Method Details
#prompt_regex ⇒ Object
10 11 12 13 14 |
# File 'lib/rouge/lexers/session.rb', line 10 def prompt_regex @prompt_regex ||= option(:prompt).tap do |prompt| Regexp === prompt ? prompt : Regexp.new(prompt) end end |
#stream_tokens(str, &b) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rouge/lexers/session.rb', line 16 def stream_tokens(str, &b) scanner = StringScanner.new(str) until scanner.eos? if scanner.scan(prompt_regex) debug { "prompt: #{scanner[0].inspect}" } yield Token['Generic.Heading'], scanner[0] scanner.scan(line_regex) debug { "line: #{scanner[0].inspect}" } parent.lex(scanner[0], :continue => true, &b) end scanner.scan(until_prompt_regex) debug { "(#{until_prompt_regex.inspect}: #{scanner[0].inspect}" } yield Token['Generic.Output'], scanner[0] end end |