nokogumbo 2.0.4 → 2.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d5936b6ffffb20ec22609b2be5d2493919c81f7c8279a7c21fd8e95e457d0c5
4
- data.tar.gz: 5259acf1b328d1097edcbb162433d72e69b084b66ed8bae28703bca53bd88b76
3
+ metadata.gz: a84b367d94046358f7844781b0f92cea51a75e052d54e35b53ab03602743f1b8
4
+ data.tar.gz: 8d96a5adfa701f658f7ba193ee96bb8a7e6901c1ff4d3fb2dad6f3e372ce66d2
5
5
  SHA512:
6
- metadata.gz: 6fdc59096ec69684932424b70bed03f05f6ea5324e9d3f70eee8481891a15ae9f3cf063fff7106cc38d2873d072d21169b58ed6f5b381b687aa5b1680eee35e6
7
- data.tar.gz: 4d1d88817b4242b060e5a9ac74e36e9f23d38b153547b64d51a59d86daff44853915ba8bd07473902fe4d936cd53851d2594c3ac09541159863117eedf8339ab
6
+ metadata.gz: de2472c6ff89e3f0076a44ac13fa67688e82f909b265a2b70fe45225daf01aaf6059c6ca94f06e10ff94e10ac8a8f42b685e63f494849f04f3af56f337a73382
7
+ data.tar.gz: 3880defdaa15cb278236cf170d5727d1d73b14698f1ea41e7a7141da7a2fe8c3bafea19367196214c0dc0c1c27854602714d80abd30ecfd6be90f4277f3e33d7
@@ -5,6 +5,7 @@ require 'nokogiri'
5
5
 
6
6
  $CFLAGS += " -std=c99"
7
7
  $LDFLAGS.gsub!('-Wl,--no-undefined', '')
8
+ $DLDFLAGS.gsub!('-Wl,--no-undefined', '')
8
9
  $warnflags = CONFIG['warnflags'] = '-Wall'
9
10
 
10
11
  NG_SPEC = Gem::Specification.find_by_name('nokogiri', "= #{Nokogiri::VERSION}")
@@ -60,41 +61,64 @@ end
60
61
  have_libxml2 = false
61
62
  have_ng = false
62
63
 
64
+ def windows?
65
+ ::RUBY_PLATFORM =~ /mingw|mswin/
66
+ end
67
+
68
+ def modern_nokogiri?
69
+ nokogiri_version = Gem::Version.new(Nokogiri::VERSION)
70
+ requirement = windows? ? ">= 1.11.2" : ">= 1.11.0.rc4"
71
+ Gem::Requirement.new(requirement).satisfied_by?(nokogiri_version)
72
+ end
73
+
63
74
  if !prohibited
64
- if Nokogiri::VERSION_INFO.include?('libxml') and
65
- Nokogiri::VERSION_INFO['libxml']['source'] == 'packaged'
66
- # Nokogiri has libxml2 built in. Find the headers.
67
- libxml2_path = File.join(Nokogiri::VERSION_INFO['libxml']['libxml2_path'],
68
- 'include/libxml2')
69
- if find_header('libxml/tree.h', libxml2_path)
70
- have_libxml2 = true
75
+ if modern_nokogiri?
76
+ append_cflags(Nokogiri::VERSION_INFO["nokogiri"]["cppflags"])
77
+ append_ldflags(Nokogiri::VERSION_INFO["nokogiri"]["ldflags"]) # may be nil for nokogiri pre-1.11.2
78
+ have_libxml2 = if Nokogiri::VERSION_INFO["nokogiri"]["ldflags"].empty?
79
+ have_header('libxml/tree.h')
80
+ else
81
+ have_func("xmlNewDoc", "libxml/tree.h")
82
+ end
83
+ end
84
+
85
+ if !have_libxml2
86
+ if Nokogiri::VERSION_INFO.include?('libxml') and
87
+ Nokogiri::VERSION_INFO['libxml']['source'] == 'packaged'
88
+ # Nokogiri has libxml2 built in. Find the headers.
89
+ libxml2_path = File.join(Nokogiri::VERSION_INFO['libxml']['libxml2_path'],
90
+ 'include/libxml2')
91
+ if find_header('libxml/tree.h', libxml2_path)
92
+ have_libxml2 = true
93
+ else
94
+ # Unfortunately, some versions of Nokogiri delete these files.
95
+ # https://github.com/sparklemotion/nokogiri/pull/1788
96
+ # Try to download them
97
+ libxml2_path = download_headers
98
+ unless libxml2_path.nil?
99
+ have_libxml2 = find_header('libxml/tree.h', libxml2_path)
100
+ end
101
+ end
71
102
  else
72
- # Unfortunately, some versions of Nokogiri delete these files.
73
- # https://github.com/sparklemotion/nokogiri/pull/1788
74
- # Try to download them
75
- libxml2_path = download_headers
76
- unless libxml2_path.nil?
77
- have_libxml2 = find_header('libxml/tree.h', libxml2_path)
103
+ # Nokogiri is compiled with system headers.
104
+ # Hack to work around broken mkmf on macOS
105
+ # (https://bugs.ruby-lang.org/issues/14992 fixed now)
106
+ if RbConfig::MAKEFILE_CONFIG['LIBPATHENV'] == 'DYLD_LIBRARY_PATH'
107
+ RbConfig::MAKEFILE_CONFIG['LIBPATHENV'] = 'DYLD_FALLBACK_LIBRARY_PATH'
78
108
  end
