module ReverseMarkdown

Constants

VERSION

Public Class Methods

cleaner() click to toggle source
# File lib/reverse_markdown.rb, line 58
def self.cleaner
  @cleaner ||= Cleaner.new
end
config() { |config| ... } click to toggle source
# File lib/reverse_markdown.rb, line 52
def self.config
  @config ||= Config.new
  yield @config if block_given?
  @config
end
convert(input, options = {}) click to toggle source
# File lib/reverse_markdown.rb, line 35
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