nokolexbor 0.5.4-x86_64-linux → 0.6.2-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nokolexbor/2.6/nokolexbor.so +0 -0
- data/lib/nokolexbor/2.7/nokolexbor.so +0 -0
- data/lib/nokolexbor/3.0/nokolexbor.so +0 -0
- data/lib/nokolexbor/3.1/nokolexbor.so +0 -0
- data/lib/nokolexbor/3.2/nokolexbor.so +0 -0
- data/lib/nokolexbor/3.3/nokolexbor.so +0 -0
- data/lib/nokolexbor/3.4/nokolexbor.so +0 -0
- data/lib/nokolexbor/document.rb +20 -0
- data/lib/nokolexbor/node.rb +30 -10
- data/lib/nokolexbor/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e6989b30048faef37e763032340f29fdb048b476e61abb8d2290ff96bf5b130
|
4
|
+
data.tar.gz: d706f514a7a1085e3c55011b998e1f74c06e4aa90645945372b7373eebbc12ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6880272c3a4336af85ffca9151376fd02278ce653f534cd912341ec1819ecb0266b442e7773a3a828e741000b332ccc5de86d2c2f78e38e5cf923df69c546d66
|
7
|
+
data.tar.gz: 22fffba70b2231460dbc4779004c9f44fd3d1dd56b565bfa74a551745a0d0008e36f1469dc16b8327ff36b03dc5b4caa3885b76b0afcacb94c3e39190efb7e84
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/nokolexbor/document.rb
CHANGED
@@ -141,6 +141,26 @@ module Nokolexbor
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
+
# Parse HTML into a {Document}.
|
145
|
+
#
|
146
|
+
# @param string_or_io [String, #read]
|
147
|
+
# The HTML to be parsed. It may be a String, or any object that
|
148
|
+
# responds to #read such as an IO, or StringIO.
|
149
|
+
#
|
150
|
+
# @return [Document]
|
151
|
+
def self.parse(string_or_io)
|
152
|
+
html = string_or_io
|
153
|
+
if string_or_io.respond_to?(:read)
|
154
|
+
html = string_or_io.read
|
155
|
+
end
|
156
|
+
|
157
|
+
if html.respond_to?(:encoding) && html.encoding != Encoding::UTF_8
|
158
|
+
html = html.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
|
159
|
+
end
|
160
|
+
|
161
|
+
parse_native(html)
|
162
|
+
end
|
163
|
+
|
144
164
|
private
|
145
165
|
|
146
166
|
IMPLIED_XPATH_CONTEXTS = ["//"].freeze # :nodoc:
|
data/lib/nokolexbor/node.rb
CHANGED
@@ -717,18 +717,38 @@ module Nokolexbor
|
|
717
717
|
|
718
718
|
def xpath_query_from_css_rule(rule, ns)
|
719
719
|
ensure_nokogiri
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
720
|
+
|
721
|
+
unless defined?(Gem)
|
722
|
+
require 'rubygems'
|
723
|
+
end
|
724
|
+
|
725
|
+
v_1_17_0 = Gem::Version.new("1.17.0")
|
726
|
+
current_version = Gem::Version.new(Nokogiri::VERSION)
|
727
|
+
|
728
|
+
if current_version < v_1_17_0
|
729
|
+
if defined? Nokogiri::CSS::XPathVisitor::BuiltinsConfig
|
730
|
+
visitor = Nokogiri::CSS::XPathVisitor.new(
|
731
|
+
builtins: Nokogiri::CSS::XPathVisitor::BuiltinsConfig::OPTIMAL,
|
732
|
+
doctype: :html4,
|
733
|
+
)
|
734
|
+
else
|
735
|
+
visitor = Nokogiri::CSS::XPathVisitorOptimallyUseBuiltins.new
|
736
|
+
end
|
737
|
+
self.class::IMPLIED_XPATH_CONTEXTS.map do |implied_xpath_context|
|
738
|
+
Nokogiri::CSS.xpath_for(rule.to_s, { prefix: implied_xpath_context, ns: ns,
|
739
|
+
visitor: visitor, })
|
740
|
+
end.join(" | ")
|
725
741
|
else
|
726
|
-
|
742
|
+
self.class::IMPLIED_XPATH_CONTEXTS.map do |implied_xpath_context|
|
743
|
+
visitor = Nokogiri::CSS::XPathVisitor.new(
|
744
|
+
builtins: Nokogiri::CSS::XPathVisitor::BuiltinsConfig::OPTIMAL,
|
745
|
+
doctype: :html4,
|
746
|
+
prefix: implied_xpath_context,
|
747
|
+
namespaces: ns,
|
748
|
+
)
|
749
|
+
Nokogiri::CSS.xpath_for(rule.to_s, visitor: visitor)
|
750
|
+
end.join(" | ")
|
727
751
|
end
|
728
|
-
self.class::IMPLIED_XPATH_CONTEXTS.map do |implied_xpath_context|
|
729
|
-
Nokogiri::CSS.xpath_for(rule.to_s, { prefix: implied_xpath_context, ns: ns,
|
730
|
-
visitor: visitor, })
|
731
|
-
end.join(" | ")
|
732
752
|
end
|
733
753
|
|
734
754
|
def extract_params(params)
|
data/lib/nokolexbor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokolexbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- Yicheng Zhou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- lib/nokolexbor/3.1/nokolexbor.so
|
53
53
|
- lib/nokolexbor/3.2/nokolexbor.so
|
54
54
|
- lib/nokolexbor/3.3/nokolexbor.so
|
55
|
+
- lib/nokolexbor/3.4/nokolexbor.so
|
55
56
|
- lib/nokolexbor/document.rb
|
56
57
|
- lib/nokolexbor/document_fragment.rb
|
57
58
|
- lib/nokolexbor/node.rb
|
@@ -74,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
75
|
version: '2.6'
|
75
76
|
- - "<"
|
76
77
|
- !ruby/object:Gem::Version
|
77
|
-
version: 3.
|
78
|
+
version: 3.5.dev
|
78
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
81
|
- - ">="
|