79
- end
80
- else
81
- # Nokogiri is compiled with system headers.
82
- # Hack to work around broken mkmf on macOS
83
- # (https://bugs.ruby-lang.org/issues/14992 fixed now)
84
- if RbConfig::MAKEFILE_CONFIG['LIBPATHENV'] == 'DYLD_LIBRARY_PATH'
85
- RbConfig::MAKEFILE_CONFIG['LIBPATHENV'] = 'DYLD_FALLBACK_LIBRARY_PATH'
86
- end
87
109
 
88
- pkg_config('libxml-2.0')
89
- have_libxml2 = have_library('xml2', 'xmlNewDoc')
110
+ pkg_config('libxml-2.0')
111
+ have_libxml2 = have_library('xml2', 'xmlNewDoc')
112
+ end
90
113
  end
114
+
91
115
  if required and !have_libxml2
92
116
  abort "libxml2 required but could not be located"
93
117
  end
94
118
 
119
+
95
120
  if have_libxml2
96
- # Find nokogiri.h
97
- have_ng = find_header('nokogiri.h', File.join(NG_SPEC.gem_dir, 'ext/nokogiri'))
121
+ have_ng = have_header('nokogiri.h') || find_header('nokogiri.h', File.join(NG_SPEC.gem_dir, 'ext/nokogiri'))
98
122
  end
99
123
  end
100
124
 
@@ -104,7 +128,6 @@ end
104
128
 
105
129
  # Symlink gumbo-parser source files.
106
130
  ext_dir = File.dirname(__FILE__)
107
- gumbo_src = File.join(ext_dir, 'gumbo_src')
108
131
 
109
132
  Dir.chdir(ext_dir) do
110
133
  $srcs = Dir['*.c', '../../gumbo-parser/src/*.c']
data/lib/nokogumbo.rb CHANGED
@@ -1,17 +1,27 @@
1
1
  require 'nokogiri'
2
- require 'nokogumbo/version'
3
- require 'nokogumbo/html5'
4
2
 
5
- require 'nokogumbo/nokogumbo'
3
+ if ((defined?(Nokogiri::HTML5) && Nokogiri::HTML5.respond_to?(:parse)) &&
4
+ (defined?(Nokogiri::Gumbo) && Nokogiri::Gumbo.respond_to?(:parse)) &&
5
+ !(ENV.key?("NOKOGUMBO_IGNORE_NOKOGIRI_HTML5") && ENV["NOKOGUMBO_IGNORE_NOKOGIRI_HTML5"] != "false"))
6
+
7
+ warn "NOTE: nokogumbo: Using Nokogiri::HTML5 provided by Nokogiri. See https://github.com/sparklemotion/nokogiri/issues/2205 for more information."
8
+
9
+ ::Nokogumbo = ::Nokogiri::Gumbo
10
+ else
11
+ require 'nokogumbo/html5'
12
+ require 'nokogumbo/nokogumbo'
6
13
 
7
- module Nokogumbo
8
- # The default maximum number of attributes per element.
9
- DEFAULT_MAX_ATTRIBUTES = 400
14
+ module Nokogumbo
15
+ # The default maximum number of attributes per element.
16
+ DEFAULT_MAX_ATTRIBUTES = 400
10
17
 
11
- # The default maximum number of errors for parsing a document or a fragment.
12
- DEFAULT_MAX_ERRORS = 0
18
+ # The default maximum number of errors for parsing a document or a fragment.
19
+ DEFAULT_MAX_ERRORS = 0
13
20
 
14
- # The default maximum depth of the DOM tree produced by parsing a document
15
- # or fragment.
16
- DEFAULT_MAX_TREE_DEPTH = 400
21
+ # The default maximum depth of the DOM tree produced by parsing a document
22
+ # or fragment.
23
+ DEFAULT_MAX_TREE_DEPTH = 400
24
+ end
17
25
  end
26
+
27
+ require 'nokogumbo/version'
@@ -1,3 +1,3 @@
1
1
  module Nokogumbo
2
- VERSION = "2.0.4"
2
+ VERSION = "2.0.5"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nokogumbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Ruby
8
8
  - Stephen Checkoway
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-27 00:00:00.000000000 Z
12
+ date: 2021-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -94,7 +94,7 @@ metadata:
94
94
  changelog_uri: https://github.com/rubys/nokogumbo/blob/master/CHANGELOG.md
95
95
  homepage_uri: https://github.com/rubys/nokogumbo/#readme
96
96
  source_code_uri: https://github.com/rubys/nokogumbo
97
- post_install_message:
97
+ post_install_message:
98
98
  rdoc_options: []
99
99
  require_paths:
100
100
  - lib
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  requirements: []
112
112
  rubygems_version: 3.1.4
113
- signing_key:
113
+ signing_key:
114
114
  specification_version: 4
115
115
  summary: Nokogiri interface to the Gumbo HTML5 parser
116
116
  test_files: []
OSZAR »