DEV: Remove invalid parsing options (#30545)

HTML5 parser doesn't have those options
This commit is contained in:
Jarek Radosz 2025-01-03 13:17:49 +01:00 committed by GitHub
parent bba4c9b005
commit 145c7e46e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
require "nokogiri/xml/parse_options"
RSpec::Matchers.define :match_html do |expected| RSpec::Matchers.define :match_html do |expected|
match { |actual| make_canonical_html(expected).eql? make_canonical_html(actual) } match { |actual| make_canonical_html(expected).eql? make_canonical_html(actual) }
@ -13,11 +12,7 @@ RSpec::Matchers.define :match_html do |expected|
end end
def make_canonical_html(html) def make_canonical_html(html)
doc = doc = Nokogiri.HTML5(html)
Nokogiri.HTML5(html) do |config|
config[:options] = Nokogiri::XML::ParseOptions::NOBLANKS |
Nokogiri::XML::ParseOptions::COMPACT
end
doc.traverse do |node| doc.traverse do |node|
node.content = node.content.gsub(/\s+/, " ").strip if node.node_name&.downcase == "text" node.content = node.content.gsub(/\s+/, " ").strip if node.node_name&.downcase == "text"