Module: Rouge::Indentation
- Included in:
- Lexers::Haml, Lexers::Sass, Lexers::Slim
- Defined in:
- lib/rouge/util.rb
Overview
shared methods for some indentation-sensitive lexers
Instance Method Summary collapse
-
#indentation(indent_str) ⇒ Object
handle a single indented line.
- #reset! ⇒ Object
-
#starts_block(block_state) ⇒ Object
push a state for the next indented block.
Instance Method Details
#indentation(indent_str) ⇒ Object
handle a single indented line
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rouge/util.rb', line 83 def indentation(indent_str) puts " indentation: #{indent_str.inspect}" if @debug puts " block_indentation: #{@block_indentation.inspect}" if @debug @last_indentation = indent_str # if it's an indent and we know where to go next, # push that state. otherwise, push content and # clear the block state. if (@block_state && indent_str.start_with?(@block_indentation) && indent_str != @block_indentation ) push @block_state else @block_state = @block_indentation = nil push :content end end |
#reset! ⇒ Object
69 70 71 72 |
# File 'lib/rouge/util.rb', line 69 def reset! super @block_state = @block_indentation = nil end |
#starts_block(block_state) ⇒ Object
push a state for the next indented block
75 76 77 78 79 80 |
# File 'lib/rouge/util.rb', line 75 def starts_block(block_state) @block_state = block_state @block_indentation = @last_indentation || '' puts " starts_block: #{block_state.inspect}" if @debug puts " block_indentation: #{@block_indentation.inspect}" if @debug end |