This repository has been archived by the owner on Aug 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #171 from rubys/flavorjones-check-for-html5-alread…
…y-defined feat: Nokogumbo detects Nokogiri's HTML5 API
- Loading branch information
Showing
3 changed files
with
28 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
require 'nokogiri' | ||
require 'nokogumbo/version' | ||
require 'nokogumbo/html5' | ||
|
||
require 'nokogumbo/nokogumbo' | ||
if ((defined?(Nokogiri::HTML5) && Nokogiri::HTML5.respond_to?(:parse)) && | ||
(defined?(Nokogiri::Gumbo) && Nokogiri::Gumbo.respond_to?(:parse)) && | ||
!(ENV.key?("NOKOGUMBO_IGNORE_NOKOGIRI_HTML5") && ENV["NOKOGUMBO_IGNORE_NOKOGIRI_HTML5"] != "false")) | ||
|
||
warn "NOTE: nokogumbo: Using Nokogiri::HTML5 provided by Nokogiri. See https://github.com/sparklemotion/nokogiri/issues/2205 for more information." | ||
|
||
::Nokogumbo = ::Nokogiri::Gumbo | ||
else | ||
require 'nokogumbo/html5' | ||
require 'nokogumbo/nokogumbo' | ||
|
||
module Nokogumbo | ||
# The default maximum number of attributes per element. | ||
DEFAULT_MAX_ATTRIBUTES = 400 | ||
module Nokogumbo | ||
# The default maximum number of attributes per element. | ||
DEFAULT_MAX_ATTRIBUTES = 400 | ||
|
||
# The default maximum number of errors for parsing a document or a fragment. | ||
DEFAULT_MAX_ERRORS = 0 | ||
# The default maximum number of errors for parsing a document or a fragment. | ||
DEFAULT_MAX_ERRORS = 0 | ||
|
||
# The default maximum depth of the DOM tree produced by parsing a document | ||
# or fragment. | ||
DEFAULT_MAX_TREE_DEPTH = 400 | ||
# The default maximum depth of the DOM tree produced by parsing a document | ||
# or fragment. | ||
DEFAULT_MAX_TREE_DEPTH = 400 | ||
end | ||
end | ||
|
||
require 'nokogumbo/version' |