module Nokogiri

def self.HTML5(input, url = nil, encoding = nil, **options, &block)

Parse an HTML5 document. Convenience method for {Nokogiri::HTML5::Document.parse}

⚠ HTML5 functionality is not available when running JRuby.

Since v1.12.0
def self.HTML5(input, url = nil, encoding = nil, **options, &block)
  Nokogiri::HTML5::Document.parse(input, url, encoding, **options, &block)
end

def self.jruby?

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

def self.libxml2_patches

:nodoc:
def self.libxml2_patches
  if VersionInfo.instance.libxml2_using_packaged?
    Nokogiri::VERSION_INFO["libxml"]["patches"]
  else
    []
  end
end

def self.uses_gumbo?

:nodoc:
def self.uses_gumbo?
  uses_libxml? # TODO: replace with Gumbo functionality
end

def self.uses_libxml?(requirement = nil)

:nodoc:
def self.uses_libxml?(requirement = nil)
  return false unless VersionInfo.instance.libxml2?
  return true unless requirement
  Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
end

def HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block)

Parse HTML. Convenience method for Nokogiri::HTML4::Document.parse

HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) → Nokogiri::HTML4::Document
:call-seq:
def HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block)
  Nokogiri::HTML4::Document.parse(input, 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 install_default_aliases

:nodoc:
def install_default_aliases
  warn("Nokogiri.install_default_aliases is deprecated. Please call Nokogiri::EncodingHandler.install_default_aliases instead. This will become an error in Nokogiri v1.17.0.", uplevel: 1, category: :deprecated) # deprecated in v1.14.0, remove in v1.17.0
  Nokogiri::EncodingHandler.install_default_aliases
end

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

Create a new Nokogiri::XML::DocumentFragment
##
def make(input = nil, opts = {}, &blk)
  if input
    Nokogiri::HTML4.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)
  if string.respond_to?(:read) ||
      /^\s*<(?:!DOCTYPE\s+)?html[\s>]/i.match?(string[0, 512])
    # Expect an HTML indicator to appear within the first 512
    # characters of a document. (<?xml ?> + <?xml-stylesheet ?>
    # shouldn't be that long)
    Nokogiri.HTML4(
      string,
      url,
      encoding,
      options || XML::ParseOptions::DEFAULT_HTML,
    )
  else
    Nokogiri.XML(
      string,
      url,
      encoding,
      options || XML::ParseOptions::DEFAULT_XML,
    )
  end.tap do |doc|
    yield doc if block_given?
  end
end