canon 0.3.41 → 0.3.43
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/diff_formatter/by_line/xml_formatter.rb +51 -6
- data/lib/canon/version.rb +1 -1
- data/lib/canon/xml/c14n.rb +14 -7
- 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: 88bb496bdbab5cc434e73d3f353563e110bbaf0b73a76f009886e45743206984
|
|
4
|
+
data.tar.gz: c00284c8cc531ed825633e8e2250a1dbead21ec4db083529a6bef5d3b909bd4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7e32bb5f265281f3ba69a7b9c130025d84f27578084a8a90267edaefc7e5cc6cedd8b2aa72db0a930d38def70ac07f826fc80e767cda72089d3ebedbc88219f4
|
|
7
|
+
data.tar.gz: 82a1b117a2f121dbd436962937b1aec7de7ef691b8d15f51fbf69155d6ff9fe09af5ed5f69efdbfa4724af65dbd3858525a56ac22ebb6d603c91ad9b032ab590
|
|
@@ -59,10 +59,55 @@ module Canon
|
|
|
59
59
|
grouping_lines: @diff_grouping_lines,
|
|
60
60
|
)
|
|
61
61
|
|
|
62
|
+
# #85/#86: DiffNodes the enricher could not locate were
|
|
63
|
+
# previously dropped silently — the absorption mechanism.
|
|
64
|
+
# Their serialized content renders as a trailing context so
|
|
65
|
+
# the change is always visible, without perturbing the
|
|
66
|
+
# located walk's line accounting.
|
|
67
|
+
append_unlocated_context(report)
|
|
68
|
+
|
|
62
69
|
# Layer 6: Format the report
|
|
63
70
|
format_report(report, doc1, doc2)
|
|
64
71
|
end
|
|
65
72
|
|
|
73
|
+
# Trailing context for DiffNodes with no located char ranges
|
|
74
|
+
# (multiline reflowed text, relocated content): one removed
|
|
75
|
+
# DiffLine per serialized_before line, one added per
|
|
76
|
+
# serialized_after line. Nil positions render as blank line
|
|
77
|
+
# numbers.
|
|
78
|
+
def append_unlocated_context(report)
|
|
79
|
+
unlocated = @differences.select do |dn|
|
|
80
|
+
dn.char_ranges.nil? || dn.char_ranges.empty?
|
|
81
|
+
end
|
|
82
|
+
return if unlocated.empty?
|
|
83
|
+
|
|
84
|
+
unlocated = unlocated.reject do |dn|
|
|
85
|
+
(@show_diffs == :normative && !dn.normative?) ||
|
|
86
|
+
(@show_diffs == :informative && !dn.informative?)
|
|
87
|
+
end
|
|
88
|
+
return if unlocated.empty?
|
|
89
|
+
|
|
90
|
+
lines = []
|
|
91
|
+
unlocated.each do |dn|
|
|
92
|
+
fmt = dn.formatting?
|
|
93
|
+
dn.serialized_before&.split("\n")&.each do |line|
|
|
94
|
+
lines << Canon::Diff::DiffLine.new(
|
|
95
|
+
line_number: nil, new_position: nil, content: line,
|
|
96
|
+
type: :removed, diff_node: dn, formatting: fmt
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
next unless dn.serialized_after
|
|
100
|
+
|
|
101
|
+
dn.serialized_after.split("\n").each do |line|
|
|
102
|
+
lines << Canon::Diff::DiffLine.new(
|
|
103
|
+
line_number: nil, new_position: nil, content: line,
|
|
104
|
+
type: :added, diff_node: dn, formatting: fmt
|
|
105
|
+
)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
report.contexts << Canon::Diff::DiffContext.new(lines: lines)
|
|
109
|
+
end
|
|
110
|
+
|
|
66
111
|
# Format a DiffReport for display
|
|
67
112
|
def format_report(report, doc1, doc2)
|
|
68
113
|
return "" if report.contexts.empty?
|
|
@@ -100,12 +145,12 @@ module Canon
|
|
|
100
145
|
context.lines.each do |diff_line|
|
|
101
146
|
case diff_line.type
|
|
102
147
|
when :unchanged
|
|
103
|
-
old_num = diff_line.line_number
|
|
104
|
-
new_num = (diff_line.new_position || diff_line.line_number)
|
|
148
|
+
old_num = diff_line.line_number&.+(1)
|
|
149
|
+
new_num = (diff_line.new_position || diff_line.line_number)&.+(1)
|
|
105
150
|
output << format_unified_line(old_num, new_num, " ",
|
|
106
151
|
diff_line.content)
|
|
107
152
|
when :removed
|
|
108
|
-
line_num = diff_line.line_number
|
|
153
|
+
line_num = diff_line.line_number&.+(1)
|
|
109
154
|
formatting = diff_line.formatting?
|
|
110
155
|
informative = diff_line.informative?
|
|
111
156
|
|
|
@@ -147,7 +192,7 @@ module Canon
|
|
|
147
192
|
theme_color(:removed, :content))
|
|
148
193
|
end
|
|
149
194
|
when :added
|
|
150
|
-
line_num = (diff_line.new_position || diff_line.line_number)
|
|
195
|
+
line_num = (diff_line.new_position || diff_line.line_number)&.+(1)
|
|
151
196
|
formatting = diff_line.formatting?
|
|
152
197
|
informative = diff_line.informative?
|
|
153
198
|
|
|
@@ -255,8 +300,8 @@ module Canon
|
|
|
255
300
|
# Format a changed diff line using DiffCharRanges for character-level highlighting.
|
|
256
301
|
# Reads pre-computed char ranges from the DiffLine — NO tokenization, NO LCS.
|
|
257
302
|
def format_changed_line(diff_line, _lines1)
|
|
258
|
-
old_line_num = diff_line.line_number
|
|
259
|
-
new_line_num = (diff_line.new_position || diff_line.line_number)
|
|
303
|
+
old_line_num = diff_line.line_number&.+(1)
|
|
304
|
+
new_line_num = (diff_line.new_position || diff_line.line_number)&.+(1)
|
|
260
305
|
formatting = diff_line.formatting?
|
|
261
306
|
informative = diff_line.informative?
|
|
262
307
|
old_content = diff_line.old_content || diff_line.content
|
data/lib/canon/version.rb
CHANGED
data/lib/canon/xml/c14n.rb
CHANGED
|
@@ -22,13 +22,20 @@ module Canon
|
|
|
22
22
|
processor.process(root_node)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# leptris' C-side C14N 1.1 —
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
# prefix
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
25
|
+
# leptris' C-side C14N 1.1 — 23x faster than the Ruby processor
|
|
26
|
+
# through canon's own API (1MB document). libleptris 1.9.164
|
|
27
|
+
# closed four of the five leptris#1015 families (attribute
|
|
28
|
+
# ordering, prefix loss and rebinding, `>` and TAB escaping —
|
|
29
|
+
# unpinned in the parity spec since gem 1.9.174.0). A local
|
|
30
|
+
# default-flip attempt surfaced three MORE divergences the
|
|
31
|
+
# edge corpus did not cover, so the lane stays opt-in
|
|
32
|
+
# (CANON_C14N_BACKEND=leptris) until they close (leptris#1096):
|
|
33
|
+
# redundant namespace redeclarations are kept (Ruby removes
|
|
34
|
+
# them), xmlns:xml with the standard URI is kept (Ruby omits
|
|
35
|
+
# it), and document-level processing instructions are dropped.
|
|
36
|
+
# The Ruby lane additionally validates relative namespace URIs
|
|
37
|
+
# at parse time — a future flip must carry that check into the
|
|
38
|
+
# native wrapper. Comments mode keeps the Ruby path regardless.
|
|
32
39
|
def self.native_canonicalize(xml, with_comments)
|
|
33
40
|
return nil if with_comments
|
|
34
41
|
return nil if RUBY_ENGINE == "opal"
|