class Rouge::Lexers::YAML
def self.detect?(text)
def self.detect?(text) # look for the %YAML directive return true if text =~ /\A\s*%YAML/m end
def continue_indent(match)
def continue_indent(match) puts " yaml: continue_indent" if @debug @next_indent += match.size end
def dedent?(level)
def dedent?(level) level < self.indent end
def indent
def indent raise 'empty indent stack!' if @indent_stack.empty? @indent_stack.last end
def indent?(level)
def indent?(level) level > self.indent end
def reset_indent
def reset_indent puts " yaml: reset_indent" if @debug @indent_stack = [0] @next_indent = 0 @block_scalar_indent = nil end
def save_indent(match)
def save_indent(match) @next_indent = match.size puts " yaml: indent: #{self.indent}/#@next_indent" if @debug puts " yaml: popping indent stack - before: #@indent_stack" if @debug if dedent?(@next_indent) @indent_stack.pop while dedent?(@next_indent) puts " yaml: popping indent stack - after: #@indent_stack" if @debug puts " yaml: indent: #{self.indent}/#@next_indent" if @debug # dedenting to a state not previously indented to is an error [match[0...self.indent], match[self.indent..-1]] else [match, ''] end end
def set_indent(match, opts={})
def set_indent(match, opts={}) if indent < @next_indent puts " yaml: indenting #{indent}/#{@next_indent}" if @debug @indent_stack << @next_indent end @next_indent += match.size unless opts[:implicit] end