mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 03:32:40 +08:00
DEV: Remove invalid parsing options (#30545)
HTML5 parser doesn't have those options
This commit is contained in:
parent
bba4c9b005
commit
145c7e46e1
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user