nokogiri 1.11.0.rc4-java → 1.11.5-java

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.

Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/LICENSE-DEPENDENCIES.md +12 -12
  4. data/LICENSE.md +1 -1
  5. data/README.md +168 -91
  6. data/dependencies.yml +12 -12
  7. data/ext/java/nokogiri/EncodingHandler.java +76 -89
  8. data/ext/java/nokogiri/HtmlDocument.java +135 -144
  9. data/ext/java/nokogiri/HtmlElementDescription.java +102 -117
  10. data/ext/java/nokogiri/HtmlEntityLookup.java +33 -60
  11. data/ext/java/nokogiri/HtmlSaxParserContext.java +218 -222
  12. data/ext/java/nokogiri/HtmlSaxPushParser.java +162 -169
  13. data/ext/java/nokogiri/NokogiriService.java +595 -556
  14. data/ext/java/nokogiri/XmlAttr.java +118 -126
  15. data/ext/java/nokogiri/XmlAttributeDecl.java +95 -106
  16. data/ext/java/nokogiri/XmlCdata.java +35 -58
  17. data/ext/java/nokogiri/XmlComment.java +46 -67
  18. data/ext/java/nokogiri/XmlDocument.java +645 -572
  19. data/ext/java/nokogiri/XmlDocumentFragment.java +125 -137
  20. data/ext/java/nokogiri/XmlDtd.java +448 -414
  21. data/ext/java/nokogiri/XmlElement.java +23 -48
  22. data/ext/java/nokogiri/XmlElementContent.java +343 -316
  23. data/ext/java/nokogiri/XmlElementDecl.java +124 -125
  24. data/ext/java/nokogiri/XmlEntityDecl.java +119 -127
  25. data/ext/java/nokogiri/XmlEntityReference.java +49 -72
  26. data/ext/java/nokogiri/XmlNamespace.java +175 -175
  27. data/ext/java/nokogiri/XmlNode.java +1843 -1620
  28. data/ext/java/nokogiri/XmlNodeSet.java +361 -331
  29. data/ext/java/nokogiri/XmlProcessingInstruction.java +47 -69
  30. data/ext/java/nokogiri/XmlReader.java +513 -450
  31. data/ext/java/nokogiri/XmlRelaxng.java +85 -104
  32. data/ext/java/nokogiri/XmlSaxParserContext.java +328 -315
  33. data/ext/java/nokogiri/XmlSaxPushParser.java +227 -220
  34. data/ext/java/nokogiri/XmlSchema.java +328 -295
  35. data/ext/java/nokogiri/XmlSyntaxError.java +113 -115
  36. data/ext/java/nokogiri/XmlText.java +55 -76
  37. data/ext/java/nokogiri/XmlXpathContext.java +240 -238
  38. data/ext/java/nokogiri/XsltStylesheet.java +280 -269
  39. data/ext/java/nokogiri/internals/ClosedStreamException.java +5 -2
  40. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +201 -202
  41. data/ext/java/nokogiri/internals/IgnoreSchemaErrorsErrorHandler.java +17 -10
  42. data/ext/java/nokogiri/internals/NokogiriBlockingQueueInputStream.java +43 -16
  43. data/ext/java/nokogiri/internals/NokogiriDomParser.java +63 -80
  44. data/ext/java/nokogiri/internals/NokogiriEntityResolver.java +107 -88
  45. data/ext/java/nokogiri/internals/NokogiriErrorHandler.java +27 -52
  46. data/ext/java/nokogiri/internals/NokogiriHandler.java +316 -286
  47. data/ext/java/nokogiri/internals/NokogiriHelpers.java +736 -652
  48. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +184 -173
  49. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +81 -98
  50. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler.java +64 -79
  51. data/ext/java/nokogiri/internals/NokogiriNonStrictErrorHandler4NekoHtml.java +84 -99
  52. data/ext/java/nokogiri/internals/NokogiriStrictErrorHandler.java +48 -65
  53. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +116 -131
  54. data/ext/java/nokogiri/internals/NokogiriXPathFunctionResolver.java +34 -56
  55. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +23 -46
  56. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +55 -72
  57. data/ext/java/nokogiri/internals/ParserContext.java +206 -211
  58. data/ext/java/nokogiri/internals/ReaderNode.java +478 -403
  59. data/ext/java/nokogiri/internals/SaveContextVisitor.java +822 -739
  60. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +31 -54
  61. data/ext/java/nokogiri/internals/XalanDTMManagerPatch.java +129 -123
  62. data/ext/java/nokogiri/internals/XmlDeclHandler.java +3 -34
  63. data/ext/java/nokogiri/internals/XmlDomParserContext.java +206 -207
  64. data/ext/java/nokogiri/internals/XmlSaxParser.java +22 -47
  65. data/ext/java/nokogiri/internals/c14n/AttrCompare.java +71 -68
  66. data/ext/java/nokogiri/internals/c14n/C14nHelper.java +137 -118
  67. data/ext/java/nokogiri/internals/c14n/CanonicalFilter.java +27 -21
  68. data/ext/java/nokogiri/internals/c14n/CanonicalizationException.java +74 -61
  69. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +230 -205
  70. data/ext/java/nokogiri/internals/c14n/Canonicalizer11.java +572 -547
  71. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_OmitComments.java +17 -10
  72. data/ext/java/nokogiri/internals/c14n/Canonicalizer11_WithComments.java +17 -10
  73. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java +323 -302
  74. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java +232 -219
  75. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclOmitComments.java +22 -15
  76. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315ExclWithComments.java +23 -16
  77. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315OmitComments.java +23 -16
  78. data/ext/java/nokogiri/internals/c14n/Canonicalizer20010315WithComments.java +22 -15
  79. data/ext/java/nokogiri/internals/c14n/CanonicalizerBase.java +575 -545
  80. data/ext/java/nokogiri/internals/c14n/CanonicalizerPhysical.java +141 -120
  81. data/ext/java/nokogiri/internals/c14n/CanonicalizerSpi.java +39 -38
  82. data/ext/java/nokogiri/internals/c14n/Constants.java +13 -10
  83. data/ext/java/nokogiri/internals/c14n/ElementProxy.java +279 -247
  84. data/ext/java/nokogiri/internals/c14n/HelperNodeList.java +66 -53
  85. data/ext/java/nokogiri/internals/c14n/IgnoreAllErrorHandler.java +44 -37
  86. data/ext/java/nokogiri/internals/c14n/InclusiveNamespaces.java +135 -120
  87. data/ext/java/nokogiri/internals/c14n/InvalidCanonicalizerException.java +59 -48
  88. data/ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java +384 -334
  89. data/ext/java/nokogiri/internals/c14n/NodeFilter.java +25 -24
  90. data/ext/java/nokogiri/internals/c14n/UtfHelpper.java +151 -140
  91. data/ext/java/nokogiri/internals/c14n/XMLUtils.java +456 -423
  92. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +1466 -1500
  93. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTMdefaultNamespaceDeclarationNode.java +626 -574
  94. data/ext/nokogiri/depend +34 -474
  95. data/ext/nokogiri/extconf.rb +270 -183
  96. data/ext/nokogiri/html_document.c +10 -15
  97. data/ext/nokogiri/html_element_description.c +84 -71
  98. data/ext/nokogiri/html_entity_lookup.c +21 -16
  99. data/ext/nokogiri/html_sax_parser_context.c +67 -64
  100. data/ext/nokogiri/html_sax_push_parser.c +42 -34
  101. data/ext/nokogiri/libxml2_backwards_compat.c +121 -0
  102. data/ext/nokogiri/nokogiri.c +190 -60
  103. data/ext/nokogiri/test_global_handlers.c +40 -0
  104. data/ext/nokogiri/xml_attr.c +15 -15
  105. data/ext/nokogiri/xml_attribute_decl.c +18 -18
  106. data/ext/nokogiri/xml_cdata.c +13 -18
  107. data/ext/nokogiri/xml_comment.c +19 -26
  108. data/ext/nokogiri/xml_document.c +246 -188
  109. data/ext/nokogiri/xml_document_fragment.c +13 -15
  110. data/ext/nokogiri/xml_dtd.c +54 -48
  111. data/ext/nokogiri/xml_element_content.c +30 -27
  112. data/ext/nokogiri/xml_element_decl.c +22 -22
  113. data/ext/nokogiri/xml_encoding_handler.c +17 -11
  114. data/ext/nokogiri/xml_entity_decl.c +32 -30
  115. data/ext/nokogiri/xml_entity_reference.c +16 -18
  116. data/ext/nokogiri/xml_namespace.c +56 -49
  117. data/ext/nokogiri/xml_node.c +371 -320
  118. data/ext/nokogiri/xml_node_set.c +168 -156
  119. data/ext/nokogiri/xml_processing_instruction.c +17 -19
  120. data/ext/nokogiri/xml_reader.c +191 -157
  121. data/ext/nokogiri/xml_relax_ng.c +29 -23
  122. data/ext/nokogiri/xml_sax_parser.c +117 -112
  123. data/ext/nokogiri/xml_sax_parser_context.c +101 -84
  124. data/ext/nokogiri/xml_sax_push_parser.c +36 -27
  125. data/ext/nokogiri/xml_schema.c +48 -42
  126. data/ext/nokogiri/xml_syntax_error.c +42 -21
  127. data/ext/nokogiri/xml_text.c +13 -17
  128. data/ext/nokogiri/xml_xpath_context.c +134 -127
  129. data/ext/nokogiri/xslt_stylesheet.c +157 -157
  130. data/lib/nokogiri.rb +2 -6
  131. data/lib/nokogiri/css/parser.rb +1 -1
  132. data/lib/nokogiri/extension.rb +26 -0
  133. data/lib/nokogiri/html/document_fragment.rb +15 -15
  134. data/lib/nokogiri/nokogiri.jar +0 -0
  135. data/lib/nokogiri/version/constant.rb +1 -1
  136. data/lib/nokogiri/version/info.rb +32 -8
  137. data/lib/nokogiri/xml/document.rb +74 -28
  138. data/lib/nokogiri/xml/node.rb +39 -42
  139. data/lib/nokogiri/xml/reader.rb +2 -9
  140. data/lib/nokogiri/xml/xpath.rb +1 -3
  141. data/lib/nokogiri/xml/xpath/syntax_error.rb +1 -1
  142. metadata +62 -127
  143. data/ext/nokogiri/xml_io.c +0 -63
  144. data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Nokogiri
