class Forspell::Loaders::Markdown::FilteredHash

Constants

PERMITTED_TYPES

Public Instance Methods

convert(el, options) click to toggle source
# File lib/forspell/loaders/markdown.rb, line 16
def convert(el, options)
  return if !PERMITTED_TYPES.include?(el.type) && el.children.empty?

  hash = { type: el.type }
  hash[:attr] = el.attr unless el.attr.empty?
  hash[:value] = el.value unless el.value.nil?
  hash[:location] = el.options[:location]
  unless el.children.empty?
    hash[:children] = []
    el.children.each { |child| hash[:children] << convert(child, options) }
  end
  hash
end