class Nokogiri::HTML5::Document
def parse(string_or_io, url = nil, encoding = nil, **options, &block)
[Returns] Nokogiri::HTML5::Document
Nokogiri::HTML5 for more information and usage.
- +block+ (optional) is passed a configuration Hash on which parse options may be set. See
Nokogiri::XML::Document and Nokogiri::HTML4::Document.
⚠ Note that these options are different than those made available by
+:max_tree_depth+ and +:max_attributes+, described at Nokogiri::HTML5.
during parsing. The three currently supported options are +:max_errors+,
- +options+ (optional) is a configuration Hash (or keyword arguments) to set options
the document.
- +encoding+ (optional) is the encoding that should be used when processing
- +url+ (optional) is a String indicating the canonical URI where this document is located.
IO, or StringIO.
- +input+ may be a String, or any object that responds to _read_ and _close_ such as an
[Parameters]
Parse HTML5 input.
parse(input, url=nil, encoding=nil) { |options| ... }
parse(input, url=nil, encoding=nil, **options)
parse(input)
:call-seq:
def parse(string_or_io, url = nil, encoding = nil, **options, &block) yield options if block string_or_io = "" unless string_or_io if string_or_io.respond_to?(:encoding) && string_or_io.encoding != Encoding::ASCII_8BIT encoding ||= string_or_io.encoding.name end if string_or_io.respond_to?(:read) && string_or_io.respond_to?(:path) url ||= string_or_io.path end unless string_or_io.respond_to?(:read) || string_or_io.respond_to?(:to_str) raise ArgumentError, "not a string or IO object" end do_parse(string_or_io, url, encoding, options) end