metanorma-utils 1.2.0 → 1.2.1
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 +4 -4
- data/lib/utils/image.rb +2 -1
- data/lib/utils/version.rb +1 -1
- data/spec/utils_spec.rb +7 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e32e0167b7ef50067c61aca6c6d270c239d6095f428b2d94cae193ef0ff97643
|
4
|
+
data.tar.gz: 4d374d23469c0ba74cae811f155a430fb6a7c0865558fd5e332555ed4cd646b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e560c04556fc4439ac3af71692e7f552048737c71148cbed4448e97fc12be5bcea60c467c03bb1ade45e53b2e482a6ca5781f81561a17a570e77a9f127ce959
|
7
|
+
data.tar.gz: 3befc32a1486a098183b21f341741cf857161c93c56ad51261c6d2035c9d117f6d12638693ace505701e228dcc1034fcfc4a3264746e52e34dcb58c97e0dbab5
|
data/lib/utils/image.rb
CHANGED
@@ -50,7 +50,7 @@ module Metanorma
|
|
50
50
|
path = svgmap_rewrite0_path(src, localdirectory)
|
51
51
|
File.file?(path) or return false
|
52
52
|
svg = Nokogiri::XML(File.read(path, encoding: "utf-8"))
|
53
|
-
i.replace(svgmap_rewrite1(svgmap, svg, namespace))
|
53
|
+
i.replace(svgmap_rewrite1(svgmap, svg.root, namespace))
|
54
54
|
/^data:/.match(src) and i["src"] = datauri(path)
|
55
55
|
elsif i = svgmap.at(".//m:svg", "m" => SVG_NS)
|
56
56
|
i.replace(svgmap_rewrite1(svgmap, i, namespace))
|
@@ -75,6 +75,7 @@ module Metanorma
|
|
75
75
|
a[p] and x = targ[File.expand_path(a[p])] and a[p] = x
|
76
76
|
end
|
77
77
|
end
|
78
|
+
svg.xpath("processing-instruction()|.//processing-instruction()").remove
|
78
79
|
svg.to_xml
|
79
80
|
end
|
80
81
|
|
data/lib/utils/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
@@ -158,9 +158,7 @@ RSpec.describe Metanorma::Utils do
|
|
158
158
|
</target>
|
159
159
|
</svgmap>
|
160
160
|
<figure>
|
161
|
-
|
162
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
163
|
-
<svg xmlns='http://www.w3.org/2000/svg' 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' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
161
|
+
<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'>
|
164
162
|
<style/>
|
165
163
|
<image/>
|
166
164
|
<a xlink:href='#ref1'>
|
@@ -176,9 +174,7 @@ RSpec.describe Metanorma::Utils do
|
|
176
174
|
</figure>
|
177
175
|
<svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
|
178
176
|
<figure>
|
179
|
-
|
180
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
181
|
-
<svg xmlns='http://www.w3.org/2000/svg' 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' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
177
|
+
<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'>
|
182
178
|
<style/>
|
183
179
|
<image/>
|
184
180
|
<a xlink:href='mn://action_schema'>
|
@@ -204,7 +200,7 @@ RSpec.describe Metanorma::Utils do
|
|
204
200
|
</target>
|
205
201
|
</svgmap>
|
206
202
|
<figure>
|
207
|
-
|
203
|
+
<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'>
|
208
204
|
<a href='#ref1'>
|
209
205
|
<rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
|
210
206
|
</a>
|
@@ -218,9 +214,7 @@ RSpec.describe Metanorma::Utils do
|
|
218
214
|
</figure>
|
219
215
|
<svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
|
220
216
|
<figure>
|
221
|
-
|
222
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
223
|
-
<svg xmlns='http://www.w3.org/2000/svg' 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' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
217
|
+
<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'>
|
224
218
|
<style/>
|
225
219
|
<image/>
|
226
220
|
<a xlink:href='mn://action_schema'>
|
@@ -287,6 +281,7 @@ RSpec.describe Metanorma::Utils do
|
|
287
281
|
INPUT
|
288
282
|
Metanorma::Utils.svgmap_rewrite(xmldoc)
|
289
283
|
expect(xmlpp(xmldoc.to_xml.gsub(%r{<image.*?</image>}m, "<image/>").gsub(%r{<style.*?</style>}m, "<style/>"))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
284
|
+
<?xml version='1.0'?>
|
290
285
|
<standard-document type="semantic" version="1.8.2" xmlns="http://www.example.com">
|
291
286
|
<bibdata type="standard">
|
292
287
|
<title language="en" format="text/plain">Document title</title>
|
@@ -307,9 +302,7 @@ RSpec.describe Metanorma::Utils do
|
|
307
302
|
</bibdata>
|
308
303
|
<sections><svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
|
309
304
|
<figure>
|
310
|
-
|
311
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
312
|
-
<svg xmlns='http://www.w3.org/2000/svg' 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' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
305
|
+
<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'>
|
313
306
|
<style/>
|
314
307
|
<image/>
|
315
308
|
<a xlink:href='#ref1'>
|
@@ -325,9 +318,7 @@ RSpec.describe Metanorma::Utils do
|
|
325
318
|
</figure>
|
326
319
|
<svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
|
327
320
|
<figure>
|
328
|
-
|
329
|
-
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
330
|
-
<svg xmlns='http://www.w3.org/2000/svg' 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' xmlns:xlink='http://www.w3.org/1999/xlink'>
|
321
|
+
<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'>
|
331
322
|
<style/>
|
332
323
|
<image/>
|
333
324
|
<a xlink:href='mn://action_schema'>
|