metanorma-utils 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8ae87e8a2582071abee8bdf9dcedc29748752e841d8223d3ccea204fc6446c3
4
- data.tar.gz: 6e49a57e3062b5ce3860de9ee92eab343f5c9bc8044687ae4ff13e38a3c79546
3
+ metadata.gz: 91f96b7aa6ec3c7ee29649b93edc0dfc1b485ab5db05f6b5c8dcf4f3c38da3bb
4
+ data.tar.gz: '080959b8d7c6057098cbf4cd6d22b6711f10ee122b85a833af16cfc352a1ccb1'
5
5
  SHA512:
6
- metadata.gz: d1659ee28aa09a7de7260f87676e5b6b07ae0efe9af2fdd48a2d15a980e80ade14d48a5f728112c41bf44c06da186b7a2991e966c75a06c8a507faf2f7bcc3e3
7
- data.tar.gz: 40eb1d98da67ea6f743e9f57cc11dcd0ec5493947cc57078466be59d336fedf164b57bb3aa78b2bce3ab0acf674221e3dc40573972ec21b9a33f33332cb4eeb7
6
+ metadata.gz: 8702b7f309905c9add48241b1f6ca0a6bd11832171d0d7bdbfed97e61fad52dcb86e0eacb680ea3e888fee9f7b2c445b5790e62e4f90779b26152bed168b7880
7
+ data.tar.gz: c218e92eda255cb5d0dd8351146f65eefb83f361d206d8e2d12b4bc4e076cdcb49826a349cf560847af91365b050c95ee13ee30c658f7d40d12bcae46d2d208e
@@ -78,6 +78,38 @@ module Metanorma
78
78
  hash
79
79
  end
80
80
 
81
+ def svgmap_rewrite(xmldoc)
82
+ xmldoc.xpath("//svgmap").each do |s|
83
+ next unless s["src"]
84
+ path = File.file?(s["src"]) ? s["src"] : @localdir + s["src"]
85
+ File.file?(path) or next
86
+ svg = Nokogiri::XML(File.read(path, encoding: "utf-8"))
87
+ svgmap_rewrite1(s, svg, path)
88
+ next if s.at(".//eref")
89
+ svgmap_to_image(s, svg&.at(".//xmlns:image/@height")&.text, svg&.at(".//xmlns:image/@width")&.text)
90
+ end
91
+ end
92
+
93
+ def svgmap_to_image(s, height, width)
94
+ s.children.remove
95
+ s.name = "img"
96
+ s["mimetype"] = "image/svg+xml"
97
+ s["height"] = height || "auto"
98
+ s["width"] = width || "auto"
99
+ end
100
+
101
+ def svgmap_rewrite1(s, svg, path)
102
+ targets = s.xpath("./target").each_with_object({}) do |t, m|
103
+ x = t.at("./xref") and m[t["href"]] = "##{x['target']}"
104
+ x = t.at("./link") and m[t["href"]] = x['target']
105
+ t.remove if t.at("./xref | ./link")
106
+ end
107
+ svg.xpath(".//xmlns:a").each do |a|
108
+ x = targets[a["xlink:href"]] and a["xlink:href"] = x
109
+ end
110
+ File.open(path, "w", encoding: "utf-8") { |f| f.write(svg.to_xml) }
111
+ end
112
+
81
113
  # not currently used
82
114
  def flatten_rawtext_lines(node, result)
