module Nokogiri

def self.ffi? # :nodoc:

:nodoc:
def self.ffi? # :nodoc:
  uses_libxml? && Nokogiri::VERSION_INFO['libxml']['binding'] == 'ffi'
end

def self.is_2_6_16? # :nodoc:

:nodoc:
def self.is_2_6_16? # :nodoc:
  Nokogiri::VERSION_INFO['libxml']['loaded'] <= '2.6.16'
end

def self.uses_libxml? # :nodoc:

:nodoc:
def self.uses_libxml? # :nodoc:
  !Nokogiri::VERSION_INFO['libxml'].nil?
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


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

Example:

Create a Nokogiri::XSLT::Stylesheet with +stylesheet+.
##
def XSLT stylesheet
  XSLT.parse(stylesheet)
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