canon 0.3.124 → 0.3.125
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/canon/comparison/node_inspector.rb +17 -4
- data/lib/canon/comparison/xml_comparator.rb +4 -3
- data/lib/canon/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8b203097b191fc83c22d4e5d091c9558e7c43e8544ead70dae7e17f70d4a3f60
|
|
4
|
+
data.tar.gz: be396b430f798bfe53c931e7eb49b6e2fa97bde9d9c48b968bfd41f6a6f12ff8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9ea68cf0daa2a6290cd2fca74ec53bdf310597f4c3641bffea73d30b82d21614f1216bd4d3c25602bf87389ab61b8af067340feac3da045a99e2764fa6b87e3b
|
|
7
|
+
data.tar.gz: 9d2e6cc4ad93a583b52055ba2aeeeab159593282b5141b5a57f0ee08b9061a20067318b677b65dd88e241bbcb2e016f042bad6f765e5b526c3f99ff162f0c8a7
|
|
@@ -122,11 +122,24 @@ module Canon
|
|
|
122
122
|
XmlParsing.children(node)
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
+
# Text/comment content with XML 1.0 §2.11 line-end normalization
|
|
126
|
+
# (CRLF and lone CR -> LF). Conformant parsers normalize line
|
|
127
|
+
# ends in all parsed content, but engines disagree in practice —
|
|
128
|
+
# libxml2 preserves \r inside comment data and text nodes while
|
|
129
|
+
# the leptris lane normalizes — so the comparison normalizes at
|
|
130
|
+
# this single seam to keep equivalence engine-neutral (canon#310:
|
|
131
|
+
# the svg/* corpus fixtures carry CRLF comments and text and
|
|
132
|
+
# compared inequivalent under the raw-nokogiri lane).
|
|
125
133
|
def self.text_content(node)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
raw = if node.is_a?(Canon::Xml::Nodes::TextNode)
|
|
135
|
+
node.value.to_s
|
|
136
|
+
elsif node.is_a?(Canon::Xml::Node)
|
|
137
|
+
node.text_content.to_s
|
|
138
|
+
else
|
|
139
|
+
XmlParsing.text_content(node).to_s
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
raw.gsub(/\r\n?/, "\n")
|
|
130
143
|
end
|
|
131
144
|
|
|
132
145
|
def self.node_type(node)
|
|
@@ -539,9 +539,10 @@ module Canon
|
|
|
539
539
|
match_opts = opts[:match_opts]
|
|
540
540
|
behavior = match_opts[:comments]
|
|
541
541
|
|
|
542
|
-
#
|
|
543
|
-
|
|
544
|
-
|
|
542
|
+
# Line ends normalized per XML 1.0 §2.11 in NodeInspector —
|
|
543
|
+
# engines disagree on \r inside comment data (canon#310).
|
|
544
|
+
content1 = NodeInspector.text_content(n1)
|
|
545
|
+
content2 = NodeInspector.text_content(n2)
|
|
545
546
|
|
|
546
547
|
# Check if content differs
|
|
547
548
|
contents_differ = content1 != content2
|
data/lib/canon/version.rb
CHANGED