module MaRuKu::HTMLFragment

This is just a factory, not an actual class

Public Class Methods

new(raw_html) click to toggle source

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

# 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