Class: ReverseAdoc::HtmlConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/reverse_adoc/html_converter.rb

Class Method Summary collapse

Class Method Details

.convert(input, options = {}) ⇒ Object



56
57
58
59
# File 'lib/reverse_adoc/html_converter.rb', line 56

def self.convert(input, options = {})
  result = Coradoc::Generator.gen_adoc(to_coradoc(input, options))
  ReverseAdoc.cleaner.tidy(result)
end

.to_coradoc(input, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/reverse_adoc/html_converter.rb', line 39

def self.to_coradoc(input, options = {})
  root = case input
         when String
           Nokogiri::HTML(input).root
         when Nokogiri::XML::Document
           input.root
         when Nokogiri::XML::Node
           input
         end

  return "" unless root

  ReverseAdoc.config.with(options) do
    ReverseAdoc::Converters.lookup(root.name).to_coradoc(root)
  end
end