module Nokogiri

def self.jruby? # :nodoc:

:nodoc:
def self.jruby? # :nodoc:
  VersionInfo.instance.jruby?
end

def self.uses_libxml? # :nodoc:

:nodoc:
def self.uses_libxml? # :nodoc:
  VersionInfo.instance.libxml2?
end

def HTML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block

Parse HTML. Convenience method for Nokogiri::HTML::Document.parse
##
def HTML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block
  Nokogiri::HTML::Document.parse(thing, url, encoding, options, &block)
end

def Slop(*args, &block)


assert_equal('second', doc.html.body.p[1].text)
eohtml


second


first




doc = Nokogiri::Slop(<<-eohtml)

or XPath. For example:
implements method_missing such that methods may be used instead of CSS
Parse a document and add the Slop decorator. The Slop decorator
##
def Slop(*args, &block)
  Nokogiri(*args, &block).slop!
end

def XML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block

Parse XML. Convenience method for Nokogiri::XML::Document.parse
##
def XML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block
  Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
end

def XSLT stylesheet, modules = {}


xslt = Nokogiri::XSLT(File.read(ARGV[0]))

Example:

Create a Nokogiri::XSLT::Stylesheet with +stylesheet+.
##
def XSLT stylesheet, modules = {}
  XSLT.parse(stylesheet, modules)
end

def make input = nil, opts = {}, &blk

Create a new Nokogiri::XML::DocumentFragment
##
def make input = nil, opts = {}, &blk
  if input
    Nokogiri::HTML.fragment(input).children.first
  else
    Nokogiri(&blk)
  end
end

def parse string, url = nil, encoding = nil, options = nil

Parse an HTML or XML document. +string+ contains the document.
##
def parse string, url = nil, encoding = nil, options = nil
  doc =
    if string.respond_to?(:read) ||
      string =~ /^\s*<[^Hh>]*html/i # Probably html
      Nokogiri.HTML(
        string,
        url,
        encoding, options || XML::ParseOptions::DEFAULT_HTML
      )
    else
      Nokogiri.XML(string, url, encoding,
                    options || XML::ParseOptions::DEFAULT_XML)
    end
  yield doc if block_given?
  doc
end