3
3
  # The version of Nokogiri you are using
4
- VERSION = "1.11.0.rc4"
4
+ VERSION = "1.11.5"
5
5
  end
@@ -10,6 +10,14 @@ module Nokogiri
10
10
  ::JRUBY_VERSION if ::RUBY_PLATFORM == "java"
11
11
  end
12
12
 
13
+ def windows?
14
+ ::RUBY_PLATFORM =~ /mingw|mswin/
15
+ end
16
+
17
+ def ruby_minor
18
+ Gem::Version.new(::RUBY_VERSION).segments[0..1].join(".")
19
+ end
20
+
13
21
  def engine
14
22
  defined?(::RUBY_ENGINE) ? ::RUBY_ENGINE : "mri"
15
23
  end
@@ -74,18 +82,38 @@ module Nokogiri
74
82
 
75
83
  def to_hash
76
84
  header_directory = File.expand_path(File.join(File.dirname(__FILE__), "../../../ext/nokogiri"))
85
+
77
86
  {}.tap do |vi|
78
87
  vi["warnings"] = []
79
88
  vi["nokogiri"] = {}.tap do |nokogiri|
80
89
  nokogiri["version"] = Nokogiri::VERSION
81
90
 
82
91
  unless jruby?
92
+ # enable gems like nokogumbo to build with the following in their extconf.rb:
93
+ #
94
+ # append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"])
95
+ # append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"])
96
+ #
83
97
  cppflags = ["-I#{header_directory.shellescape}"]
