nokogiri 1.11.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE-DEPENDENCIES.md +1682 -0
- data/LICENSE.md +9 -0
- data/README.md +272 -0
- data/bin/nokogiri +118 -0
- data/dependencies.yml +74 -0
- data/ext/nokogiri/depend +477 -0
- data/ext/nokogiri/extconf.rb +836 -0
- data/ext/nokogiri/html_document.c +171 -0
- data/ext/nokogiri/html_document.h +10 -0
- data/ext/nokogiri/html_element_description.c +279 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +32 -0
- data/ext/nokogiri/html_entity_lookup.h +8 -0
- data/ext/nokogiri/html_sax_parser_context.c +116 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/html_sax_push_parser.c +87 -0
- data/ext/nokogiri/html_sax_push_parser.h +9 -0
- data/ext/nokogiri/include/libexslt/exslt.h +102 -0
- data/ext/nokogiri/include/libexslt/exsltconfig.h +70 -0
- data/ext/nokogiri/include/libexslt/exsltexports.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/DOCBparser.h +96 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLparser.h +306 -0
- data/ext/nokogiri/include/libxml2/libxml/HTMLtree.h +147 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX.h +173 -0
- data/ext/nokogiri/include/libxml2/libxml/SAX2.h +178 -0
- data/ext/nokogiri/include/libxml2/libxml/c14n.h +126 -0
- data/ext/nokogiri/include/libxml2/libxml/catalog.h +182 -0
- data/ext/nokogiri/include/libxml2/libxml/chvalid.h +230 -0
- data/ext/nokogiri/include/libxml2/libxml/debugXML.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/dict.h +79 -0
- data/ext/nokogiri/include/libxml2/libxml/encoding.h +245 -0
- data/ext/nokogiri/include/libxml2/libxml/entities.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/globals.h +508 -0
- data/ext/nokogiri/include/libxml2/libxml/hash.h +236 -0
- data/ext/nokogiri/include/libxml2/libxml/list.h +137 -0
- data/ext/nokogiri/include/libxml2/libxml/nanoftp.h +163 -0
- data/ext/nokogiri/include/libxml2/libxml/nanohttp.h +81 -0
- data/ext/nokogiri/include/libxml2/libxml/parser.h +1241 -0
- data/ext/nokogiri/include/libxml2/libxml/parserInternals.h +644 -0
- data/ext/nokogiri/include/libxml2/libxml/pattern.h +100 -0
- data/ext/nokogiri/include/libxml2/libxml/relaxng.h +217 -0
- data/ext/nokogiri/include/libxml2/libxml/schemasInternals.h +958 -0
- data/ext/nokogiri/include/libxml2/libxml/schematron.h +142 -0
- data/ext/nokogiri/include/libxml2/libxml/threads.h +89 -0
- data/ext/nokogiri/include/libxml2/libxml/tree.h +1311 -0
- data/ext/nokogiri/include/libxml2/libxml/uri.h +94 -0
- data/ext/nokogiri/include/libxml2/libxml/valid.h +458 -0
- data/ext/nokogiri/include/libxml2/libxml/xinclude.h +129 -0
- data/ext/nokogiri/include/libxml2/libxml/xlink.h +189 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlIO.h +366 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlautomata.h +146 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlerror.h +945 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlexports.h +153 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmemory.h +224 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlmodule.h +57 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlreader.h +428 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlregexp.h +222 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlsave.h +88 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemas.h +246 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlschemastypes.h +151 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlstring.h +140 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlunicode.h +202 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlversion.h +485 -0
- data/ext/nokogiri/include/libxml2/libxml/xmlwriter.h +488 -0
- data/ext/nokogiri/include/libxml2/libxml/xpath.h +566 -0
- data/ext/nokogiri/include/libxml2/libxml/xpathInternals.h +632 -0
- data/ext/nokogiri/include/libxml2/libxml/xpointer.h +114 -0
- data/ext/nokogiri/include/libxslt/attributes.h +38 -0
- data/ext/nokogiri/include/libxslt/documents.h +93 -0
- data/ext/nokogiri/include/libxslt/extensions.h +262 -0
- data/ext/nokogiri/include/libxslt/extra.h +72 -0
- data/ext/nokogiri/include/libxslt/functions.h +78 -0
- data/ext/nokogiri/include/libxslt/imports.h +75 -0
- data/ext/nokogiri/include/libxslt/keys.h +53 -0
- data/ext/nokogiri/include/libxslt/namespaces.h +68 -0
- data/ext/nokogiri/include/libxslt/numbersInternals.h +73 -0
- data/ext/nokogiri/include/libxslt/pattern.h +84 -0
- data/ext/nokogiri/include/libxslt/preproc.h +43 -0
- data/ext/nokogiri/include/libxslt/security.h +104 -0
- data/ext/nokogiri/include/libxslt/templates.h +77 -0
- data/ext/nokogiri/include/libxslt/transform.h +207 -0
- data/ext/nokogiri/include/libxslt/variables.h +118 -0
- data/ext/nokogiri/include/libxslt/xslt.h +110 -0
- data/ext/nokogiri/include/libxslt/xsltInternals.h +1978 -0
- data/ext/nokogiri/include/libxslt/xsltconfig.h +180 -0
- data/ext/nokogiri/include/libxslt/xsltexports.h +142 -0
- data/ext/nokogiri/include/libxslt/xsltlocale.h +76 -0
- data/ext/nokogiri/include/libxslt/xsltutils.h +313 -0
- data/ext/nokogiri/nokogiri.c +135 -0
- data/ext/nokogiri/nokogiri.h +130 -0
- data/ext/nokogiri/xml_attr.c +103 -0
- data/ext/nokogiri/xml_attr.h +9 -0
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +62 -0
- data/ext/nokogiri/xml_cdata.h +9 -0
- data/ext/nokogiri/xml_comment.c +69 -0
- data/ext/nokogiri/xml_comment.h +9 -0
- data/ext/nokogiri/xml_document.c +622 -0
- data/ext/nokogiri/xml_document.h +23 -0
- data/ext/nokogiri/xml_document_fragment.c +48 -0
- data/ext/nokogiri/xml_document_fragment.h +10 -0
- data/ext/nokogiri/xml_dtd.c +202 -0
- data/ext/nokogiri/xml_dtd.h +10 -0
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +52 -0
- data/ext/nokogiri/xml_entity_reference.h +9 -0
- data/ext/nokogiri/xml_io.c +63 -0
- data/ext/nokogiri/xml_io.h +11 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +111 -0
- data/ext/nokogiri/xml_namespace.h +14 -0
- data/ext/nokogiri/xml_node.c +1773 -0
- data/ext/nokogiri/xml_node.h +13 -0
- data/ext/nokogiri/xml_node_set.c +486 -0
- data/ext/nokogiri/xml_node_set.h +12 -0
- data/ext/nokogiri/xml_processing_instruction.c +56 -0
- data/ext/nokogiri/xml_processing_instruction.h +9 -0
- data/ext/nokogiri/xml_reader.c +657 -0
- data/ext/nokogiri/xml_reader.h +10 -0
- data/ext/nokogiri/xml_relax_ng.c +179 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +305 -0
- data/ext/nokogiri/xml_sax_parser.h +39 -0
- data/ext/nokogiri/xml_sax_parser_context.c +262 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +159 -0
- data/ext/nokogiri/xml_sax_push_parser.h +9 -0
- data/ext/nokogiri/xml_schema.c +276 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +64 -0
- data/ext/nokogiri/xml_syntax_error.h +13 -0
- data/ext/nokogiri/xml_text.c +52 -0
- data/ext/nokogiri/xml_text.h +9 -0
- data/ext/nokogiri/xml_xpath_context.c +374 -0
- data/ext/nokogiri/xml_xpath_context.h +10 -0
- data/ext/nokogiri/xslt_stylesheet.c +263 -0
- data/ext/nokogiri/xslt_stylesheet.h +14 -0
- data/lib/nokogiri.rb +144 -0
- data/lib/nokogiri/2.5/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.6/nokogiri.bundle +0 -0
- data/lib/nokogiri/2.7/nokogiri.bundle +0 -0
- data/lib/nokogiri/3.0/nokogiri.bundle +0 -0
- data/lib/nokogiri/css.rb +28 -0
- data/lib/nokogiri/css/node.rb +53 -0
- data/lib/nokogiri/css/parser.rb +751 -0
- data/lib/nokogiri/css/parser.y +272 -0
- data/lib/nokogiri/css/parser_extras.rb +94 -0
- data/lib/nokogiri/css/syntax_error.rb +8 -0
- data/lib/nokogiri/css/tokenizer.rb +154 -0
- data/lib/nokogiri/css/tokenizer.rex +55 -0
- data/lib/nokogiri/css/xpath_visitor.rb +260 -0
- data/lib/nokogiri/decorators/slop.rb +43 -0
- data/lib/nokogiri/html.rb +38 -0
- data/lib/nokogiri/html/builder.rb +36 -0
- data/lib/nokogiri/html/document.rb +322 -0
- data/lib/nokogiri/html/document_fragment.rb +50 -0
- data/lib/nokogiri/html/element_description.rb +24 -0
- data/lib/nokogiri/html/element_description_defaults.rb +672 -0
- data/lib/nokogiri/html/entity_lookup.rb +14 -0
- data/lib/nokogiri/html/sax/parser.rb +63 -0
- data/lib/nokogiri/html/sax/parser_context.rb +17 -0
- data/lib/nokogiri/html/sax/push_parser.rb +37 -0
- data/lib/nokogiri/jruby/dependencies.rb +20 -0
- data/lib/nokogiri/syntax_error.rb +5 -0
- data/lib/nokogiri/version.rb +3 -0
- data/lib/nokogiri/version/constant.rb +5 -0
- data/lib/nokogiri/version/info.rb +182 -0
- data/lib/nokogiri/xml.rb +76 -0
- data/lib/nokogiri/xml/attr.rb +15 -0
- data/lib/nokogiri/xml/attribute_decl.rb +19 -0
- data/lib/nokogiri/xml/builder.rb +447 -0
- data/lib/nokogiri/xml/cdata.rb +12 -0
- data/lib/nokogiri/xml/character_data.rb +8 -0
- data/lib/nokogiri/xml/document.rb +290 -0
- data/lib/nokogiri/xml/document_fragment.rb +159 -0
- data/lib/nokogiri/xml/dtd.rb +33 -0
- data/lib/nokogiri/xml/element_content.rb +37 -0
- data/lib/nokogiri/xml/element_decl.rb +14 -0
- data/lib/nokogiri/xml/entity_decl.rb +20 -0
- data/lib/nokogiri/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +14 -0
- data/lib/nokogiri/xml/node.rb +1240 -0
- data/lib/nokogiri/xml/node/save_options.rb +62 -0
- data/lib/nokogiri/xml/node_set.rb +372 -0
- data/lib/nokogiri/xml/notation.rb +7 -0
- data/lib/nokogiri/xml/parse_options.rb +127 -0
- data/lib/nokogiri/xml/pp.rb +3 -0
- data/lib/nokogiri/xml/pp/character_data.rb +19 -0
- data/lib/nokogiri/xml/pp/node.rb +57 -0
- data/lib/nokogiri/xml/processing_instruction.rb +9 -0
- data/lib/nokogiri/xml/reader.rb +116 -0
- data/lib/nokogiri/xml/relax_ng.rb +37 -0
- data/lib/nokogiri/xml/sax.rb +5 -0
- data/lib/nokogiri/xml/sax/document.rb +172 -0
- data/lib/nokogiri/xml/sax/parser.rb +123 -0
- data/lib/nokogiri/xml/sax/parser_context.rb +17 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +61 -0
- data/lib/nokogiri/xml/schema.rb +72 -0
- data/lib/nokogiri/xml/searchable.rb +239 -0
- data/lib/nokogiri/xml/syntax_error.rb +71 -0
- data/lib/nokogiri/xml/text.rb +10 -0
- data/lib/nokogiri/xml/xpath.rb +11 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +12 -0
- data/lib/nokogiri/xml/xpath_context.rb +17 -0
- data/lib/nokogiri/xslt.rb +57 -0
- data/lib/nokogiri/xslt/stylesheet.rb +26 -0
- data/lib/xsd/xmlparser/nokogiri.rb +103 -0
- metadata +499 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Nokogiri
|
3
|
+
module HTML
|
4
|
+
class EntityDescription < Struct.new(:value, :name, :description); end
|
5
|
+
|
6
|
+
class EntityLookup
|
7
|
+
###
|
8
|
+
# Look up entity with +name+
|
9
|
+
def [] name
|
10
|
+
(val = get(name)) && val.value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Nokogiri
|
3
|
+
module HTML
|
4
|
+
###
|
5
|
+
# Nokogiri lets you write a SAX parser to process HTML but get HTML
|
6
|
+
# correction features.
|
7
|
+
#
|
8
|
+
# See Nokogiri::HTML::SAX::Parser for a basic example of using a
|
9
|
+
# SAX parser with HTML.
|
10
|
+
#
|
11
|
+
# For more information on SAX parsers, see Nokogiri::XML::SAX
|
12
|
+
module SAX
|
13
|
+
###
|
14
|
+
# This class lets you perform SAX style parsing on HTML with HTML
|
15
|
+
# error correction.
|
16
|
+
#
|
17
|
+
# Here is a basic usage example:
|
18
|
+
#
|
19
|
+
# class MyDoc < Nokogiri::XML::SAX::Document
|
20
|
+
# def start_element name, attributes = []
|
21
|
+
# puts "found a #{name}"
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# parser = Nokogiri::HTML::SAX::Parser.new(MyDoc.new)
|
26
|
+
# parser.parse(File.read(ARGV[0], mode: 'rb'))
|
27
|
+
#
|
28
|
+
# For more information on SAX parsers, see Nokogiri::XML::SAX
|
29
|
+
class Parser < Nokogiri::XML::SAX::Parser
|
30
|
+
###
|
31
|
+
# Parse html stored in +data+ using +encoding+
|
32
|
+
def parse_memory data, encoding = 'UTF-8'
|
33
|
+
raise ArgumentError unless data
|
34
|
+
return unless data.length > 0
|
35
|
+
ctx = ParserContext.memory(data, encoding)
|
36
|
+
yield ctx if block_given?
|
37
|
+
ctx.parse_with self
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Parse given +io+
|
42
|
+
def parse_io io, encoding = 'UTF-8'
|
43
|
+
check_encoding(encoding)
|
44
|
+
@encoding = encoding
|
45
|
+
ctx = ParserContext.io(io, ENCODINGS[encoding])
|
46
|
+
yield ctx if block_given?
|
47
|
+
ctx.parse_with self
|
48
|
+
end
|
49
|
+
|
50
|
+
###
|
51
|
+
# Parse a file with +filename+
|
52
|
+
def parse_file filename, encoding = 'UTF-8'
|
53
|
+
raise ArgumentError unless filename
|
54
|
+
raise Errno::ENOENT unless File.exist?(filename)
|
55
|
+
raise Errno::EISDIR if File.directory?(filename)
|
56
|
+
ctx = ParserContext.file(filename, encoding)
|
57
|
+
yield ctx if block_given?
|
58
|
+
ctx.parse_with self
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Nokogiri
|
3
|
+
module HTML
|
4
|
+
module SAX
|
5
|
+
###
|
6
|
+
# Context for HTML SAX parsers. This class is usually not instantiated
|
7
|
+
# by the user. Instead, you should be looking at
|
8
|
+
# Nokogiri::HTML::SAX::Parser
|
9
|
+
class ParserContext < Nokogiri::XML::SAX::ParserContext
|
10
|
+
def self.new thing, encoding = 'UTF-8'
|
11
|
+
[:read, :close].all? { |x| thing.respond_to?(x) } ? super :
|
12
|
+
memory(thing, encoding)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Nokogiri
|
3
|
+
module HTML
|
4
|
+
module SAX
|
5
|
+
class PushParser
|
6
|
+
|
7
|
+
# The Nokogiri::HTML::SAX::Document on which the PushParser will be
|
8
|
+
# operating
|
9
|
+
attr_accessor :document
|
10
|
+
|
11
|
+
def initialize(doc = HTML::SAX::Document.new, file_name = nil, encoding = 'UTF-8')
|
12
|
+
@document = doc
|
13
|
+
@encoding = encoding
|
14
|
+
@sax_parser = HTML::SAX::Parser.new(doc, @encoding)
|
15
|
+
|
16
|
+
## Create our push parser context
|
17
|
+
initialize_native(@sax_parser, file_name, encoding)
|
18
|
+
end
|
19
|
+
|
20
|
+
###
|
21
|
+
# Write a +chunk+ of HTML to the PushParser. Any callback methods
|
22
|
+
# that can be called will be called immediately.
|
23
|
+
def write chunk, last_chunk = false
|
24
|
+
native_write(chunk, last_chunk)
|
25
|
+
end
|
26
|
+
alias :<< :write
|
27
|
+
|
28
|
+
###
|
29
|
+
# Finish the parsing. This method is only necessary for
|
30
|
+
# Nokogiri::HTML::SAX::Document#end_document to be called.
|
31
|
+
def finish
|
32
|
+
write '', true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# The line below caused a problem on non-GAE rack environment.
|
3
|
+
# unless defined?(JRuby::Rack::VERSION) || defined?(AppEngine::ApiProxy)
|
4
|
+
#
|
5
|
+
# However, simply cutting defined?(JRuby::Rack::VERSION) off resulted in
|
6
|
+
# an unable-to-load-nokogiri problem. Thus, now, Nokogiri checks the presense
|
7
|
+
# of appengine-rack.jar in $LOAD_PATH. If Nokogiri is on GAE, Nokogiri
|
8
|
+
# should skip loading xml jars. This is because those are in WEB-INF/lib and
|
9
|
+
# already set in the classpath.
|
10
|
+
unless $LOAD_PATH.to_s.include?("appengine-rack")
|
11
|
+
require 'stringio'
|
12
|
+
require 'isorelax.jar'
|
13
|
+
require 'jing.jar'
|
14
|
+
require 'nekohtml.jar'
|
15
|
+
require 'nekodtd.jar'
|
16
|
+
require 'xercesImpl.jar'
|
17
|
+
require 'serializer.jar'
|
18
|
+
require 'xalan.jar'
|
19
|
+
require 'xml-apis.jar'
|
20
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "singleton"
|
3
|
+
require "shellwords"
|
4
|
+
|
5
|
+
module Nokogiri
|
6
|
+
class VersionInfo # :nodoc:
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def jruby?
|
10
|
+
::JRUBY_VERSION if ::RUBY_PLATFORM == "java"
|
11
|
+
end
|
12
|
+
|
13
|
+
def engine
|
14
|
+
defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "mri"
|
15
|
+
end
|
16
|
+
|
17
|
+
def loaded_libxml_version
|
18
|
+
Gem::Version.new(Nokogiri::LIBXML_LOADED_VERSION
|
19
|
+
.scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first
|
20
|
+
.collect(&:to_i)
|
21
|
+
.join("."))
|
22
|
+
end
|
23
|
+
|
24
|
+
def compiled_libxml_version
|
25
|
+
Gem::Version.new(Nokogiri::LIBXML_COMPILED_VERSION)
|
26
|
+
end
|
27
|
+
|
28
|
+
def loaded_libxslt_version
|
29
|
+
Gem::Version.new(Nokogiri::LIBXSLT_LOADED_VERSION
|
30
|
+
.scan(/^(\d+)(\d\d)(\d\d)(?!\d)/).first
|
31
|
+
.collect(&:to_i)
|
32
|
+
.join("."))
|
33
|
+
end
|
34
|
+
|
35
|
+
def compiled_libxslt_version
|
36
|
+
Gem::Version.new(Nokogiri::LIBXSLT_COMPILED_VERSION)
|
37
|
+
end
|
38
|
+
|
39
|
+
def libxml2?
|
40
|
+
defined?(Nokogiri::LIBXML_COMPILED_VERSION)
|
41
|
+
end
|
42
|
+
|
43
|
+
def libxml2_has_iconv?
|
44
|
+
defined?(Nokogiri::LIBXML_ICONV_ENABLED) && Nokogiri::LIBXML_ICONV_ENABLED
|
45
|
+
end
|
46
|
+
|
47
|
+
def libxml2_using_packaged?
|
48
|
+
libxml2? && Nokogiri::PACKAGED_LIBRARIES
|
49
|
+
end
|
50
|
+
|
51
|
+
def libxml2_using_system?
|
52
|
+
libxml2? && !libxml2_using_packaged?
|
53
|
+
end
|
54
|
+
|
55
|
+
def libxml2_precompiled?
|
56
|
+
libxml2_using_packaged? && Nokogiri::PRECOMPILED_LIBRARIES
|
57
|
+
end
|
58
|
+
|
59
|
+
def warnings
|
60
|
+
warnings = []
|
61
|
+
|
62
|
+
if libxml2?
|
63
|
+
if compiled_libxml_version != loaded_libxml_version
|
64
|
+
warnings << "Nokogiri was built against libxml version #{compiled_libxml_version}, but has dynamically loaded #{loaded_libxml_version}"
|
65
|
+
end
|
66
|
+
|
67
|
+
if compiled_libxslt_version != loaded_libxslt_version
|
68
|
+
warnings << "Nokogiri was built against libxslt version #{compiled_libxslt_version}, but has dynamically loaded #{loaded_libxslt_version}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
warnings
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_hash
|
76
|
+
header_directory = File.expand_path(File.join(File.dirname(__FILE__), "../../../ext/nokogiri"))
|
77
|
+
{}.tap do |vi|
|
78
|
+
vi["warnings"] = []
|
79
|
+
vi["nokogiri"] = {}.tap do |nokogiri|
|
80
|
+
nokogiri["version"] = Nokogiri::VERSION
|
81
|
+
|
82
|
+
unless jruby?
|
83
|
+
cppflags = ["-I#{header_directory.shellescape}"]
|
84
|
+
if libxml2_using_packaged?
|
85
|
+
cppflags << "-I#{File.join(header_directory, "include").shellescape}"
|
86
|
+
cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}"
|
87
|
+
end
|
88
|
+
nokogiri["cppflags"] = cppflags
|
89
|
+
end
|
90
|
+
end
|
91
|
+
vi["ruby"] = {}.tap do |ruby|
|
92
|
+
ruby["version"] = ::RUBY_VERSION
|
93
|
+
ruby["platform"] = ::RUBY_PLATFORM
|
94
|
+
ruby["gem_platform"] = ::Gem::Platform.local.to_s
|
95
|
+
ruby["description"] = ::RUBY_DESCRIPTION
|
96
|
+
ruby["engine"] = engine
|
97
|
+
ruby["jruby"] = jruby? if jruby?
|
98
|
+
end
|
99
|
+
|
100
|
+
if libxml2?
|
101
|
+
vi["libxml"] = {}.tap do |libxml|
|
102
|
+
if libxml2_using_packaged?
|
103
|
+
libxml["source"] = "packaged"
|
104
|
+
libxml["precompiled"] = libxml2_precompiled?
|
105
|
+
libxml["patches"] = Nokogiri::LIBXML2_PATCHES
|
106
|
+
|
107
|
+
# this is for nokogumbo and shouldn't be forever
|
108
|
+
libxml["libxml2_path"] = header_directory
|
109
|
+
else
|
110
|
+
libxml["source"] = "system"
|
111
|
+
end
|
112
|
+
libxml["iconv_enabled"] = libxml2_has_iconv?
|
113
|
+
libxml["compiled"] = compiled_libxml_version.to_s
|
114
|
+
libxml["loaded"] = loaded_libxml_version.to_s
|
115
|
+
end
|
116
|
+
|
117
|
+
vi["libxslt"] = {}.tap do |libxslt|
|
118
|
+
if libxml2_using_packaged?
|
119
|
+
libxslt["source"] = "packaged"
|
120
|
+
libxslt["precompiled"] = libxml2_precompiled?
|
121
|
+
libxslt["patches"] = Nokogiri::LIBXSLT_PATCHES
|
122
|
+
else
|
123
|
+
libxslt["source"] = "system"
|
124
|
+
end
|
125
|
+
libxslt["compiled"] = compiled_libxslt_version.to_s
|
126
|
+
libxslt["loaded"] = loaded_libxslt_version.to_s
|
127
|
+
end
|
128
|
+
|
129
|
+
vi["warnings"] = warnings
|
130
|
+
end
|
131
|
+
|
132
|
+
if defined?(Nokogiri::OTHER_LIBRARY_VERSIONS)
|
133
|
+
# see extconf for how this string is assembled: "lib1name:lib1version,lib2name:lib2version"
|
134
|
+
vi["other_libraries"] = Hash[*Nokogiri::OTHER_LIBRARY_VERSIONS.split(/[,:]/)]
|
135
|
+
elsif jruby?
|
136
|
+
vi["other_libraries"] = {}.tap do |ol|
|
137
|
+
ol["xerces"] = Nokogiri::XERCES_VERSION
|
138
|
+
ol["nekohtml"] = Nokogiri::NEKO_VERSION
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def to_markdown
|
145
|
+
begin
|
146
|
+
require "psych"
|
147
|
+
rescue LoadError
|
148
|
+
end
|
149
|
+
require "yaml"
|
150
|
+
"# Nokogiri (#{Nokogiri::VERSION})\n" +
|
151
|
+
YAML.dump(to_hash).each_line.map { |line| " #{line}" }.join
|
152
|
+
end
|
153
|
+
|
154
|
+
instance.warnings.each do |warning|
|
155
|
+
warn "WARNING: #{warning}"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.uses_libxml?(requirement = nil) # :nodoc:
|
160
|
+
return false unless VersionInfo.instance.libxml2?
|
161
|
+
return true unless requirement
|
162
|
+
Gem::Requirement.new(requirement).satisfied_by?(VersionInfo.instance.loaded_libxml_version)
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.jruby? # :nodoc:
|
166
|
+
VersionInfo.instance.jruby?
|
167
|
+
end
|
168
|
+
|
169
|
+
# Ensure constants used in this file are loaded - see #1896
|
170
|
+
if Nokogiri.jruby?
|
171
|
+
require "nokogiri/jruby/dependencies"
|
172
|
+
end
|
173
|
+
begin
|
174
|
+
::RUBY_VERSION =~ /(\d+\.\d+)/
|
175
|
+
require "nokogiri/#{Regexp.last_match(1)}/nokogiri"
|
176
|
+
rescue LoadError
|
177
|
+
require "nokogiri/nokogiri"
|
178
|
+
end
|
179
|
+
|
180
|
+
# More complete version information about libxml
|
181
|
+
VERSION_INFO = VersionInfo.instance.to_hash
|
182
|
+
end
|
data/lib/nokogiri/xml.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'nokogiri/xml/pp'
|
3
|
+
require 'nokogiri/xml/parse_options'
|
4
|
+
require 'nokogiri/xml/sax'
|
5
|
+
require 'nokogiri/xml/searchable'
|
6
|
+
require 'nokogiri/xml/node'
|
7
|
+
require 'nokogiri/xml/attribute_decl'
|
8
|
+
require 'nokogiri/xml/element_decl'
|
9
|
+
require 'nokogiri/xml/element_content'
|
10
|
+
require 'nokogiri/xml/character_data'
|
11
|
+
require 'nokogiri/xml/namespace'
|
12
|
+
require 'nokogiri/xml/attr'
|
13
|
+
require 'nokogiri/xml/dtd'
|
14
|
+
require 'nokogiri/xml/cdata'
|
15
|
+
require 'nokogiri/xml/text'
|
16
|
+
require 'nokogiri/xml/document'
|
17
|
+
require 'nokogiri/xml/document_fragment'
|
18
|
+
require 'nokogiri/xml/processing_instruction'
|
19
|
+
require 'nokogiri/xml/node_set'
|
20
|
+
require 'nokogiri/xml/syntax_error'
|
21
|
+
require 'nokogiri/xml/xpath'
|
22
|
+
require 'nokogiri/xml/xpath_context'
|
23
|
+
require 'nokogiri/xml/builder'
|
24
|
+
require 'nokogiri/xml/reader'
|
25
|
+
require 'nokogiri/xml/notation'
|
26
|
+
require 'nokogiri/xml/entity_decl'
|
27
|
+
require 'nokogiri/xml/entity_reference'
|
28
|
+
require 'nokogiri/xml/schema'
|
29
|
+
require 'nokogiri/xml/relax_ng'
|
30
|
+
|
31
|
+
module Nokogiri
|
32
|
+
class << self
|
33
|
+
###
|
34
|
+
# Parse XML. Convenience method for Nokogiri::XML::Document.parse
|
35
|
+
def XML thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block
|
36
|
+
Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module XML
|
41
|
+
# Original C14N 1.0 spec canonicalization
|
42
|
+
XML_C14N_1_0 = 0
|
43
|
+
# Exclusive C14N 1.0 spec canonicalization
|
44
|
+
XML_C14N_EXCLUSIVE_1_0 = 1
|
45
|
+
# C14N 1.1 spec canonicalization
|
46
|
+
XML_C14N_1_1 = 2
|
47
|
+
class << self
|
48
|
+
###
|
49
|
+
# Parse an XML document using the Nokogiri::XML::Reader API. See
|
50
|
+
# Nokogiri::XML::Reader for mor information
|
51
|
+
def Reader string_or_io, url = nil, encoding = nil, options = ParseOptions::STRICT
|
52
|
+
|
53
|
+
options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
|
54
|
+
# Give the options to the user
|
55
|
+
yield options if block_given?
|
56
|
+
|
57
|
+
if string_or_io.respond_to? :read
|
58
|
+
return Reader.from_io(string_or_io, url, encoding, options.to_i)
|
59
|
+
end
|
60
|
+
Reader.from_memory(string_or_io, url, encoding, options.to_i)
|
61
|
+
end
|
62
|
+
|
63
|
+
###
|
64
|
+
# Parse XML. Convenience method for Nokogiri::XML::Document.parse
|
65
|
+
def parse thing, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML, &block
|
66
|
+
Document.parse(thing, url, encoding, options, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
####
|
70
|
+
# Parse a fragment from +string+ in to a NodeSet.
|
71
|
+
def fragment string
|
72
|
+
XML::DocumentFragment.parse(string)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|