metanorma-standoc 3.5.1.pre.alpha.1 → 3.5.1.pre.alpha.2

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: 8001a19a529d536d37e1f035e1fcc45585ecfdecaece0e2466b00a684807f71c
4
- data.tar.gz: aa1838be7a5e6dfb6675251a4c0871aafb58e427a4bea598a60849e5263b4e22
3
+ metadata.gz: 20d96c893a795276c186f9db7477b532d9aa721249e1060a18637dac83ad3393
4
+ data.tar.gz: 18d954ac50528b1284a97507fa5d0ebe9ddcd24eb00f45682281a14b0832d3e7
5
5
  SHA512:
6
- metadata.gz: 48756dd12f0f9ba7f553e0c762b398688d812bf86780a6a860f88c09c32395e7460a3bbc9556e0a0c02b5d9d61a998ff1897c04708b6f545693e6600ceb93be8
7
- data.tar.gz: c9bfc8a020ab69a476d91d737acdf13d319b41b8e234b64d23ceb2770ab976cf79dbddd984c3393a395bae69adc54cd2d06797e4b725c023ac1c5bfb4ce5ef78
6
+ metadata.gz: 8f96198b09ca3df70057291824dfc2e95ac804d3f64ea7069fddcaac5924df9c486ea32a65503ffde29301982978047e04800d08a55b25629746191cf57af4dc
7
+ data.tar.gz: 1c21fe689c11c6162ae93b827eb7721de93f6173a86c86d3abca5585006f2c803bdc34e7d009cf4efc35e03b379c3d234058c6504a2c8d15f9a189fb64c34809
@@ -185,18 +185,6 @@ module Metanorma
185
185
  node[:selector] = Crass.parse("#{v} {}").first[:selector]
186
186
  end
187
187
 
188
- IRI_TAG_PROPERTIES_MAP = {
189
- clipPath: ["clip-path"],
190
- "color-profile": nil,
191
- cursor: nil,
192
- filter: nil,
193
- linearGradient: ["fill", "stroke"],
194
- marker: ["marker", "marker-end", "marker-mid", "marker-start"],
195
- mask: nil,
196
- pattern: ["fill", "stroke"],
197
- radialGradient: ["fill", "stroke"],
198
- }.freeze
199
-
200
188
  SVG_NS = "http://www.w3.org/2000/svg".freeze
201
189
 
202
190
  def svg_uniqueids(xmldoc)
@@ -204,77 +192,32 @@ module Metanorma
204
192
  ids = xmldoc.xpath("//m:svg//*/@id | //svg/@id", "m" => SVG_NS)
205
193
  .map(&:text).group_by(&:itself).transform_values(&:count)
206
194
  .delete_if { |_, v| v < 2 }
207
- xmldoc.xpath("//m:svg", "m" => SVG_NS).each_with_index do |s, i|
208
- ids = svg_uniqueids1(s, i, ids)
195
+ # re-resolve by position each time: replacing an outer SVG detaches
196
+ # the nodes of any SVG nested inside it
197
+ xmldoc.xpath("//m:svg", "m" => SVG_NS).size.times do |i|
198
+ svg = xmldoc.xpath("//m:svg", "m" => SVG_NS)[i]
199
+ ids = svg_uniqueids1(svg, i, ids)
209
200
  end
210
201
  end
211
202
 
212
- def svg_iri_properties(id_elems)
213
- iri_tag_names = id_elems.each_with_object([]) do |e, m|
214
- IRI_TAG_PROPERTIES_MAP.key?(e.name.to_sym) and m << e.name
215
- end.uniq
216
- iri_properties = iri_tag_names.each_with_object([]) do |t, m|
217
- (IRI_TAG_PROPERTIES_MAP[t.to_sym] || [t]).each { |t1| m = m << t1 }
218
- end.uniq
219
- iri_properties.empty? and return []
220
- iri_properties << "style"
221
- end
222
-
203
+ # Vectory returns a rewritten copy: reparse it with the caller's XML
204
+ # library and swap it into the caller's tree.
223
205
  def svg_uniqueids1(svg, idx, ids)
224
- id_elems = svg.xpath(".//*[@id] | ./@id/..")
225
- iri_properties = svg_iri_properties(id_elems)
226
- svg_uniqueids2(svg, iri_properties, idx, ids)
227
- new_ids = id_elems.map { |x| x["id"] }
228
- .map { |x| x + (ids[x] ? "_inject_#{idx}" : "") }
206
+ rewritten = Vectory::SvgIdDisambiguator
207
+ .rewrite(svg.to_xml, "_inject_#{idx}", ids)
208
+ .sub(/\A<\?xml[^>]*\?>\s*/, "")
209
+ new_svg = svg_replace(svg, rewritten)
210
+ new_ids = new_svg.xpath(".//*[@id] | ./@id/..").map { |x| x["id"] }
229
211
  ids.merge(new_ids.each.to_h { |value| [value, true] })
