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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b6ae46cc828d11dd9474dbaad7453e48cd8c6282d6523732683e06812c919ba
4
- data.tar.gz: d9245d48440921bca331af7c3be00843c21647cbd043473580c6a218f6a15f77
3
+ metadata.gz: 88bb496bdbab5cc434e73d3f353563e110bbaf0b73a76f009886e45743206984
4
+ data.tar.gz: c00284c8cc531ed825633e8e2250a1dbead21ec4db083529a6bef5d3b909bd4b
5
5
  SHA512:
6
- metadata.gz: 7e9eb37f4285e047e2defa49566b19f3d2ddec40cb1fe55f6711c16674dcd076a805244c1716996a442b1bac99dc44af8e2c56ef89c49d677a5cf6649096adcc
7
- data.tar.gz: f39f78aae5823e33033d328138da4dc5a748c3ee1c55079190457f926bcebeea4767ffc5e515132cd3e767347d80b4065c7fdd1d8e60e7a0833306053271b2e3
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 + 1
104
- new_num = (diff_line.new_position || diff_line.line_number) + 1
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 + 1
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) + 1
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 + 1
259
- new_line_num = (diff_line.new_position || diff_line.line_number) + 1
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canon
4
- VERSION = "0.3.41"
4
+ VERSION = "0.3.43"
5
5
  end
@@ -22,13 +22,20 @@ module Canon
22
22
  processor.process(root_node)
23
23
  end
24
24
 
25
- # leptris' C-side C14N 1.1 — ~50x faster than the Ruby processor
26
- # but NOT yet byte-identical on canon's edge-case corpus
27
- # (attribute ordering, `>` escaping, document-level PIs, one
28
- # prefix case leptris#1015; the parity spec pins
29
- # each). Opt-in via CANON_C14N_BACKEND=leptris until those
30
- # close; comments mode keeps the Ruby path regardless (the
31
- # native seam exposes no with-comments form).
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"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.41
4
+ version: 0.3.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.