Module: MaRuKu::HTMLFragment

Defined in:
lib/maruku/html.rb

Overview

This is just a factory, not an actual class

Class Method Summary collapse

Class Method Details

.new(raw_html) ⇒ Object

HTMLFragment.new produces a concrete HTMLFragment implementation that is either a NokogiriHTMLFragment or a REXMLHTMLFragment.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/maruku/html.rb', line 31

def self.new(raw_html)
  if !$warned_nokogiri && MaRuKu::Globals[:html_parser] == 'nokogiri'
    begin
      require 'nokogiri'
      return NokogiriHTMLFragment.new(raw_html)
    rescue LoadError
      warn "Nokogiri could not be loaded. Falling back to REXML."
      $warned_nokogiri = true
    end
  end

  require 'rexml/document'
  REXMLHTMLFragment.new(raw_html)
end