83
115
  node.lines.each do |x|
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.0.1".freeze
3
+ VERSION = "1.0.2".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,122 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
+ <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
+ viewBox="0 0 595.28 841.89" style="enable-background:new 0 0 595.28 841.89;" xml:space="preserve">
5
+ <style type="text/css">
6
+ .st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
7
+ </style>
8
+ <image style="overflow:visible;" width="368" height="315" xlink:href="data:image/gif;base64,R0lGODlhcAE7Aff/AAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBm
9
+ ZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/
10
+ mQD/zAD//zMAADMAMzMAZjM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AstCBGKikuMhx/QYRczNW0Fb
103
+ ouMi5HTEN5p559zN4iqvCMHe4gqvLvpLHLod9arEJPxyip2zV4ukBSRi+ORPI3ZFVOxPRySr6ciw
104
+ CCSPJkYp1LN497jU+/GwTRqxC6fODMKjvQd7bnvXklu1lUuyKFmCqB2nzMdjGxKnL+ZjLatgLxtA
105
+ BCWzsymyIU4u//3Y68JLAkSSL0aPRJUIXAZk0ToiZpYkx3PiL745GUnHQRuzVvW0PhuXpC0QIz65
106
+ CzOOg9xzarWFY7JnNqd7hNzlgCy23+0+Z/WoLjlCZhWpcPJXTytXOZ4TcOvbN/odpFZp/osMRZ9m
107
+ RUrpqhtEt2sUaXBsWgGgArLVqqcKJEhpuIWTuK61uJlCTXxr5T8x4qAr3TZISVxdlkORuRv8EFrz
108
+ 6QkjFJ8Lu6NbuqohbDliaaSuuizhyjPWE/Nru/QSu7Nbu7QtFJpdELqbL7zru70unzxRD8lrvN5r
109
+ vsuOvuXr7OfLveML7c0u7c9u7dEevt+77cwuvteu7d2uvuzb2ORe7u97ZvV7v8UevBLGv/4LwHi+
110
+ ZARswAgc77C27vqba/guwMe27x997/Z+av6O3QC/5co28BQs8AFfaAgv0gWf3Apv8P2+8GfW8CJ8
111
+ 8BS/ZBYP2fqe8TK28Xmdaydj7iRfFvIpo8qEnfIqv/Is3/Iu//IwH/OhERAAOw==" transform="matrix(1 0 0 1 114 263.8898)">
112
+ </image>
113
+ <a xlink:href="mn://action_schema" >
114
+ <rect x="123.28" y="273.93" class="st0" width="88.05" height="41.84"/>
115
+ </a>
116
+ <a xlink:href="mn://basic_attribute_schema" >
117
+ <rect x="324.69" y="450.52" class="st0" width="132.62" height="40.75"/>
118
+ </a>
119
+ <a xlink:href="mn://support_resource_schema" >
120
+ <rect x="324.69" y="528.36" class="st0" width="148.16" height="40.75"/>
121
+ </a>
122
+ </svg>
@@ -5,6 +5,7 @@ end
5
5
  require "rspec/matchers"
6
6
  require "equivalent-xml"
7
7
  require "metanorma-utils"
8
+ require "rexml/document"
8
9
 
9
10
  RSpec.configure do |config|
10
11
  # Enable flags like --only-failures and --next-failure
@@ -32,3 +33,10 @@ class Dummy
32
33
  end
33
34
  end
34
35
 
36
+ def xmlpp(x)
37
+ s = ""
38
+ f = REXML::Formatters::Pretty.new(2)
39
+ f.compact = true
40
+ f.write(REXML::Document.new(x), s)
41
+ s
42
+ end
@@ -72,6 +72,92 @@ RSpec.describe Metanorma::Utils do
72
72
  OUTPUT
73
73
  end
74
74
 
