canon 0.3.6 → 0.3.7

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: 04012234db38cae77206ba33f856aca1262a0ad0111e7d233d5b814e90c22187
4
- data.tar.gz: 3700758afcb5619f59ba7e2f896963bc63695d534f60af7d922dfce8c26076ec
3
+ metadata.gz: b1ce43e1e3cb461ac60687f0e9cdd815916f85cd40a87c8d70f0a071c56b1c04
4
+ data.tar.gz: 3eff7d2db22b5fe57674e64aa5f6b5ebb1d4b82d6f3afde5c45444f57f2c8e55
5
5
  SHA512:
6
- metadata.gz: c6452b462325e65c3f38f31438656b1cf60790646413314d8e835f6a27f78026bc10de2474065627b26a602962c424fd6858e1bc97ed3bca43e8a009b1779291
7
- data.tar.gz: 749b78e282b4b2c7d440f9dff4a2361ee8d7742afcdab54b490bf836ae9417afc5f677e2039143020a6e50eceaf12d42950372c7a5f62dfcd335223243962fef
6
+ metadata.gz: 7428800d8125c5173b61338ce8929f1c3700684ccba7cae25847a1d5cc533c99eea946a46cd5f567841b978597670e26d546849b853b11bd88cb6f72c023c647
7
+ data.tar.gz: 77cdd82d177e2d476aece71503a70487ee31f6593f30d401e748199944fbc9230756c5bba08b73411dae62621c5d08c16c1fdb4ec427a5e96f0d43955cea0414
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.6"
4
+ VERSION = "0.3.7"
5
5
  end
@@ -205,9 +205,16 @@ inherited_namespaces: nil)
205
205
  # scopes cannot flow down during the stream).
206
206
 
207
207
  def self.from_moxml_xml(xml_string, preserve_whitespace:)
208
- doc = Canon::XmlParsing.moxml_context.parse(xml_string, readonly: true)
208
+ # strict: false keeps the Nokogiri-engine contract — malformed
209
+ # input yields a recovered document plus diagnostics instead of
210
+ # an exception (moxml 0.5.15 defaults strict to true; issue
211
+ # #147 rides recover errors on Document#parse_errors).
212
+ doc = Canon::XmlParsing.moxml_context.parse(xml_string,
213
+ readonly: true,
214
+ strict: false)
209
215
  check_moxml_relative_namespace_uris(doc)
210
216
  result = build_from_moxml(doc, preserve_whitespace: preserve_whitespace)
217
+ result.parse_errors = doc.parse_errors if doc.parse_errors.any?
211
218
  # Canon owns this document's full lifecycle: the canon tree holds
212
219
  # no engine references once built, so release the native tree now
213
220
  # instead of waiting for the GC finalizer (moxml#134; no-op on
data/lib/canon/xml/sax.rb CHANGED
@@ -10,16 +10,13 @@ module Canon
10
10
  # API to that protocol. OCP: a new engine is a new driver plus one line
11
11
  # here; the builder never changes.
12
12
  #
13
- # Engine choice: the leptris SAX flip is armed but blocked twice over.
14
- # The batch-attribute corruption (leptris-ruby#95) is answered by a
15
- # correctness-first path in leptris 1.9.36 attributes are correct,
16
- # but that path DROPS namespace declarations from SAX events
17
- # entirely (raw `["<root xmlns:a=.../>", []]` xmlns pairs vanish),
18
- # blinding namespace comparison. Until xmlns reporting is restored
19
- # (and then the fast path returns with the C fix), CRuby keeps the
20
- # Nokogiri driver; the flip is the one-line change below. With
21
- # leptris absent (moxml resolving nokogiri) the driver calls Nokogiri
22
- # directly — the wrapper layer only adds overhead there.
13
+ # Engine choice follows the resolved adapter independent of the
14
+ # DOM engine default: leptris SAX (corruption leptris#625 and the
15
+ # missing xmlns reporting leptris-ruby#99 both fixed) builds canon
16
+ # trees at parity with or faster than Nokogiri SAX, CI-gated. The
17
+ # DOM engine default stays Nokogiri until the record conversion
18
+ # passes the same gate (see XmlBackend). With leptris absent the
19
+ # driver calls Nokogiri directly.
23
20
  module Sax
24
21
  autoload :NokogiriDriver, "canon/xml/sax/nokogiri_driver"
25
22
  autoload :MoxmlDriver, "canon/xml/sax/moxml_driver"
@@ -27,7 +24,7 @@ module Canon
27
24
  class << self
28
25
  # Drive `builder` with the runtime's SAX engine.
29
26
  def parse(xml_string, builder)
30
- if RUBY_ENGINE == "opal"
27
+ if RUBY_ENGINE == "opal" || Canon::XmlParsing.moxml_adapter_name != :nokogiri
31
28
  MoxmlDriver.new(builder).parse(xml_string)
32
29
  else
33
30
  NokogiriDriver.new(builder).parse(xml_string)
@@ -9,16 +9,14 @@ module Canon
9
9
  # - HTML support — always Nokogiri on CRuby; moxml has no HTML adapter and
10
10
  # leptris no HTML parser (see Canon::Html::NokogiriSupport).
11
11
  #
12
- # SSOT: moxml owns adapter preference (Moxml::Config prefers leptris when
13
- # installed and capable; see XmlParsing.moxml_adapter_name). Canon's
14
- # default engine is Nokogiri on CRuby until leptris WINS somewhere
15
- # measurably: conformance parity is complete (engine_parity_spec 12/12),
16
- # but the leptris SAX driver is blocked by a data-corruption bug
17
- # (leptris-ruby#95) and the record-based conversion runs ~0.55x Nokogiri
18
- # (CI performance gate: -42..45% on from_xml) pending lighter record
19
- # emission upstream. Flipping the default is the one-line change in
20
- # #detect; CANON_XML_BACKEND=moxml opts in today. Under Opal the engine
21
- # is moxml (rexml adapter).
12
+ # SSOT: moxml owns adapter preference (Moxml::Config prefers leptris
13
+ # when installed; see XmlParsing.moxml_adapter_name). The SAX engine
14
+ # follows the resolved adapter leptris (correct since leptris#625
15
+ # and leptris-ruby#99; CI perf-gated). The DOM engine stays Nokogiri
16
+ # until the record conversion passes the same gate (moxml#143's fix
17
+ # landed; still -40%/-37% from_xml on the CI runner). Conformance
18
+ # parity is complete (engine_parity_spec 12/12, zero pendings).
19
+ # CANON_XML_BACKEND=moxml opts into the leptris DOM engine today.
22
20
  #
23
21
  # HTML stays on Nokogiri on CRuby (Canon::Html::NokogiriSupport) and the
24
22
  # pretty-printers keep the Nokogiri pipeline — pretty-printed bytes are
@@ -63,6 +61,11 @@ module Canon
63
61
  def detect
64
62
  return :moxml if RUBY_ENGINE == "opal"
65
63
 
64
+ # The SAX engine flipped to leptris (leptris#625/#99 fixed,
65
+ # CI-gated — see Canon::Xml::Sax), but the DOM conversion still
66
+ # trails Nokogiri on the CI runner (-40%/-37% from_xml after
67
+ # moxml#143's emission fix landed). Nokogiri stays the DOM
68
+ # default until that gate passes; flipping is this one line.
66
69
  :nokogiri
67
70
  end
68
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-29 00:00:00.000000000 Z
11
+ date: 2026-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs