Module: Nokogiri
- Defined in:
- lib/nokogiri.rb,
lib/nokogiri/css.rb,
lib/nokogiri/xml.rb,
lib/nokogiri/html.rb,
lib/nokogiri/xslt.rb,
lib/nokogiri/gumbo.rb,
lib/nokogiri/html4.rb,
lib/nokogiri/html5.rb,
lib/nokogiri/xml/dtd.rb,
lib/nokogiri/css/node.rb,
lib/nokogiri/xml/attr.rb,
lib/nokogiri/xml/node.rb,
lib/nokogiri/xml/text.rb,
lib/nokogiri/xml/cdata.rb,
lib/nokogiri/xml/xpath.rb,
lib/nokogiri/css/parser.rb,
lib/nokogiri/css/parser.rb,
lib/nokogiri/html5/node.rb,
lib/nokogiri/xml/reader.rb,
lib/nokogiri/xml/schema.rb,
lib/nokogiri/xml/builder.rb,
lib/nokogiri/xml/pp/node.rb,
lib/nokogiri/syntax_error.rb,
lib/nokogiri/version/info.rb,
lib/nokogiri/xml/document.rb,
lib/nokogiri/xml/node_set.rb,
lib/nokogiri/xml/notation.rb,
lib/nokogiri/xml/relax_ng.rb,
lib/nokogiri/css/tokenizer.rb,
lib/nokogiri/html4/builder.rb,
lib/nokogiri/xml/namespace.rb,
lib/nokogiri/class_resolver.rb,
lib/nokogiri/html4/document.rb,
lib/nokogiri/html5/document.rb,
lib/nokogiri/xml/sax/parser.rb,
lib/nokogiri/xml/searchable.rb,
lib/nokogiri/decorators/slop.rb,
lib/nokogiri/xml/entity_decl.rb,
lib/nokogiri/xslt/stylesheet.rb,
lib/nokogiri/css/syntax_error.rb,
lib/nokogiri/html4/sax/parser.rb,
lib/nokogiri/version/constant.rb,
lib/nokogiri/xml/element_decl.rb,
lib/nokogiri/xml/sax/document.rb,
lib/nokogiri/xml/syntax_error.rb,
lib/nokogiri/css/parser_extras.rb,
lib/nokogiri/css/xpath_visitor.rb,
lib/nokogiri/xml/parse_options.rb,
lib/nokogiri/xml/xpath_context.rb,
lib/nokogiri/xml/attribute_decl.rb,
lib/nokogiri/xml/character_data.rb,
lib/nokogiri/html4/entity_lookup.rb,
lib/nokogiri/xml/element_content.rb,
lib/nokogiri/xml/sax/push_parser.rb,
lib/nokogiri/xml/entity_reference.rb,
lib/nokogiri/html4/sax/push_parser.rb,
lib/nokogiri/xml/document_fragment.rb,
lib/nokogiri/xml/node/save_options.rb,
lib/nokogiri/xml/pp/character_data.rb,
lib/nokogiri/xml/sax/parser_context.rb,
lib/nokogiri/xml/xpath/syntax_error.rb,
lib/nokogiri/html4/document_fragment.rb,
lib/nokogiri/html5/document_fragment.rb,
lib/nokogiri/html4/sax/parser_context.rb,
lib/nokogiri/html4/element_description.rb,
lib/nokogiri/xml/processing_instruction.rb,
lib/nokogiri/html4/element_description_defaults.rb,
ext/nokogiri/nokogiri.c
Overview
– DO NOT MODIFY!!!! This file is automatically generated by rex 1.0.7 from lexical definition file “lib/nokogiri/css/tokenizer.rex”. ++
Defined Under Namespace
Modules: CSS, ClassResolver, Decorators, Gumbo, HTML, HTML4, HTML5, Test, XML, XSLT Classes: EncodingHandler, SyntaxError, VersionInfo
Constant Summary collapse
- VERSION_INFO =
Detailed version info about Nokogiri and the installed extension dependencies.
VersionInfo.instance.to_hash
- VERSION =
The version of Nokogiri you are using
"1.13.6"
Class Method Summary collapse
-
.HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) ⇒ Object
:call-seq: HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) → Nokogiri::HTML4::Document.
-
.HTML5(input, url = nil, encoding = nil, **options, &block) ⇒ Object
Since v1.12.0.
-
.install_default_aliases ⇒ Object
:nodoc:.
-
.jruby? ⇒ Boolean
:nodoc:.
-
.libxml2_patches ⇒ Object
:nodoc:.
-
.make(input = nil, opts = {}, &blk) ⇒ Object
Create a new Nokogiri::XML::DocumentFragment.
-
.parse(string, url = nil, encoding = nil, options = nil) ⇒ Object
Parse an HTML or XML document.
-
.Slop(*args, &block) ⇒ Object
Parse a document and add the Slop decorator.
-
.uses_gumbo? ⇒ Boolean
:nodoc:.
-
.uses_libxml?(requirement = nil) ⇒ Boolean
:nodoc:.
-
.XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block) ⇒ Object
Parse XML.
-
.XSLT(stylesheet, modules = {}) ⇒ Object
Create a Nokogiri::XSLT::Stylesheet with
stylesheet
.
Class Method Details
.HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) ⇒ Object
:call-seq:
HTML4(input, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_HTML, &block) → Nokogiri::HTML4::Document
Parse HTML. Convenience method for Nokogiri::HTML4::Document.parse
10 11 12 |
# File 'lib/nokogiri/html4.rb', line 10 def HTML4(input, url = nil, encoding = nil, = XML::ParseOptions::DEFAULT_HTML, &block) Nokogiri::HTML4::Document.parse(input, url, encoding, , &block) end |
.HTML5(input, url = nil, encoding = nil, **options, &block) ⇒ Object
Since v1.12.0
⚠ HTML5 functionality is not available when running JRuby.
Parse an HTML5 document. Convenience method for Nokogiri::HTML5::Document.parse
30 31 32 |
# File 'lib/nokogiri/html5.rb', line 30 def self.HTML5(input, url = nil, encoding = nil, **, &block) Nokogiri::HTML5::Document.parse(input, url, encoding, **, &block) end |
.install_default_aliases ⇒ Object
:nodoc:
90 91 92 93 94 95 96 97 98 |
# File 'lib/nokogiri.rb', line 90 def install_default_aliases # Make sure to support some popular encoding aliases not known by # all iconv implementations. { "Windows-31J" => "CP932", # Windows-31J is the IANA registered name of CP932. }.each do |alias_name, name| EncodingHandler.alias(name, alias_name) if EncodingHandler[alias_name].nil? end end |
.jruby? ⇒ Boolean
:nodoc:
204 205 206 |
# File 'lib/nokogiri/version/info.rb', line 204 def self.jruby? VersionInfo.instance.jruby? end |
.libxml2_patches ⇒ Object
:nodoc:
209 210 211 212 213 214 215 |
# File 'lib/nokogiri/version/info.rb', line 209 def self.libxml2_patches if VersionInfo.instance.libxml2_using_packaged? Nokogiri::VERSION_INFO["libxml"]["patches"] else [] end end |
.make(input = nil, opts = {}, &blk) ⇒ Object
Create a new Nokogiri::XML::DocumentFragment
62 63 64 65 66 67 68 |
# File 'lib/nokogiri.rb', line 62 def make(input = nil, opts = {}, &blk) if input Nokogiri::HTML4.fragment(input).children.first else Nokogiri(&blk) end end |
.parse(string, url = nil, encoding = nil, options = nil) ⇒ Object
Parse an HTML or XML document. string
contains the document.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nokogiri.rb', line 44 def parse(string, url = nil, encoding = nil, = 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, || XML::ParseOptions::DEFAULT_HTML) else Nokogiri.XML(string, url, encoding, || XML::ParseOptions::DEFAULT_XML) end.tap do |doc| yield doc if block_given? end end |
.Slop(*args, &block) ⇒ Object
Parse a document and add the Slop decorator. The Slop decorator implements method_missing such that methods may be used instead of CSS or XPath. For example:
doc = Nokogiri::Slop(<<-eohtml)
<html>
<body>
<p>first</p>
<p>second</p>
</body>
</html>
eohtml
assert_equal('second', doc.html.body.p[1].text)
85 86 87 |
# File 'lib/nokogiri.rb', line 85 def Slop(*args, &block) Nokogiri(*args, &block).slop! end |
.uses_gumbo? ⇒ Boolean
:nodoc:
199 200 201 |
# File 'lib/nokogiri/version/info.rb', line 199 def self.uses_gumbo? uses_libxml? # TODO: replace with Gumbo functionality end |
.uses_libxml?(requirement = nil) ⇒ Boolean
:nodoc:
191 192 193 194 195 196 |
# File 'lib/nokogiri/version/info.rb', line 191 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 |
.XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block) ⇒ Object
Parse XML. Convenience method for Nokogiri::XML::Document.parse
7 8 9 |
# File 'lib/nokogiri/xml.rb', line 7 def XML(thing, url = nil, encoding = nil, = XML::ParseOptions::DEFAULT_XML, &block) Nokogiri::XML::Document.parse(thing, url, encoding, , &block) end |