75
+ it "rewrites SVGs" do
76
+ FileUtils.cp "spec/fixtures/action_schemaexpg1.svg", "action_schemaexpg1.svg"
77
+ FileUtils.cp "spec/fixtures/action_schemaexpg1.svg", "action_schemaexpg2.svg"
78
+ xmldoc = Nokogiri::XML(<<~INPUT)
79
+ <standard-document type="semantic" version="1.8.2">
80
+ <bibdata type="standard">
81
+ <title language="en" format="text/plain">Document title</title>
82
+ <docidentifier/>
83
+ <docnumber/>
84
+ <version/>
85
+ <language>en</language>
86
+ <script>Latn</script>
87
+ <status>
88
+ <stage>published</stage>
89
+ </status>
90
+ <copyright>
91
+ <from>2021</from>
92
+ </copyright>
93
+ <ext>
94
+ <doctype>article</doctype>
95
+ </ext>
96
+ </bibdata>
97
+ <sections><svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
98
+ <svgmap id="_4072bdcb-5895-4821-b636-5795b96787cb" src="action_schemaexpg1.svg"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target><target href="http://www.example.com"><link target="http://www.example.com">Phone</link></target></svgmap>
99
+ <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd" src="action_schemaexpg2.svg" alt="Workmap"><target href="href1.htm"><xref target="ref1">Computer</xref></target><target href="mn://basic_attribute_schema"><link target="http://www.example.com">Phone</link></target><target href="mn://support_resource_schema"><eref type="express" bibitemid="express_action_schema" citeas=""><localityStack><locality type="anchor"><referenceFrom>action_schema.basic</referenceFrom></locality></localityStack>Coffee</eref></target></svgmap></sections>
100
+ </standard-document>
101
+ INPUT
102
+ Metanorma::Utils.svgmap_rewrite(xmldoc)
103
+ expect(xmldoc.to_xml).to be_equivalent_to <<~OUTPUT
104
+ <standard-document type="semantic" version="1.8.2">
105
+ <bibdata type="standard">
106
+ <title language="en" format="text/plain">Document title</title>
107
+ <docidentifier/>
108
+ <docnumber/>
109
+ <version/>
110
+ <language>en</language>
111
+ <script>Latn</script>
112
+ <status>
113
+ <stage>published</stage>
114
+ </status>
115
+ <copyright>
116
+ <from>2021</from>
117
+ </copyright>
118
+ <ext>
119
+ <doctype>article</doctype>
120
+ </ext>
121
+ </bibdata>
122
+ <sections><svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
123
+ <img id="_4072bdcb-5895-4821-b636-5795b96787cb" src="action_schemaexpg1.svg" mimetype="image/svg+xml" height="315" width="368"/>
124
+ <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd" src="action_schemaexpg2.svg" alt="Workmap"><target href="mn://support_resource_schema"><eref type="express" bibitemid="express_action_schema" citeas=""><localityStack><locality type="anchor"><referenceFrom>action_schema.basic</referenceFrom></locality></localityStack>Coffee</eref></target></svgmap></sections>
125
+ </standard-document>
126
+ OUTPUT
127
+ expect(xmlpp(File.read("action_schemaexpg1.svg", encoding: "utf-8").sub(%r{<image .*</image>}m, ""))).to be_equivalent_to <<~OUTPUT
128
+ <?xml version='1.0' encoding='UTF-8'?>
129
+ <!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
130
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
131
+ <style type='text/css'> .st0{fill:none;stroke:#000000;stroke-miterlimit:10;} </style>
132
+ <a xlink:href='#ref1'>
133
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
134
+ </a>
135
+ <a xlink:href='mn://basic_attribute_schema'>
136
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
137
+ </a>
138
+ <a xlink:href='mn://support_resource_schema'>
139
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
140
+ </a>
141
+ </svg>
142
+ OUTPUT
143
+ expect(xmlpp(File.read("action_schemaexpg2.svg", encoding: "utf-8").sub(%r{<image .*</image>}m, ""))).to be_equivalent_to <<~OUTPUT
144
+ <?xml version='1.0' encoding='UTF-8'?>
145
+ <!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
146
+ <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
147
+ <style type='text/css'> .st0{fill:none;stroke:#000000;stroke-miterlimit:10;} </style>
148
+ <a xlink:href='mn://action_schema'>
149
+ <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
150
+ </a>
151
+ <a xlink:href='http://www.example.com'>
152
+ <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
153
+ </a>
154
+ <a xlink:href='mn://support_resource_schema'>
155
+ <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
156
+ </a>
157
+ </svg>
158
+ OUTPUT
159
+ end
160
+
75
161
  # not testing Asciidoctor log extraction here
76
162
  it "generates log" do
77
163
  xml = Nokogiri::XML(<<~INPUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.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: 2021-01-25 00:00:00.000000000 Z
11
+ date: 2021-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sterile
@@ -253,6 +253,7 @@ files:
253
253
  - lib/utils/main.rb
254
254
  - lib/utils/version.rb
255
255
  - metanorma-utils.gemspec
256
+ - spec/fixtures/action_schemaexpg1.svg
256
257
  - spec/spec_helper.rb
257
258
  - spec/utils_spec.rb
258
259
  homepage: https://github.com/metanorma/metanorma-utils
@@ -274,7 +275,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
275
  - !ruby/object:Gem::Version
275
276
  version: '0'
276
277
  requirements: []
277
- rubygems_version: 3.0.3
278
+ rubygems_version: 3.1.4
278
279
  signing_key:
279
280
  specification_version: 4
280
281
  summary: metanorma-utils