class Nokogiri::HTML5::DocumentFragment
Since v1.12.0
💡 HTML5 functionality is not available when running JRuby.
Attributes
document[RW]
errors[RW]
quirks_mode[R]
Get the parser’s quirks mode value. See HTML5::QuirksMode.
This method returns ‘nil` if the parser was not invoked (e.g., `Nokogiri::HTML5::DocumentFragment.new(doc)`).
Since v1.14.0
Public Class Methods
# File lib/nokogiri/html5/document_fragment.rb, line 39
def initialize(doc, tags = nil, ctx = nil, options = {})
self.document = doc
self.errors = []
return self unless tags
max_attributes = options[:max_attributes] || Nokogiri::Gumbo::DEFAULT_MAX_ATTRIBUTES
max_errors = options[:max_errors] || Nokogiri::Gumbo::DEFAULT_MAX_ERRORS
max_depth = options[:max_tree_depth] || Nokogiri::Gumbo::DEFAULT_MAX_TREE_DEPTH
tags = Nokogiri::HTML5.read_and_encode(tags, nil)
Nokogiri::Gumbo.fragment(self, tags, ctx, max_attributes, max_errors, max_depth)
end Create a document fragment.
# File lib/nokogiri/html5/document_fragment.rb, line 58
def self.parse(tags, encoding = nil, options = {})
doc = HTML5::Document.new
tags = HTML5.read_and_encode(tags, encoding)
doc.encoding = "UTF-8"
new(doc, tags, nil, options)
end Parse a document fragment from tags, returning a Nodeset.
© 2008–2023 by Mike Dalessio, Aaron Patterson, Yoko Harada, Akinori MUSHA, John Shahid,
Karol Bucek, Sam Ruby, Craig Barnes, Stephen Checkoway, Lars Kanis, Sergio Arbeo,
Timothy Elliott, Nobuyoshi Nakada, Charles Nutter, Patrick MahoneyLicensed under the MIT License.
https://nokogiri.org/rdoc/Nokogiri/HTML5/DocumentFragment.html