class Nokogiri::HTML4::Document

def parse(

[Returns] Nokogiri::HTML4::Document

can be configured before parsing. See Nokogiri::XML::ParseOptions for more information.
If a block is given, a Nokogiri::XML::ParseOptions object is yielded to the block which
[Yields]

+ParseOptions::DEFAULT_HTML+.
behaviors during parsing. See ParseOptions for more information. The default value is
- +options:+ (Nokogiri::XML::ParseOptions) Configuration object that determines some

content.
document. When not provided, the encoding will be determined based on the document
- +encoding:+ (String) The name of the encoding that should be used when processing the

- +url:+ (String) The base URI for this document.
[Optional Keyword Arguments]

- +input+ (String | IO) The content to be parsed.
[Required Parameters]

Parse \HTML4 input from a String or IO object, and return a new HTML4::Document.

parse(input, url:, encoding:, options:) => Nokogiri::HTML4::Document
parse(input) { |options| ... } => Nokogiri::HTML4::Document
:call-seq:
def parse(
  input,
  url_ = nil, encoding_ = nil, options_ = XML::ParseOptions::DEFAULT_HTML,
  url: url_, encoding: encoding_, options: options_
)
  options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
  yield options if block_given?
  url ||= input.respond_to?(:path) ? input.path : nil
  if input.respond_to?(:encoding)
    unless input.encoding == Encoding::ASCII_8BIT
      encoding ||= input.encoding.name
    end
  end
  if input.respond_to?(:read)
    if input.is_a?(Pathname)
      # resolve the Pathname to the file and open it as an IO object, see #2110
      input = input.expand_path.open
      url ||= input.path
    end
    unless encoding
      input = EncodingReader.new(input)
      begin
        return read_io(input, url, encoding, options.to_i)
      rescue EncodingReader::EncodingFound => e
        encoding = e.found_encoding
      end
    end
    return read_io(input, url, encoding, options.to_i)
  end
  # read_memory pukes on empty docs
  if input.nil? || input.empty?
    return encoding ? new.tap { |i| i.encoding = encoding } : new
  end
  encoding ||= EncodingReader.detect_encoding(input)
  read_memory(input, url, encoding, options.to_i)
end