98
+ ldflags = []
99
+
84
100
  if libxml2_using_packaged?
85
- cppflags << "-I#{File.join(header_directory, "include").shellescape}"
86
- cppflags << "-I#{File.join(header_directory, "include/libxml2").shellescape}"
101
+ cppflags << "-I#{File.join(header_directory, 'include').shellescape}"
102
+ cppflags << "-I#{File.join(header_directory, 'include/libxml2').shellescape}"
103
+
104
+ if windows?
105
+ # on windows, nokogumbo needs to link against nokogiri.so to resolve symbols. see #2167
106
+ lib_directory = File.expand_path(File.join(File.dirname(__FILE__), "../#{ruby_minor}"))
107
+ unless File.exist?(lib_directory)
108
+ lib_directory = File.expand_path(File.join(File.dirname(__FILE__), ".."))
109
+ end
110
+ ldflags << "-L#{lib_directory.shellescape}"
111
+ ldflags << "-l:nokogiri.so"
112
+ end
87
113
  end
114
+
88
115
  nokogiri["cppflags"] = cppflags
116
+ nokogiri["ldflags"] = ldflags
89
117
  end
90
118
  end
91
119
  vi["ruby"] = {}.tap do |ruby|
@@ -109,6 +137,7 @@ module Nokogiri
109
137
  else
110
138
  libxml["source"] = "system"
111
139
  end
140
+ libxml["memory_management"] = Nokogiri::LIBXML_MEMORY_MANAGEMENT
112
141
  libxml["iconv_enabled"] = libxml2_has_iconv?
113
142
  libxml["compiled"] = compiled_libxml_version.to_s
114
143
  libxml["loaded"] = loaded_libxml_version.to_s
@@ -170,12 +199,7 @@ module Nokogiri
170
199
  if Nokogiri.jruby?
171
200
  require "nokogiri/jruby/dependencies"
172
201
  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
202
+ require "nokogiri/extension"
179
203
 
180
204
  # More complete version information about libxml
181
205
  VERSION_INFO = VersionInfo.instance.to_hash
@@ -1,3 +1,4 @@
1
+ # coding: utf-8
1
2
  # frozen_string_literal: true
2
3
 
3
4
  require 'pathname'
@@ -13,11 +14,12 @@ module Nokogiri
13
14
  # Nokogiri::XML::Searchable#xpath
14
15
  #
15
16
  class Document < Nokogiri::XML::Node
16
- # I'm ignoring unicode characters here.
17
- # See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details.
17
+ # See http://www.w3.org/TR/REC-xml-names/#ns-decl for more details. Note that we're not
18
+ # attempting to handle unicode characters partly because libxml2 doesn't handle unicode
19
+ # characters in NCNAMEs.
18
20
  NCNAME_START_CHAR = "A-Za-z_"
