canon 0.3.17 → 0.3.18

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: acd6e56003a73f4bee16d0e835892b42e37a58c727bd898fffbcaf24cefa3f03
4
- data.tar.gz: 6e6ed37c6dd5fef784562fe82df04d3700a6f69ba0ee3f6983d7d21df0e95109
3
+ metadata.gz: b27c3659e1b75307f170fb50161ce649c54ab4a12600716d3b006fce8b01ad1a
4
+ data.tar.gz: 89c288d724f4a3b0b410938d94959880b4fbbcff1ec550b53593840bd33d52c8
5
5
  SHA512:
6
- metadata.gz: c6229f67b92e300793b056bee9e0f17af12646213806c44724dd5cd0080da43069c816466ce29af36e23d2c942a571c8361c6ded5dff62d88826ddd5b5e64a76
7
- data.tar.gz: ed684a66f994208cc599bd58b18545fbe5993b4d8d2f9029fd851d5cfb65573a431ca92c778783b71cadcedeeda575ceff19812e1a10adbc6d87c64b7b7d248d
6
+ metadata.gz: '0922a2a6d6061f7472ac55de8c6e0172a8ce8d2939f8f144f71493b148248fb597c07d916c67dc9a4549d35a6e65b7757e5cb3f0d0ae79a7a39f7b35306bbb22'
7
+ data.tar.gz: e5b5b898ca11ef0bdc077d8cfb78d6575bc7c9a6b712f2a0ccbd2a3f338704d66883c730e32651af1776746b751b996c723b29af80044d8cd44944f9b18df883
@@ -23,8 +23,12 @@ module Canon
23
23
  def self.sort_yaml_keys(obj)
24
24
  case obj
25
25
  when Hash
26
- obj.transform_values { |v| sort_yaml_keys(v) }
27
- .sort.to_h
26
+ # Single pass: sorted keys once, one rebuilt hash (the
27
+ # transform_values + sort.to_h form rebuilt every container
28
+ # twice).
29
+ sorted = {}
30
+ obj.keys.sort.each { |key| sorted[key] = sort_yaml_keys(obj[key]) }
31
+ sorted
28
32
  when Array
29
33
  obj.map { |item| sort_yaml_keys(item) }
30
34
  else
@@ -134,8 +134,7 @@ module Canon
134
134
  keep: Canon::Xml::WhitespacePolicy.keep_html_text?(
135
135
  node.content,
136
136
  parent_name: node.parent.is_a?(Nokogiri::XML::Element) ? node.parent.name : nil,
137
- inline_significant:
138
- Canon::Comparison::WhitespaceSensitivity.inline_whitespace_significant?(node),
137
+ text_node: node,
139
138
  ),
140
139
  )
141
140
  when Nokogiri::XML::Comment
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.17"
4
+ VERSION = "0.3.18"
5
5
  end
@@ -61,13 +61,18 @@ element_parent: true)
61
61
  # so it is checked explicitly).
62
62
  HTML_WHITESPACE_SENSITIVE_TAGS = %w[pre code textarea script style].freeze
63
63
 
64
- def keep_html_text?(content, parent_name:, inline_significant: false)
64
+ def keep_html_text?(content, parent_name:, text_node: nil)
65
65
  return true unless content.match?(STRIP_ONLY)
66
66
  return true if content.include?(" ")
67
67
 
68
68
  parent_name = parent_name.to_s.downcase
69
69
  return true if HTML_WHITESPACE_SENSITIVE_TAGS.include?(parent_name)
70
- return true if inline_significant
70
+
71
+ # Computed last: the sibling scan is O(siblings), so it must
72
+ # not run for the content-bearing text nodes that fail the
73
+ # whitespace-only check above.
74
+ return true if text_node &&
75
+ Canon::Comparison::WhitespaceSensitivity.inline_whitespace_significant?(text_node)
71
76
 
72
77
  false
73
78
  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.17
4
+ version: 0.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.