canon 0.3.11 → 0.3.12

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: d77d47de69156fdb3e8f88265fc5001b817095efd353dfc69e2d76dc94fb0c7a
4
- data.tar.gz: 0d5c91f098eb11d20952314047c6a2e0c9e1b6dc5dc50cd8b0a148061e8d528f
3
+ metadata.gz: cb5f47fd1b5759edefe57276d19baec565e015cebc47c683125875dad10122b2
4
+ data.tar.gz: e21fe66a481474c041add458fdbf2e7bcb39dfc910d5fe58f3c6394f33929426
5
5
  SHA512:
6
- metadata.gz: 327210061ef13044a7e27f1b7ecc604ab83b361371bbf5282382b3637b0b224c70a782068c9b3b8557ef18b3631385de4b907e796abc6800a83cf85ad8ded20b
7
- data.tar.gz: e3337e3f0102d94e9a66dcf4adcc9517104a3eb947f6fd3e34080cfb605898411848b25821b4eaa0e087b4845a2abfbf08d81538b6f6ad9084a44026e775fbed
6
+ metadata.gz: a28e38753f0ac126563f37bdea72adec9f605885c25320f09407b4367495ee17c72b60f014615bc7bad6c352640eda067ece20ef4e04361632ae7fd8323f644d
7
+ data.tar.gz: 6db620f6c3ccdb828102c7b80489b302396e8bdda96c07b0a11abb65b4e2cc09b08ea7ea221cb9bfced71eaaaad829ccc37c1e47d0a88036e2f8c25e5d6b15c4
@@ -12,14 +12,16 @@ module Canon
12
12
 
13
13
  def format(xml_string)
14
14
  # Output parity: pretty-printed bytes are canon's product. The
15
- # moxml serializer cannot yet match Nokogiri's output (empty
16
- # element expansion, declaration placement, tab indent), so the
17
- # Nokogiri pipeline is used whenever available the moxml branch
18
- # is the Opal fallback.
19
- if defined?(Nokogiri)
20
- nokogiri_format(xml_string)
21
- else
15
+ # leptris serializer matches Nokogiri byte-for-byte for space
16
+ # and tab indentation (moxml#153/#155/#156) and runs faster
17
+ # since moxml#158, with the #167 escaping race fixed in 0.5.28
18
+ # the fixture integrity suite and the CI performance gate are
19
+ # the standing gates. Nokogiri serves the fallback engine and
20
+ # Opal.
21
+ if RUBY_ENGINE == "opal" || Canon::XmlBackend.moxml?
22
22
  moxml_format(xml_string)
23
+ else
24
+ nokogiri_format(xml_string)
23
25
  end
24
26
  end
25
27
 
@@ -35,8 +37,16 @@ module Canon
35
37
  end
36
38
 
37
39
  def moxml_format(xml_string)
38
- doc = Canon::XmlParsing.parse(xml_string)
39
- doc.to_xml
40
+ # noblanks mutates the tree (strips whitespace-only text), so
41
+ # the document cannot be readonly.
42
+ doc = Canon::XmlParsing.moxml_context.parse(xml_string, noblanks: true)
43
+ if @indent_type == "tab"
44
+ doc.to_xml(declaration: true, encoding: "UTF-8",
45
+ indent: 1, indent_text: "\t", expand_empty: false)
46
+ else
47
+ doc.to_xml(declaration: true, encoding: "UTF-8",
48
+ indent: @indent, expand_empty: false)
49
+ end
40
50
  end
41
51
  end
42
52
  end
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.11"
4
+ VERSION = "0.3.12"
5
5
  end
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.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.