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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rouge/util.rb', line 82 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
68 69 70 71 |
# File 'lib/rouge/util.rb', line 68 def reset! super @block_state = @block_indentation = nil end |
#starts_block(block_state) ⇒ Object
push a state for the next indented block
74 75 76 77 78 79 |
# File 'lib/rouge/util.rb', line 74 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 |