19
- NCNAME_CHAR = NCNAME_START_CHAR + "\\-.0-9"
20
- NCNAME_RE = /^xmlns(:[#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*)?$/
21
+ NCNAME_CHAR = NCNAME_START_CHAR + "\\-\\.0-9"
22
+ NCNAME_RE = /^xmlns(?::([#{NCNAME_START_CHAR}][#{NCNAME_CHAR}]*))?$/
21
23
 
22
24
  ##
23
25
  # Parse an XML file.
@@ -79,6 +81,35 @@ module Nokogiri
79
81
  return doc
80
82
  end
81
83
 
84
+ ##
85
+ # @!method wrap(java_document)
86
+ # @!scope class
87
+ #
88
+ # Create a {Document} using an existing Java DOM document object.
89
+ #
90
+ # The returned {Document} shares the same underlying data structure as the Java object, so
91
+ # changes in one are reflected in the other.
92
+ #
93
+ # @param java_document [Java::OrgW3cDom::Document]
94
+ # @return [Nokogiri::XML::Document]
95
+ # @note This method is only available when running JRuby.
96
+ # @note The class +Java::OrgW3cDom::Document+ is also accessible as +org.w3c.dom.Document+.
97
+ # @see #to_java
98
+
99
+ ##
100
+ # @!method to_java()
101
+ #
102
+ # Returns the underlying Java DOM document object for the {Document}.
103
+ #
104
+ # The returned Java object shares the same underlying data structure as the {Document}, so
105
+ # changes in one are reflected in the other.
106
+ #
107
+ # @return [Java::OrgW3cDom::Document]
108
+ # @note This method is only available when running JRuby.
109
+ # @note The class +Java::OrgW3cDom::Document+ is also accessible as +org.w3c.dom.Document+.
110
+ # @see .wrap
111
+
112
+
82
113
  # A list of Nokogiri::XML::SyntaxError found when parsing a document
83
114
  attr_accessor :errors
84
115
 
@@ -88,33 +119,58 @@ module Nokogiri
88
119
  end
89
120
 
90
121
  ##
91
- # Create an element with +name+, and optionally setting the content and attributes.
122
+ # Create a new +Element+ with +name+ sharing GC lifecycle with the document, optionally
123
+ # setting contents or attributes.
124
+ #
125
+ # Arguments may be passed to initialize the element:
126
+ # - a +Hash+ argument will be used to set attributes
127
+ # - a non-Hash object that responds to +#to_s+ will be used to set the new node's contents
92
128
  #
93
- # doc.create_element "div" # <div></div>
94
- # doc.create_element "div", :class => "container" # <div class='container'></div>
95
- # doc.create_element "div", "contents" # <div>contents</div>
96
- # doc.create_element "div", "contents", :class => "container" # <div class='container'>contents</div>
97
- # doc.create_element "div" { |node| node['class'] = "container" } # <div class='container'></div>
129
+ # A block may be passed to mutate the node.
98
130
  #
99
- def create_element name, *args, &block
131
+ # @param name [String]
132
+ # @param contents_or_attrs [#to_s,Hash]
133
+ # @yieldparam node [Nokogiri::XML::Element]
134
+ # @return [Nokogiri::XML::Element]
135
+ #
136
+ # @example An empty element without attributes
137
+ # doc.create_element("div")
138
+ # # => <div></div>
139
+ #
140
+ # @example An element with contents
141
+ # doc.create_element("div", "contents")
142
+ # # => <div>contents</div>
143
+ #
144
+ # @example An element with attributes
145
+ # doc.create_element("div", {"class" => "container"})
146
+ # # => <div class='container'></div>
147
+ #
148
+ # @example An element with contents and attributes
149
+ # doc.create_element("div", "contents", {"class" => "container"})
150
+ # # => <div class='container'>contents</div>
151
+ #
152
+ # @example Passing a block to mutate the element
153
+ # doc.create_element("div") { |node| node["class"] = "blue" if before_noon? }
154
+ #
155
+ def create_element(name, *contents_or_attrs, &block)
100
156
  elm = Nokogiri::XML::Element.new(name, self, &block)
101
- args.each do |arg|
157
+ contents_or_attrs.each do |arg|
102
158
  case arg
103
159
  when Hash
104
- arg.each { |k,v|
160
+ arg.each do |k, v|
105
161
  key = k.to_s
106
162
  if key =~ NCNAME_RE
107
- ns_name = key.split(":", 2)[1]
108
- elm.add_namespace_definition ns_name, v
163
+ ns_name = Regexp.last_match(1)
164
+ elm.add_namespace_definition(ns_name, v)
109
165
  else
110
166
  elm[k.to_s] = v.to_s
111
167
  end
112
- }
168
+ end
113
169
  else
114
170
  elm.content = arg
115
171
  end
116
172
  end
117
- if ns = elm.namespace_definitions.find { |n| n.prefix.nil? or n.prefix == '' }
173
+ if ns = elm.namespace_definitions.find { |n| n.prefix.nil? || (n.prefix == '') }
118
174
  elm.namespace = ns
119
175
  end
120
176
  elm
@@ -262,24 +318,14 @@ module Nokogiri
262
318
  end
263
319
  alias :<< :add_child
264
320
 
265
- ##
266
- # +JRuby+
267
- # Wraps Java's org.w3c.dom.document and returns Nokogiri::XML::Document
268
- def self.wrap(document) end if false # native-ext provides Document.wrap
269
-
270
- ##
271
- # +JRuby+
272
- # Returns Java's org.w3c.dom.document of this Document.
273
- def to_java; end if false # JRuby provides #to_java
274
-
275
321
  private
322
+
276
323
  def self.empty_doc? string_or_io
277
324
  string_or_io.nil? ||
278
325
  (string_or_io.respond_to?(:empty?) && string_or_io.empty?) ||
279
326
  (string_or_io.respond_to?(:eof?) && string_or_io.eof?)
280
327
  end
281
328
 
282
- # @private
283
329
  IMPLIED_XPATH_CONTEXTS = [ '//'.freeze ].freeze # :nodoc:
284
330
 
285
331
  def inspect_attributes
@@ -5,64 +5,54 @@ require "nokogiri/xml/node/save_options"
5
5
 
6
6
  module Nokogiri
7
7
  module XML
8
- ####
9
- # Nokogiri::XML::Node is your window to the fun filled world of dealing
10
- # with XML and HTML tags. A Nokogiri::XML::Node may be treated similarly
11
- # to a hash with regard to attributes. For example (from irb):
8
+ ##
9
+ # {Nokogiri::XML::Node} is your window to the fun filled world of dealing with XML and HTML
10
+ # tags. A {Nokogiri::XML::Node} may be treated similarly to a hash with regard to attributes. For
11
+ # example:
12
12
  #
13
- # irb(main):004:0> node
14
- # => <a href="#foo" id="link">link</a>
15
- # irb(main):005:0> node['href']
16
- # => "#foo"
17
- # irb(main):006:0> node.keys
18
- # => ["href", "id"]
19
- # irb(main):007:0> node.values
20
- # => ["#foo", "link"]
21
- # irb(main):008:0> node['class'] = 'green'
22
- # => "green"
23
- # irb(main):009:0> node
24
- # => <a href="#foo" id="link" class="green">link</a>
25
- # irb(main):010:0>
13
+ # node = Nokogiri::XML::DocumentFragment.parse("<a href='#foo' id='link'>link</a>").at_css("a")
14
+ # node.to_html # => "<a href=\"#foo\" id=\"link\">link</a>"
15
+ # node['href'] # => "#foo"
16
+ # node.keys # => ["href", "id"]
17
+ # node.values # => ["#foo", "link"]
18
+ # node['class'] = 'green' # => "green"
19
+ # node.to_html # => "<a href=\"#foo\" id=\"link\" class=\"green\">link</a>"
26
20
  #
27
- # See Nokogiri::XML::Node#[] and Nokogiri::XML#[]= for more information.
21
+ # See the method group entitled "Working With Node Attributes" for the full set of methods.
28
22
  #
29
- # Nokogiri::XML::Node also has methods that let you move around your
23
+ # {Nokogiri::XML::Node} also has methods that let you move around your
30
24
  # tree. For navigating your tree, see:
31
25
  #
32
- # * Nokogiri::XML::Node#parent
33
- # * Nokogiri::XML::Node#children
34
- # * Nokogiri::XML::Node#next
35
- # * Nokogiri::XML::Node#previous
36
- #
26
+ # * {#parent}
27
+ # * {#children}
28
+ # * {#next}
29
+ # * {#previous}
37
30
  #
38
31
  # When printing or otherwise emitting a document or a node (and
39
32
  # its subtree), there are a few methods you might want to use:
40
33
  #
41
- # * content, text, inner_text, to_str: emit plaintext
42
- #
43
- # These methods will all emit the plaintext version of your
44
- # document, meaning that entities will be replaced (e.g., "&lt;"
45
- # will be replaced with "<"), meaning that any sanitizing will
46
- # likely be un-done in the output.
34
+ # * {#content}, {#text}, {#inner_text}, {#to_str}: These methods will all <b>emit plaintext</b>,
35
+ # meaning that entities will be replaced (e.g., "&lt;" will be replaced with "<"), meaning
36
+ # that any sanitizing will likely be un-done in the output.
47
37
  #
48
- # * to_s, to_xml, to_html, inner_html: emit well-formed markup
38
+ # * {#to_s}, {#to_xml}, {#to_html}, {#inner_html}: These methods will all <b>emit
39
+ # properly-escaped markup</b>, meaning that it's suitable for consumption by browsers,
40
+ # parsers, etc.
49
41
  #
50
- # These methods will all emit properly-escaped markup, meaning
51
- # that it's suitable for consumption by browsers, parsers, etc.
42
+ # You may search this node's subtree using {#xpath} and {#css}
52
43
  #
53
- # You may search this node's subtree using Searchable#xpath and Searchable#css
54
44
  class Node
55
45
  include Nokogiri::XML::PP::Node
56
46
  include Nokogiri::XML::Searchable
57
47
  include Enumerable
58
48
 
59
- # Element node type, see Nokogiri::XML::Node#element?
49
+ # Element node type, see {Nokogiri::XML::Node#element?}
60
50
  ELEMENT_NODE = 1
61
51
  # Attribute node type
62
52
  ATTRIBUTE_NODE = 2
63
- # Text node type, see Nokogiri::XML::Node#text?
53
+ # Text node type, see {Nokogiri::XML::Node#text?}
64
54
  TEXT_NODE = 3
65
- # CDATA node type, see Nokogiri::XML::Node#cdata?
55
+ # CDATA node type, see {Nokogiri::XML::Node#cdata?}
66
56
  CDATA_SECTION_NODE = 4
67
57
  # Entity reference node type
68
58
  ENTITY_REF_NODE = 5
@@ -70,9 +60,9 @@ module Nokogiri
70
60
  ENTITY_NODE = 6
71
61
  # PI node type
72
62
  PI_NODE = 7
73
- # Comment node type, see Nokogiri::XML::Node#comment?
63
+ # Comment node type, see {Nokogiri::XML::Node#comment?}
74
64
  COMMENT_NODE = 8
75
- # Document node type, see Nokogiri::XML::Node#xml?
65
+ # Document node type, see {Nokogiri::XML::Node#xml?}
76
66
  DOCUMENT_NODE = 9
77
67
  # Document type node type
78
68
  DOCUMENT_TYPE_NODE = 10
@@ -80,7 +70,7 @@ module Nokogiri
80
70
  DOCUMENT_FRAG_NODE = 11
81
71
  # Notation node type
82
72
  NOTATION_NODE = 12
83
- # HTML document node type, see Nokogiri::XML::Node#html?
73
+ # HTML document node type, see {Nokogiri::XML::Node#html?}
84
74
  HTML_DOCUMENT_NODE = 13
85
75
  # DTD node type
86
76
  DTD_NODE = 14
@@ -99,8 +89,15 @@ module Nokogiri
99
89
  # DOCB document node type
100
90
  DOCB_DOCUMENT_NODE = 21
101
91
 
102
- def initialize(name, document) # :nodoc:
103
- # ... Ya. This is empty on purpose.
92
+ ##
93
+ # Create a new node with +name+ sharing GC lifecycle with +document+.
94
+ # @param name [String]
95
+ # @param document [Nokogiri::XML::Document]
96
+ # @yieldparam node [Nokogiri::XML::Node]
97
+ # @return [Nokogiri::XML::Node]
98
+ # @see Nokogiri::XML::Node.new
99
+ def initialize(name, document)
100
+ # This is intentionally empty.
104
101
  end
105
102
 
106
103
  ###
@@ -86,7 +86,8 @@ module Nokogiri
86
86
  private :initialize
87
87
 
88
88
  ###
89
- # Get a list of attributes for the current node.
89
+ # Get the attributes of the current node as a Hash
90
+ # @return [Hash<String, String>] Attribute names and values
90
91
  def attributes
91
92
  attrs_hash = attribute_nodes.each_with_object({}) do |node, hash|
92
93
  hash[node.name] = node.to_s
@@ -96,14 +97,6 @@ module Nokogiri
96
97
  attrs_hash
97
98
  end
98
99
 
99
- ###
100
- # Get a list of attributes for the current node
101
- def attribute_nodes
102
- nodes = attr_nodes
103
- nodes.each { |v| v.instance_variable_set(:@_r, self) }
104
- nodes
105
- end
106
-
107
100
  ###
108
101
  # Move the cursor through the document yielding the cursor to the block
109
102
  def each
@@ -3,9 +3,7 @@ require 'nokogiri/xml/xpath/syntax_error'
3
3
 
4
4
  module Nokogiri
5
5
  module XML
6
- class XPath
7
- # The Nokogiri::XML::Document tied to this XPath instance
8
- attr_accessor :document
6
+ module XPath
9
7
  end
10
8
  end
11
9
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  module Nokogiri
3
3
  module XML
4
- class XPath
4
+ module XPath
5
5
  class SyntaxError < XML::SyntaxError
6
6
  def to_s
7
7
  [super.chomp, str1].compact.join(': ')
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0.rc4
4
+ version: 1.11.5
5
5
  platform: java
6
6
  authors:
7
7
  - Mike Dalessio
8
8
  - Aaron Patterson
9
- - John Shahid
10
9
  - Yoko Harada
11
10
  - Akinori MUSHA
11
+ - John Shahid
12
+ - Karol Bucek
12
13
  - Lars Kanis
13
- - Tim Elliott
14
+ - Sergio Arbeo
15
+ - Timothy Elliott
16
+ - Nobuyoshi Nakada
14
17
  autorequire:
15
18
  bindir: bin
16
19
  cert_chain: []
17
- date: 2020-12-29 00:00:00.000000000 Z
20
+ date: 2021-05-20 00:00:00.000000000 Z
18
21
  dependencies:
19
22
  - !ruby/object:Gem::Dependency
20
23
  requirement: !ruby/object:Gem::Requirement
@@ -35,97 +38,35 @@ dependencies:
35
38
  requirements:
36
39
  - - "~>"
37
40
  - !ruby/object:Gem::Version
38
- version: '0.41'
39
- name: concourse
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '0.41'
47
- - !ruby/object:Gem::Dependency
48
- requirement: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - "~>"
51
- - !ruby/object:Gem::Version
52
- version: '3.22'
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: 3.22.1
56
- name: hoe
57
- type: :development
58
- prerelease: false
59
- version_requirements: !ruby/object:Gem::Requirement
60
- requirements:
61
- - - "~>"
62
- - !ruby/object:Gem::Version
63
- version: '3.22'
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: 3.22.1
67
- - !ruby/object:Gem::Dependency
68
- requirement: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - "~>"
71
- - !ruby/object:Gem::Version
72
- version: '1.2'
73
- name: hoe-bundler
41
+ version: '2.2'
42
+ name: bundler
74
43
  type: :development
75
44
  prerelease: false
76
45
  version_requirements: !ruby/object:Gem::Requirement
77
46
  requirements:
78
47
  - - "~>"
79
48
  - !ruby/object:Gem::Version
80
- version: '1.2'
49
+ version: '2.2'
81
50
  - !ruby/object:Gem::Dependency
82
51
  requirement: !ruby/object:Gem::Requirement
83
52
  requirements:
84
53
  - - "~>"
85
54
  - !ruby/object:Gem::Version
86
- version: '2.0'
87
- name: hoe-debugging
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '2.0'
95
- - !ruby/object:Gem::Dependency
96
- requirement: !ruby/object:Gem::Requirement
97
- requirements:
98
- - - "~>"
99
- - !ruby/object:Gem::Version
100
- version: '1.0'
101
- name: hoe-gemspec
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - "~>"
107
- - !ruby/object:Gem::Version
108
- version: '1.0'
109
- - !ruby/object:Gem::Dependency
110
- requirement: !ruby/object:Gem::Requirement
111
- requirements:
112
- - - "~>"
113
- - !ruby/object:Gem::Version
114
- version: '1.6'
115
- name: hoe-git
55
+ version: '0.41'
56
+ name: concourse
116
57
  type: :development
117
58
  prerelease: false
118
59
  version_requirements: !ruby/object:Gem::Requirement
119
60
  requirements:
120
61
  - - "~>"
121
62
  - !ruby/object:Gem::Version
122
- version: '1.6'
63
+ version: '0.41'
123
64
  - !ruby/object:Gem::Dependency
124
65
  requirement: !ruby/object:Gem::Requirement
125
66
  requirements:
126
67
  - - "~>"
127
68
  - !ruby/object:Gem::Version
128
- version: '1.1'
69
+ version: '1.4'
129
70
  name: hoe-markdown
130
71
  type: :development
131
72
  prerelease: false
@@ -133,7 +74,7 @@ dependencies:
133
74
  requirements:
134
75
  - - "~>"
135
76
  - !ruby/object:Gem::Version
136
- version: '1.1'
77
+ version: '1.4'
137
78
  - !ruby/object:Gem::Dependency
138
79
  requirement: !ruby/object:Gem::Requirement
139
80
  requirements:
@@ -223,7 +164,7 @@ dependencies:
223
164
  requirements:
224
165
  - - "~>"
225
166
  - !ruby/object:Gem::Version
226
- version: '0.88'
167
+ version: '1.7'
227
168
  name: rubocop
228
169
  type: :development
229
170
  prerelease: false
@@ -231,13 +172,13 @@ dependencies:
231
172
  requirements:
232
173
  - - "~>"
233
174
  - !ruby/object:Gem::Version
234
- version: '0.88'
175
+ version: '1.7'
235
176
  - !ruby/object:Gem::Dependency
236
177
  requirement: !ruby/object:Gem::Requirement
237
178
  requirements:
238
179
  - - "~>"
239
180
  - !ruby/object:Gem::Version
240
- version: 0.17.0
181
+ version: '0.20'
241
182
  name: simplecov
242
183
  type: :development
243
184
  prerelease: false
@@ -245,74 +186,67 @@ dependencies:
245
186
  requirements:
246
187
  - - "~>"
247
188
  - !ruby/object:Gem::Version
248
- version: 0.17.0
189
+ version: '0.20'
249
190
  - !ruby/object:Gem::Dependency
250
191
  requirement: !ruby/object:Gem::Requirement
251
192
  requirements:
252
- - - ">="
253
- - !ruby/object:Gem::Version
254
- version: '4.0'
255
- - - "<"
193
+ - - "~>"
256
194
  - !ruby/object:Gem::Version
257
- version: '7'
258
- name: rdoc
195
+ version: '0.9'
196
+ name: yard
259
197
  type: :development
260
198
  prerelease: false
261
199
  version_requirements: !ruby/object:Gem::Requirement
262
200
  requirements:
263
- - - ">="
264
- - !ruby/object:Gem::Version
265
- version: '4.0'
266
- - - "<"
201
+ - - "~>"
267
202
  - !ruby/object:Gem::Version
268
- version: '7'
269
- description: |-
270
- Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among
271
- Nokogiri's many features is the ability to search documents via XPath
272
- or CSS3 selectors.
203
+ version: '0.9'
204
+ description: |
205
+ Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby. It provides a
206
+ sensible, easy-to-understand API for reading, writing, modifying, and querying documents. It is
207
+ fast and standards-compliant by relying on native parsers like libxml2 (C) and xerces (Java).
273
208
  email: nokogiri-talk@googlegroups.com
274
209
  executables:
275
210
  - nokogiri
276
211
  extensions: []
277
212
  extra_rdoc_files:
278
- - LICENSE-DEPENDENCIES.md
279
- - LICENSE.md
280
- - README.md
281
- - ext/nokogiri/html_document.c
282
- - ext/nokogiri/html_element_description.c
283
- - ext/nokogiri/html_entity_lookup.c
284
- - ext/nokogiri/html_sax_parser_context.c
285
- - ext/nokogiri/html_sax_push_parser.c
286
- - ext/nokogiri/nokogiri.c
213
+ - ext/nokogiri/xml_dtd.c
214
+ - ext/nokogiri/xml_xpath_context.c
287
215
  - ext/nokogiri/xml_attr.c
288
- - ext/nokogiri/xml_attribute_decl.c
289
- - ext/nokogiri/xml_cdata.c
216
+ - ext/nokogiri/libxml2_backwards_compat.c
290
217
  - ext/nokogiri/xml_comment.c
291
- - ext/nokogiri/xml_document.c
292
- - ext/nokogiri/xml_document_fragment.c
293
- - ext/nokogiri/xml_dtd.c
218
+ - ext/nokogiri/nokogiri.c
219
+ - ext/nokogiri/xml_sax_parser_context.c
220
+ - ext/nokogiri/xml_node_set.c
221
+ - ext/nokogiri/xml_reader.c
222
+ - ext/nokogiri/xml_cdata.c
294
223
  - ext/nokogiri/xml_element_content.c
224
+ - ext/nokogiri/html_entity_lookup.c
225
+ - ext/nokogiri/xml_namespace.c
226
+ - ext/nokogiri/xml_document.c
295
227
  - ext/nokogiri/xml_element_decl.c
228
+ - ext/nokogiri/xml_schema.c
229
+ - ext/nokogiri/html_document.c
230
+ - ext/nokogiri/xml_processing_instruction.c
231
+ - ext/nokogiri/xml_text.c
232
+ - ext/nokogiri/xml_syntax_error.c
233
+ - ext/nokogiri/xml_document_fragment.c
234
+ - ext/nokogiri/xml_sax_push_parser.c
296
235
  - ext/nokogiri/xml_encoding_handler.c
236
+ - ext/nokogiri/html_sax_push_parser.c
237
+ - ext/nokogiri/xml_relax_ng.c
297
238
  - ext/nokogiri/xml_entity_decl.c
298
- - ext/nokogiri/xml_entity_reference.c
299
- - ext/nokogiri/xml_io.c
300
- - ext/nokogiri/xml_libxml2_hacks.c
301
- - ext/nokogiri/xml_namespace.c
239
+ - ext/nokogiri/test_global_handlers.c
302
240
  - ext/nokogiri/xml_node.c
303
- - ext/nokogiri/xml_node_set.c
304
- - ext/nokogiri/xml_processing_instruction.c
305
- - ext/nokogiri/xml_reader.c
306
- - ext/nokogiri/xml_relax_ng.c
307
- - ext/nokogiri/xml_sax_parser.c
308
- - ext/nokogiri/xml_sax_parser_context.c
309
- - ext/nokogiri/xml_sax_push_parser.c
310
- - ext/nokogiri/xml_schema.c
311
- - ext/nokogiri/xml_syntax_error.c
312
- - ext/nokogiri/xml_text.c
313
- - ext/nokogiri/xml_xpath_context.c
241
+ - ext/nokogiri/xml_entity_reference.c
314
242
  - ext/nokogiri/xslt_stylesheet.c
243
+ - ext/nokogiri/html_sax_parser_context.c
244
+ - ext/nokogiri/xml_sax_parser.c
245
+ - ext/nokogiri/xml_attribute_decl.c
246
+ - ext/nokogiri/html_element_description.c
247
+ - README.md
315
248
  files:
249
+ - Gemfile
316
250
  - LICENSE-DEPENDENCIES.md
317
251
  - LICENSE.md
318
252
  - README.md
@@ -412,7 +346,9 @@ files:
412
346
  - ext/nokogiri/html_entity_lookup.c
413
347
  - ext/nokogiri/html_sax_parser_context.c
414
348
  - ext/nokogiri/html_sax_push_parser.c
349
+ - ext/nokogiri/libxml2_backwards_compat.c
415
350
  - ext/nokogiri/nokogiri.c
351
+ - ext/nokogiri/test_global_handlers.c
416
352
  - ext/nokogiri/xml_attr.c
417
353
  - ext/nokogiri/xml_attribute_decl.c
418
354
  - ext/nokogiri/xml_cdata.c
@@ -425,8 +361,6 @@ files:
425
361
  - ext/nokogiri/xml_encoding_handler.c
426
362
  - ext/nokogiri/xml_entity_decl.c
427
363
  - ext/nokogiri/xml_entity_reference.c
428
- - ext/nokogiri/xml_io.c
429
- - ext/nokogiri/xml_libxml2_hacks.c
430
364
  - ext/nokogiri/xml_namespace.c
431
365
  - ext/nokogiri/xml_node.c
432
366
  - ext/nokogiri/xml_node_set.c
@@ -456,6 +390,7 @@ files:
456
390
  - lib/nokogiri/css/tokenizer.rex
457
391
  - lib/nokogiri/css/xpath_visitor.rb
458
392
  - lib/nokogiri/decorators/slop.rb
393
+ - lib/nokogiri/extension.rb
459
394
  - lib/nokogiri/html.rb
460
395
  - lib/nokogiri/html/builder.rb
461
396
  - lib/nokogiri/html/document.rb
@@ -538,12 +473,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
538
473
  version: 2.5.0
539
474
  required_rubygems_version: !ruby/object:Gem::Requirement
540
475
  requirements:
541
- - - ">"
476
+ - - ">="
542
477
  - !ruby/object:Gem::Version
543
- version: 1.3.1
478
+ version: '0'
544
479
  requirements: []
545
480
  rubygems_version: 3.0.6
546
481
  signing_key:
547
482
  specification_version: 4
548
- summary: Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser
483
+ summary: Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.
549
484
  test_files: []