class Kramdown::Converter::HashAst

Converts a Kramdown::Document to a nested hash for further processing or debug output.

Public Instance Methods

convert(el) click to toggle source
   # File lib/kramdown/converter/hash_ast.rb
20 def convert(el)
21   hash = {type: el.type}
22   hash[:attr] = el.attr unless el.attr.empty?
23   hash[:value] = el.value unless el.value.nil?
24   hash[:options] = el.options unless el.options.empty?
25   unless el.children.empty?
26     hash[:children] = []
27     el.children.each {|child| hash[:children] << convert(child) }
28   end
29   hash
30 end