Class: Nokogiri::HTML5::Document
- Inherits:
-
Nokogiri::HTML4::Document
- Object
- XML::Node
- XML::Document
- Nokogiri::HTML4::Document
- Nokogiri::HTML5::Document
- Defined in:
- lib/nokogiri/html5/document.rb,
ext/nokogiri/gumbo.c
Overview
Since v1.12.0
💡 HTML5 functionality is not available when running JRuby.
Constant Summary
Constants inherited from XML::Document
XML::Document::NCNAME_CHAR, XML::Document::NCNAME_RE, XML::Document::NCNAME_START_CHAR
Constants inherited from XML::Node
XML::Node::ATTRIBUTE_DECL, XML::Node::ATTRIBUTE_NODE, XML::Node::CDATA_SECTION_NODE, XML::Node::COMMENT_NODE, XML::Node::DOCB_DOCUMENT_NODE, XML::Node::DOCUMENT_FRAG_NODE, XML::Node::DOCUMENT_NODE, XML::Node::DOCUMENT_TYPE_NODE, XML::Node::DTD_NODE, XML::Node::ELEMENT_DECL, XML::Node::ELEMENT_NODE, XML::Node::ENTITY_DECL, XML::Node::ENTITY_NODE, XML::Node::ENTITY_REF_NODE, XML::Node::HTML_DOCUMENT_NODE, XML::Node::NAMESPACE_DECL, XML::Node::NOTATION_NODE, XML::Node::PI_NODE, XML::Node::TEXT_NODE, XML::Node::XINCLUDE_END, XML::Node::XINCLUDE_START
Constants included from ClassResolver
ClassResolver::VALID_NAMESPACES
Constants included from XML::Searchable
XML::Searchable::LOOKS_LIKE_XPATH
Instance Attribute Summary
Attributes inherited from XML::Document
#errors, #namespace_inheritance
Class Method Summary collapse
- .parse(string_or_io, url = nil, encoding = nil, **options) {|options| ... } ⇒ Object
- .read_io(io, url = nil, encoding = nil, **options) ⇒ Object
- .read_memory(string, url = nil, encoding = nil, **options) ⇒ Object
Instance Method Summary collapse
- #fragment(tags = nil) ⇒ Object
- #to_xml(options = {}, &block) ⇒ Object
-
#xpath_doctype ⇒ Object
:call-seq: xpath_doctype() → Nokogiri::CSS::XPathVisitor::DoctypeConfig.
Methods inherited from Nokogiri::HTML4::Document
#meta_encoding, #meta_encoding=, new, #serialize, #title, #title=, #type
Methods inherited from XML::Document
#add_child, #canonicalize, #collect_namespaces, #create_cdata, #create_comment, #create_element, #create_entity, #create_text_node, #decorate, #decorators, #document, #dup, #encoding, #encoding=, #initialize, #name, #namespaces, new, #remove_namespaces!, #root, #root=, #slop!, #url, #validate, #version
Methods inherited from XML::Node
#<<, #<=>, #==, #[], #[]=, #accept, #add_child, #add_class, #add_namespace_definition, #add_next_sibling, #add_previous_sibling, #after, #ancestors, #append_class, #attribute, #attribute_nodes, #attribute_with_ns, #attributes, #before, #blank?, #canonicalize, #cdata?, #child, #children, #children=, #classes, #comment?, #content, #content=, #create_external_subset, #create_internal_subset, #css_path, #decorate!, #default_namespace=, #description, #do_xinclude, #document, #document?, #dup, #each, #element?, #element_children, #encode_special_chars, #external_subset, #first_element_child, #fragment?, #html?, #initialize, #inner_html, #inner_html=, #internal_subset, #key?, #keys, #kwattr_add, #kwattr_append, #kwattr_remove, #kwattr_values, #lang, #lang=, #last_element_child, #line, #line=, #matches?, #namespace, #namespace=, #namespace_definitions, #namespace_scopes, #namespaced_key?, #namespaces, #native_content=, new, #next_element, #next_sibling, #node_name, #node_name=, #node_type, #parent, #parent=, #parse, #path, #pointer_id, #prepend_child, #previous_element, #previous_sibling, #processing_instruction?, #read_only?, #remove_attribute, #remove_class, #replace, #serialize, #swap, #text?, #to_html, #to_s, #to_xhtml, #traverse, #unlink, #value?, #values, #wrap, #write_html_to, #write_to, #write_xhtml_to, #write_xml_to, #xml?
Methods included from ClassResolver
Methods included from XML::Searchable
#>, #at, #at_css, #at_xpath, #css, #search, #xpath
Methods included from XML::PP::Node
Methods included from Node
Constructor Details
This class inherits a constructor from Nokogiri::XML::Document
Class Method Details
.parse(string_or_io, url = nil, encoding = nil, **options) {|options| ... } ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/nokogiri/html5/document.rb', line 28 def self.parse(string_or_io, url = nil, encoding = nil, **, &block) yield if block string_or_io = "" unless string_or_io if string_or_io.respond_to?(:encoding) && string_or_io.encoding.name != "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, ) end |
.read_io(io, url = nil, encoding = nil, **options) ⇒ Object
46 47 48 49 50 |
# File 'lib/nokogiri/html5/document.rb', line 46 def self.read_io(io, url = nil, encoding = nil, **) raise ArgumentError, "io object doesn't respond to :read" unless io.respond_to?(:read) do_parse(io, url, encoding, ) end |
.read_memory(string, url = nil, encoding = nil, **options) ⇒ Object
52 53 54 55 56 |
# File 'lib/nokogiri/html5/document.rb', line 52 def self.read_memory(string, url = nil, encoding = nil, **) raise ArgumentError, "string object doesn't respond to :to_str" unless string.respond_to?(:to_str) do_parse(string, url, encoding, ) end |
Instance Method Details
#fragment(tags = nil) ⇒ Object
58 59 60 |
# File 'lib/nokogiri/html5/document.rb', line 58 def fragment( = nil) DocumentFragment.new(self, , root) end |
#to_xml(options = {}, &block) ⇒ Object
62 63 64 65 66 |
# File 'lib/nokogiri/html5/document.rb', line 62 def to_xml( = {}, &block) # Bypass XML::Document#to_xml which doesn't add # XML::Node::SaveOptions::AS_XML like XML::Node#to_xml does. XML::Node.instance_method(:to_xml).bind(self).call(, &block) end |
#xpath_doctype ⇒ Object
:call-seq:
xpath_doctype() → Nokogiri::CSS::XPathVisitor::DoctypeConfig
- Returns
-
The document type which determines CSS-to-XPath translation.
See XPathVisitor for more information.
74 75 76 |
# File 'lib/nokogiri/html5/document.rb', line 74 def xpath_doctype Nokogiri::CSS::XPathVisitor::DoctypeConfig::HTML5 end |