module ReverseMarkdown
def self.cleaner
def self.cleaner @cleaner ||= Cleaner.new end
def self.config
def self.config @config ||= Config.new yield @config if block_given? @config end
def self.convert(input, options = {})
def self.convert(input, options = {}) config.with(options) do input = cleaner.force_encoding(input.to_s) root = case input when String then Nokogiri::HTML(input).root when Nokogiri::XML::Document then input.root when Nokogiri::XML::Node then input end root or return '' result = ReverseMarkdown::Converters.lookup(root.name).convert(root) cleaner.tidy(result) end end