230
212
  end
231
213
 
232
- def svg_uniqueids2(svg, iri_properties, idx, ids)
233
- svg.traverse do |e|
234
- e.element? or next
235
- if e.name == "style"
236
- svg_styleupdate(e, idx, ids)
237
- elsif !e.attributes.empty?
238
- svg_attrupdate(e, iri_properties, idx, ids)
239
- end
240
- svg_linkupdate(e, idx, ids)
241
- svg_idupdate(e, idx, ids)
242
- end
243
- end
244
-
245
- def svg_update_url(text, idx, ids)
246
- text.gsub(/url\("?#([a-zA-Z][\w:.-]*)"?\)/) do |x|
247
- if ids[$1] then "url(##{$1}_inject_#{idx})"
248
- else x
249
- end
250
- end
251
- end
252
-
253
- def svg_styleupdate(elem, idx, ids)
254
- elem.children = svg_update_url(elem.text, idx, ids)
255
- end
256
-
257
- def svg_attrupdate(elem, iri_properties, idx, ids)
258
- iri_properties.each do |p|
259
- elem[p] or next
260
- elem[p] = svg_update_url(elem[p], idx, ids)
214
+ def svg_replace(svg, xml)
215
+ if defined?(Moxml) && svg.is_a?(Moxml::Node)
216
+ Moxml.new(:leptris).parse(xml).root.tap { |n| svg.replace(n) }
217
+ else
218
+ svg.replace(xml).first
261
219
  end
262
220
  end
263
-
264
- def svg_linkupdate(elem, idx, ids)
265
- %w(xlink:href href).each do |ref|
266
- iri = elem[ref]&.strip
267
- /^#/.match?(iri) or next
268
- ids[iri.sub(/^#/, "")] or next
269
- elem[ref] += "_inject_#{idx}"
270
- end
271
- end
272
-
273
- def svg_idupdate(elem, idx, ids)
274
- elem["id"] or return
275
- ids[elem["id"]] or return
276
- elem["id"] += "_inject_#{idx}"
277
- end
278
221
  end
279
222
  end
280
223
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "3.5.1.pre.alpha.1".freeze
22
+ VERSION = "3.5.1.pre.alpha.2".freeze
23
23
  end
24
24
  end
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  # spec.add_dependency "iev", "~> 0.4"
35
35
  spec.add_dependency "isodoc", "~> 3.7.2"
36
36
  spec.add_dependency "metanorma-core", "~> 0.2.3"
37
- spec.add_dependency "metanorma-document"
37
+ spec.add_dependency "metanorma-document", ">= 0.5.2.pre.alpha.1"
38
38
  spec.add_dependency "metanorma-mirror"
39
39
  spec.add_dependency "metanorma-plugin-asciichem", "~> 0.1.0"
40
40
  spec.add_dependency "metanorma-plugin-glossarist", "~> 0.5"
@@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
48
48
  # svgmap_cleanup reparses vectory's returned document and grafts the
49
49
  # content back (the 0.13 SvgMapping contract: vectory processes its own
50
50
  # tree and returns the result instead of mutating the caller's document).
51
- spec.add_dependency "vectory", "~> 0.13"
51
+ spec.add_dependency "vectory", "~> 0.13", ">= 0.13.2"
52
52
  # Floor names the 3.0.0 prerelease: bundler only considers prereleases
53
53
  # when a requirement names one, and the ecosystem target is relaton 3.0+
54
54
  # (glossarist 2.14+ requires relaton ~> 3.0.0.pre.alpha).
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1.pre.alpha.1
4
+ version: 3.5.1.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-22 00:00:00.000000000 Z
11
+ date: 2026-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.5.2.pre.alpha.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.5.2.pre.alpha.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: metanorma-mirror
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +241,9 @@ dependencies:
241
241
  - - "~>"
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0.13'
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: 0.13.2
244
247
  type: :runtime
245
248
  prerelease: false
246
249
  version_requirements: !ruby/object:Gem::Requirement
@@ -248,6 +251,9 @@ dependencies:
248
251
  - - "~>"
249
252
  - !ruby/object:Gem::Version
250
253
  version: '0.13'
254
+ - - ">="
255
+ - !ruby/object:Gem::Version
256
+ version: 0.13.2
251
257
  - !ruby/object:Gem::Dependency
252
258
  name: relaton-cli
253
259
  requirement: !ruby/object:Gem::Requirement