metanorma-utils 1.4.5 → 1.4.6

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: cf98f7674d114f222187c3da69bd8c436990eaec0a9a988402afdd8e178fe2e8
4
- data.tar.gz: fecee536903d05211404268e2408c983c32332aabdfaac56de813d7a7fdc8eef
3
+ metadata.gz: 6cb00a5f8e7ff86f9d16128e0c8cb1587c24897b17377ef72238ef53b26a6679
4
+ data.tar.gz: 52620169a6fc3515cd8be7ecc7f6926759382d05f57faa5dd40acf29d8f8c649
5
5
  SHA512:
6
- metadata.gz: e2f07346a598463eeb74fabb69e930ce7bb343a72e574303d3a22517532d421bb2df84733bcebd846bfce69b20d9cb1ee798d917dadcfe44f46920606a9b64c8
7
- data.tar.gz: 8cb5b3a0b22c94d6945002d2735e4babc9809056bd14e26b396ec3d03391d5867829e21fad78955cca7c62cb876c56adb9d896feb53957c9c3da74dcd400bfa3
6
+ metadata.gz: 94acee04cfb8fde0caa49de7d0c88e18e6796af8871f0ba3b374b07c1172f86290abf641590fa5c7c3f13c52b3d492c907444142c439b322df8c914cc8a81527
7
+ data.tar.gz: 4c613bf6368276e0472e96f1fd44c55f87e42e1935aaa24482c39ae68cca6861456929ad18afbebc0f3ddedd271d83ed6511cd96df0d3608866cf0e9d8827383
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.4.5".freeze
3
+ VERSION = "1.4.6".freeze
4
4
  end
5
5
  end
data/lib/utils/xml.rb CHANGED
@@ -58,7 +58,9 @@ module Metanorma
58
58
  doc = ::Nokogiri::XML.parse(NOKOHEAD)
59
59
  fragment = doc.fragment("")
60
60
  ::Nokogiri::XML::Builder.with fragment, &block
61
- fragment.to_xml(encoding: "US-ASCII").lines.map do |l|
61
+ fragment.to_xml(encoding: "US-ASCII", indent: 0,
62
+ save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
63
+ .lines.map do |l|
62
64
  l.gsub(/\s*\n/, "")
63
65
  end
64
66
  end
@@ -20,9 +20,12 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.bindir = "bin"
22
22
  spec.require_paths = ["lib"]
23
- spec.files = `git ls-files`.split("\n")
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features|bin|.github)/}) \
25
+ || f.match(%r{Rakefile|bin/rspec})
26
+ end
24
27
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
25
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
26
29
 
27
30
  spec.add_dependency "asciidoctor", ">= 2"
28
31
  spec.add_dependency "concurrent-ruby"
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.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2023-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -299,16 +299,12 @@ executables: []
299
299
  extensions: []
300
300
  extra_rdoc_files: []
301
301
  files:
302
- - ".github/workflows/rake.yml"
303
- - ".github/workflows/release.yml"
304
302
  - ".gitignore"
305
303
  - ".hound.yml"
306
304
  - ".rubocop.yml"
307
305
  - Gemfile
308
306
  - LICENSE
309
307
  - README.adoc
310
- - Rakefile
311
- - bin/rspec
312
308
  - lib/metanorma-utils.rb
313
309
  - lib/utils/hash_transform_keys.rb
314
310
  - lib/utils/image.rb
@@ -317,13 +313,6 @@ files:
317
313
  - lib/utils/version.rb
318
314
  - lib/utils/xml.rb
319
315
  - metanorma-utils.gemspec
320
- - spec/fixtures/action_schemaexpg1.svg
321
- - spec/fixtures/rice_image1.png
322
- - spec/hash_transform_keys_spec.rb
323
- - spec/img_spec.rb
324
- - spec/spec_helper.rb
325
- - spec/utils_spec.rb
326
- - spec/xml_spec.rb
327
316
  homepage: https://github.com/metanorma/metanorma-utils
328
317
  licenses:
329
318
  - BSD-2-Clause
@@ -336,14 +325,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
336
325
  requirements:
337
326
  - - ">="
338
327
  - !ruby/object:Gem::Version
339
- version: 2.5.0
328
+ version: 2.7.0
340
329
  required_rubygems_version: !ruby/object:Gem::Requirement
341
330
  requirements:
342
331
  - - ">="
343
332
  - !ruby/object:Gem::Version
344
333
  version: '0'
345
334
  requirements: []
346
- rubygems_version: 3.1.6
335
+ rubygems_version: 3.3.26
347
336
  signing_key:
348
337
  specification_version: 4
349
338
  summary: metanorma-utils
@@ -1,15 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: rake
4
-
5
- on:
6
- push:
7
- branches: [ master, main ]
8
- tags: [ v* ]
9
- pull_request:
10
-
11
- jobs:
12
- rake:
13
- uses: metanorma/ci/.github/workflows/generic-rake.yml@main
14
- secrets:
15
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
@@ -1,27 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: release
4
-
5
- on:
6
- workflow_dispatch:
7
- inputs:
8
- next_version:
9
- description: |
10
- Next release version. Possible values: x.y.z, major, minor, patch or pre|rc|etc
11
- required: true
12
- default: 'skip'
13
- push:
14
- tags: [ v* ]
15
-
16
- jobs:
17
- release:
18
- uses: metanorma/ci/.github/workflows/rubygems-release.yml@main
19
- with:
20
- next_version: ${{ github.event.inputs.next_version }}
21
- release_command: rake release
22
- bundler_cache: false
23
- post_install: gem install bundler rake rspec
24
- secrets:
25
- rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
26
- pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
27
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task default: :spec
data/bin/rspec DELETED
@@ -1,17 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This file was generated by Bundler.
4
- #
5
- # The application 'rspec' is installed as part of a gem, and
6
- # this file is here to facilitate running it.
7
- #
8
-
9
- require "pathname"
10
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
- "../../Gemfile", Pathname.new(__FILE__).realpath
12
- )
13
-
14
- require "rubygems"
15
- require "bundler/setup"
16
-
17
- load Gem.bin_path("rspec-core", "rspec")
@@ -1,124 +0,0 @@
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
- #Layer_1 { fill:none }
7
- svg[id = 'Layer_1'] { fill:none }
8
- .st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
9
- </style>
10
- <image style="overflow:visible;" width="368" height="315" xlink:href="data:image/gif;base64,R0lGODlhcAE7Aff/AAAAAAAAMwAAZgAAmQAAzAAA/wAzAAAzMwAzZgAzmQAzzAAz/wBmAABmMwBm
11
- ZgBmmQBmzABm/wCZAACZMwCZZgCZmQCZzACZ/wDMAADMMwDMZgDMmQDMzADM/wD/AAD/MwD/ZgD/
12
- mQD/zAD//zMAADMAMzMAZjMAmTMAzDMA/zMzADMzMzMzZjMzmTMzzDMz/zNmADNmMzNmZjNmmTNm
13
- zDNm/zOZADOZMzOZZjOZmTOZz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tA
107
- BCWzsymyIU4u//3Y68JLAkSSL0aPRJUIXAZk0ToiZpYkx3PiL745GUnHQRuzVvW0PhuXpC0QIz65
108
- CzOOg9xzarWFY7JnNqd7hNzlgCy23+0+Z/WoLjlCZhWpcPJXTytXOZ4TcOvbN/odpFZp/osMRZ9m
109
- RUrpqhtEt2sUaXBsWgGgArLVqqcKJEhpuIWTuK61uJlCTXxr5T8x4qAr3TZISVxdlkORuRv8EFrz
110
- 6QkjFJ8Lu6NbuqohbDliaaSuuizhyjPWE/Nru/QSu7Nbu7QtFJpdELqbL7zru70unzxRD8lrvN5r
111
- vsuOvuXr7OfLveML7c0u7c9u7dEevt+77cwuvteu7d2uvuzb2ORe7u97ZvV7v8UevBLGv/4LwHi+
112
- ZARswAgc77C27vqba/guwMe27x997/Z+av6O3QC/5co28BQs8AFfaAgv0gWf3Apv8P2+8GfW8CJ8
113
- 8BS/ZBYP2fqe8TK28Xmdaydj7iRfFvIpo8qEnfIqv/Is3/Iu//IwH/OhERAAOw==" transform="matrix(1 0 0 1 114 263.8898)">
114
- </image>
115
- <a xlink:href="mn://action_schema" xlink:dummy="Layer_1">
116
- <rect x="123.28" y="273.93" class="st0" width="88.05" height="41.84"/>
117
- </a>
118
- <a xlink:href="mn://basic_attribute_schema" >
119
- <rect x="324.69" y="450.52" class="st0" width="132.62" height="40.75"/>
120
- </a>
121
- <a xlink:href="mn://support_resource_schema" >
122
- <rect x="324.69" y="528.36" class="st0" width="148.16" height="40.75"/>
123
- </a>
124
- </svg>
Binary file
@@ -1,64 +0,0 @@
1
- require "spec_helper"
2
- require "utils/hash_transform_keys"
3
-
4
- RSpec.describe Metanorma::Utils do
5
- it "deep stringify hash but skip values" do
6
- Hash.include Metanorma::Utils::Hash
7
- Array.include Metanorma::Utils::Array
8
- result = {
9
- test0: :test0,
10
- test1: false,
11
- test2: {
12
- test20: :test20,
13
- },
14
- test3: %i(test31 test32 test33),
15
- test4: [
16
- {
17
- test41: :test41,
18
- },
19
- ],
20
- }.stringify_all_keys
21
-
22
- expect(result).to include("test0", "test1", "test2", "test3", "test4")
23
- expect(result["test0"]).to eq(:test0)
24
- expect(result["test2"]).to include("test20")
25
- expect(result["test2"]["test20"]).to eq(:test20)
26
- expect(result["test3"]).to include(:test31, :test32, :test33)
27
- expect(result["test4"][0]).to include("test41")
28
- expect(result["test4"][0]["test41"]).to eq(:test41)
29
- end
30
-
31
- it "deep symbolize hash but skip values" do
32
- Hash.include Metanorma::Utils::Hash
33
- Array.include Metanorma::Utils::Array
34
- result = {
35
- test0: "test0",
36
- test1: false,
37
- test2: {
38
- test20: "test20",
39
- },
40
- test3: %w(test31 test32 test33),
41
- test4: [
42
- {
43
- test41: "test41",
44
- },
45
- ],
46
- }.stringify_all_keys.symbolize_all_keys
47
-
48
- expect(result).to include(:test0, :test1, :test2, :test3, :test4)
49
- expect(result[:test0]).to eq("test0")
50
- expect(result[:test2]).to include(:test20)
51
- expect(result[:test2][:test20]).to eq("test20")
52
- expect(result[:test3]).to include("test31", "test32", "test33")
53
- expect(result[:test4][0]).to include(:test41)
54
- expect(result[:test4][0][:test41]).to eq("test41")
55
- end
56
-
57
- it "deep merges hashes" do
58
- Hash.include Metanorma::Utils::Hash
59
- hash1 = { a: [1, 2], b: "c", c: 4, e: { f: { g: "1" } } }
60
- hash2 = { a: [3], b: "d", d: 5, e: { f: { h: "2" } } }
61
- expect(hash1.deep_merge(hash2)).to eq({ a: [1, 2, 3], b: "d", c: 4,
62
- d: 5, e: { f: { g: "1", h: "2" } } })
63
- end
64
- end
data/spec/img_spec.rb DELETED
@@ -1,349 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Metanorma::Utils do
5
- context "recognises data uris" do
6
- it "where the content is an existing file at a relative path" do
7
- expect(Metanorma::Utils.datauri("spec/fixtures/rice_image1.png"))
8
- .to eq Metanorma::Utils.encode_datauri("spec/fixtures/rice_image1.png")
9
- end
10
-
11
- it "where the content is an existing file at an absolute path" do
12
- expect(Metanorma::Utils.datauri(File.expand_path("spec/fixtures/rice_image1.png")))
13
- .to eq Metanorma::Utils.encode_datauri("spec/fixtures/rice_image1.png")
14
- end
15
-
16
- it "where the content is a relative file path pointing to a bogus file" do
17
- expect(Metanorma::Utils.datauri("spec/fixtures/bogus.png"))
18
- .to eq "spec/fixtures/bogus.png"
19
- end
20
-
21
- it "where the content is an absolute file path pointing to a bogus file" do
22
- expect(Metanorma::Utils.datauri("D:/spec/fixtures/bogus.png"))
23
- .to eq "D:/spec/fixtures/bogus.png"
24
- end
25
-
26
- it "where the content is a data/image URI" do
27
- expect(Metanorma::Utils.datauri("data1:img/gif,base64,ABBC"))
28
- .to eq "data1:img/gif,base64,ABBC"
29
- end
30
-
31
- it "where the content is an URL" do
32
- expect(Metanorma::Utils.datauri("https://example.com/image.png"))
33
- .to eq "https://example.com/image.png"
34
- end
35
- end
36
-
37
- it "recognises data uris" do
38
- expect(Metanorma::Utils.datauri?("data:img/gif,base64,ABBC"))
39
- .to eq true
40
- expect(Metanorma::Utils.datauri?("data1:img/gif,base64,ABBC"))
41
- .to eq false
42
- end
43
-
44
- it "recognises uris" do
45
- expect(Metanorma::Utils.url?("mailto://ABC"))
46
- .to eq true
47
- expect(Metanorma::Utils.url?("http://ABC"))
48
- .to eq true
49
- expect(Metanorma::Utils.url?("D:/ABC"))
50
- .to eq false
51
- expect(Metanorma::Utils.url?("/ABC"))
52
- .to eq false
53
- end
54
-
55
- it "recognises absolute file locations" do
56
- expect(Metanorma::Utils.absolute_path?("D:/a.html"))
57
- .to eq true
58
- expect(Metanorma::Utils.absolute_path?("/a.html"))
59
- .to eq true
60
- expect(Metanorma::Utils.absolute_path?("a.html"))
61
- .to eq false
62
- end
63
-
64
- it "rewrites SVGs" do
65
- FileUtils.cp("spec/fixtures/action_schemaexpg1.svg",
66
- "action_schemaexpg1.svg")
67
- FileUtils.cp("spec/fixtures/action_schemaexpg1.svg",
68
- "action_schemaexpg2.svg")
69
- xmldoc = Nokogiri::XML(<<~INPUT)
70
- <standard-document type="semantic" version="1.8.2">
71
- <bibdata type="standard">
72
- <title language="en" format="text/plain">Document title</title>
73
- <docidentifier/>
74
- <docnumber/>
75
- <version/>
76
- <language>en</language>
77
- <script>Latn</script>
78
- <status>
79
- <stage>published</stage>
80
- </status>
81
- <copyright>
82
- <from>2021</from>
83
- </copyright>
84
- <ext>
85
- <doctype>article</doctype>
86
- </ext>
87
- </bibdata>
88
- <sections>
89
- <svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
90
- <svgmap id="_4072bdcb-5895-4821-b636-5795b96787cb">
91
- <figure><image src="action_schemaexpg1.svg"/></figure>
92
- <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>
93
- </svgmap>
94
- <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd">
95
- <figure><image src="action_schemaexpg2.svg" alt="Workmap"/></figure>
96
- <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>
97
- <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd">
98
- <figure>
99
- <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'>
100
- <a href="mn://action_schema" >
101
- <rect x="123.28" y="273.93" class="st0" width="88.05" height="41.84"/>
102
- </a>
103
- <a href="mn://basic_attribute_schema" >
104
- <rect x="324.69" y="450.52" class="st0" width="132.62" height="40.75"/>
105
- </a>
106
- <a xlink:href="mn://support_resource_schema" >
107
- <rect x="324.69" y="528.36" class="st0" width="148.16" height="40.75"/>
108
- </a>
109
- </svg>
110
- </figure>
111
- <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>
112
- </svgmap>
113
- <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd">
114
- <figure>
115
-
116
- <image src='data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDI1LjAuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1OTUuMjggODQxLjg5IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OTUuMjggODQxLjg5OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+Cgkuc3Qwe2ZpbGw6bm9uZTtzdHJva2U6IzAwMDAwMDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9Cjwvc3R5bGU+CjxpbWFnZSBzdHlsZT0ib3ZlcmZsb3c6dmlzaWJsZTsiIHdpZHRoPSIzNjgiIGhlaWdodD0iMzE1IiB4bGluazpocmVmPSJkYXRhOmltYWdlL2dpZjtiYXNlNjQsUjBsR09EbGhjQUU3QWZmL0FBQUFBQUFBTXdBQVpnQUFtUUFBekFBQS93QXpBQUF6TXdBelpnQXptUUF6ekFBei93Qm1BQUJtTXdCbQpaZ0JtbVFCbXpBQm0vd0NaQUFDWk13Q1paZ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JtbjovL2FjdGlvbl9zY2hlbWEiID4KCTxyZWN0IHg9IjEyMy4yOCIgeT0iMjczLjkzIiBjbGFzcz0ic3QwIiB3aWR0aD0iODguMDUiIGhlaWdodD0iNDEuODQiLz4KPC9hPgo8YSB4bGluazpocmVmPSJtbjovL2Jhc2ljX2F0dHJpYnV0ZV9zY2hlbWEiID4KCTxyZWN0IHg9IjMyNC42OSIgeT0iNDUwLjUyIiBjbGFzcz0ic3QwIiB3aWR0aD0iMTMyLjYyIiBoZWlnaHQ9IjQwLjc1Ii8+CjwvYT4KPGEgeGxpbms6aHJlZj0ibW46Ly9zdXBwb3J0X3Jlc291cmNlX3NjaGVtYSIgPgoJPHJlY3QgeD0iMzI0LjY5IiB5PSI1MjguMzYiIGNsYXNzPSJzdDAiIHdpZHRoPSIxNDguMTYiIGhlaWdodD0iNDAuNzUiLz4KPC9hPgo8L3N2Zz4K' id='__ISO_17301-1_2016' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap1'/>
117
- </figure>
118
- <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>
119
- </sections>
120
- </standard-document>
121
- INPUT
122
- Metanorma::Utils.svgmap_rewrite(xmldoc)
123
- expect(xmlpp(xmldoc.to_xml.gsub(%r{<image.*?</image>}m, "<image/>")
124
- .gsub(%r{<style.*?</style>}m, "<style/>")))
125
- .to be_equivalent_to xmlpp(<<~OUTPUT)
126
- <?xml version='1.0'?>
127
- <standard-document type='semantic' version='1.8.2'>
128
- <bibdata type='standard'>
129
- <title language='en' format='text/plain'>Document title</title>
130
- <docidentifier/>
131
- <docnumber/>
132
- <version/>
133
- <language>en</language>
134
- <script>Latn</script>
135
- <status>
136
- <stage>published</stage>
137
- </status>
138
- <copyright>
139
- <from>2021</from>
140
- </copyright>
141
- <ext>
142
- <doctype>article</doctype>
143
- </ext>
144
- </bibdata>
145
- <sections>
146
- <svgmap id='_d5b5049a-dd53-4ea0-bc6f-e8773bd59052'>
147
- <target href='mn://action_schema'>
148
- <xref target='ref1'>Computer</xref>
149
- </target>
150
- </svgmap>
151
- <figure>
152
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000001' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
153
- <style/>
154
- <image/>
155
- <a xlink:href='#ref1' xlink:dummy='Layer_1_000000001'>
156
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
157
- </a>
158
- <a xlink:href='mn://basic_attribute_schema'>
159
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
160
- </a>
161
- <a xlink:href='mn://support_resource_schema'>
162
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
163
- </a>
164
- </svg>
165
- </figure>
166
- <svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
167
- <figure>
168
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000002' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
169
- <style/>
170
- <image/>
171
- <a xlink:href='mn://action_schema' xlink:dummy='Layer_1_000000002'>
172
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
173
- </a>
174
- <a xlink:href='http://www.example.com'>
175
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
176
- </a>
177
- <a xlink:href='mn://support_resource_schema'>
178
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
179
- </a>
180
- </svg>
181
- </figure>
182
- <target href='mn://support_resource_schema'>
183
- <eref type='express' bibitemid='express_action_schema' citeas=''>
184
- <localityStack>
185
- <locality type='anchor'>
186
- <referenceFrom>action_schema.basic</referenceFrom>
187
- </locality>
188
- </localityStack>
189
- Coffee
190
- </eref>
191
- </target>
192
- </svgmap>
193
- <figure>
194
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000003' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
195
- <a href='#ref1'>
196
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
197
- </a>
198
- <a href='mn://basic_attribute_schema'>
199
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
200
- </a>
201
- <a xlink:href='mn://support_resource_schema'>
202
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
203
- </a>
204
- </svg>
205
- </figure>
206
- <svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
207
- <figure>
208
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000004' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
209
- <style/>
210
- <image/>
211
- <a xlink:href='mn://action_schema'>
212
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
213
- </a>
214
- <a xlink:href='http://www.example.com'>
215
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
216
- </a>
217
- <a xlink:href='mn://support_resource_schema'>
218
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
219
- </a>
220
- </svg>
221
- </figure>
222
- <target href='mn://support_resource_schema'>
223
- <eref type='express' bibitemid='express_action_schema' citeas=''>
224
- <localityStack>
225
- <locality type='anchor'>
226
- <referenceFrom>action_schema.basic</referenceFrom>
227
- </locality>
228
- </localityStack>
229
- Coffee
230
- </eref>
231
- </target>
232
- </svgmap>
233
- </sections>
234
- </standard-document>
235
- OUTPUT
236
- end
237
-
238
- it "rewrites SVGs with namespaces" do
239
- FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
240
- "action_schemaexpg1.svg"
241
- FileUtils.cp "spec/fixtures/action_schemaexpg1.svg",
242
- "action_schemaexpg2.svg"
243
- xmldoc = Nokogiri::XML(<<~INPUT)
244
- <standard-document type="semantic" version="1.8.2" xmlns="http://www.example.com">
245
- <bibdata type="standard">
246
- <title language="en" format="text/plain">Document title</title>
247
- <docidentifier/>
248
- <docnumber/>
249
- <version/>
250
- <language>en</language>
251
- <script>Latn</script>
252
- <status>
253
- <stage>published</stage>
254
- </status>
255
- <copyright>
256
- <from>2021</from>
257
- </copyright>
258
- <ext>
259
- <doctype>article</doctype>
260
- </ext>
261
- </bibdata>
262
- <sections>
263
- <svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
264
- <svgmap id="_4072bdcb-5895-4821-b636-5795b96787cb">
265
- <figure><image src="action_schemaexpg1.svg"/></figure>
266
- <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>
267
- </svgmap>
268
- <svgmap id="_60dadf08-48d4-4164-845c-b4e293e00abd">
269
- <figure><image src="action_schemaexpg2.svg" alt="Workmap"/></figure>
270
- <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>
271
- </standard-document>
272
- INPUT
273
- Metanorma::Utils.svgmap_rewrite(xmldoc)
274
- expect(xmlpp(xmldoc.to_xml.gsub(%r{<image.*?</image>}m, "<image/>")))
275
- .to be_equivalent_to xmlpp(<<~OUTPUT)
276
- <?xml version='1.0'?>
277
- <standard-document type="semantic" version="1.8.2" xmlns="http://www.example.com">
278
- <bibdata type="standard">
279
- <title language="en" format="text/plain">Document title</title>
280
- <docidentifier/>
281
- <docnumber/>
282
- <version/>
283
- <language>en</language>
284
- <script>Latn</script>
285
- <status>
286
- <stage>published</stage>
287
- </status>
288
- <copyright>
289
- <from>2021</from>
290
- </copyright>
291
- <ext>
292
- <doctype>article</doctype>
293
- </ext>
294
- </bibdata>
295
- <sections><svgmap id="_d5b5049a-dd53-4ea0-bc6f-e8773bd59052"><target href="mn://action_schema"><xref target="ref1">Computer</xref></target></svgmap>
296
- <figure>
297
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000001' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
298
- <style type='text/css'>
299
- #Layer_1_000000001 { fill:none } svg[id='Layer_1_000000001'] {
300
- fill:none } .st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
301
- </style>
302
- <image/>
303
- <a xlink:href='#ref1' xlink:dummy='Layer_1_000000001'>
304
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
305
- </a>
306
- <a xlink:href='mn://basic_attribute_schema'>
307
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
308
- </a>
309
- <a xlink:href='mn://support_resource_schema'>
310
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
311
- </a>
312
- </svg>
313
- </figure>
314
- <svgmap id='_60dadf08-48d4-4164-845c-b4e293e00abd'>
315
- <figure>
316
- <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1_000000002' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
317
- <style type='text/css'>
318
- #Layer_1_000000002 { fill:none } svg[id='Layer_1_000000002'] {
319
- fill:none } .st0{fill:none;stroke:#000000;stroke-miterlimit:10;}
320
- </style>
321
- <image/>
322
- <a xlink:href='mn://action_schema' xlink:dummy='Layer_1_000000002'>
323
- <rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
324
- </a>
325
- <a xlink:href='http://www.example.com'>
326
- <rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
327
- </a>
328
- <a xlink:href='mn://support_resource_schema'>
329
- <rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
330
- </a>
331
- </svg>
332
- </figure>
333
- <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>
334
- </standard-document>
335
- OUTPUT
336
- end
337
-
338
- it "generates data uris" do
339
- expect(Metanorma::Utils.datauri("data:xyz")).to eq "data:xyz"
340
- expect(Metanorma::Utils.datauri("spec/fixtures/rice_image1.png")).to be_equivalent_to "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQCAYAAACAvzbMAAAABmJLR0QA/wD/AP+gvaeTAAAEzUlEQVR4nO3dz4tVZRzH8fedacogMCjHoiBop1RaOzF/QAv7QUIYZdCq/oQo+hdC10FRbVtVBC0r09y0iZAmoVwWRRaMBZlKnhZ3UlEwnVFnhvt6wQPnnnOeh8/m8r0P9zznKQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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su3+HgfO06cu49WPuqN29ATgBWoOnGhWCYqmHvbMNnmxpObT//OvdT2xs+3TS+dsHeIG/kBxgA1ZNdsKFUF2wo1aUbSj2+bCkBWJGmGheHtxoXij8W2tzCuV353xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAS/wLBh+fQNux/v8AAAAASUVORK5CYII=")&.first&.to_s).to eq "image/png"
344
- expect(Metanorma::Utils.datauri("spec/fixtures/rice_image0.png")).to be_equivalent_to "spec/fixtures/rice_image0.png"
345
- expect do
346
- Metanorma::Utils.datauri("spec/fixtures/rice_image0.png")
347
- end.to output(%r{Image specified at `spec/fixtures/rice_image0\.png` does not exist\.}).to_stderr
348
- end
349
- end
data/spec/spec_helper.rb DELETED
@@ -1,42 +0,0 @@
1
- require "simplecov"
2
- SimpleCov.start do
3
- add_filter "/spec/"
4
- end
5
- require "rspec/matchers"
6
- require "equivalent-xml"
7
- require "metanorma-utils"
8
- require "rexml/document"
9
-
10
- RSpec.configure do |config|
11
- # Enable flags like --only-failures and --next-failure
12
- config.example_status_persistence_file_path = ".rspec_status"
13
-
14
- # Disable RSpec exposing methods globally on `Module` and `main`
15
- config.disable_monkey_patching!
16
-
17
- config.expect_with :rspec do |c|
18
- c.syntax = :expect
19
- end
20
- end
21
-
22
- class Dummy
23
- attr_accessor :id, :docfile
24
-
25
- def initialize(id = nil)
26
- @id = id
27
- end
28
-
29
- def attr(elem)
30
- case elem
31
- when "docfile" then @docfile
32
- end
33
- end
34
- end
35
-
36
- def xmlpp(xml)
37
- s = ""
38
- f = REXML::Formatters::Pretty.new(2)
39
- f.compact = true
40
- f.write(REXML::Document.new(xml), s)
41
- s
42
- end
data/spec/utils_spec.rb DELETED
@@ -1,231 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Metanorma::Utils do
5
- it "has a version number" do
6
- expect(Metanorma::Utils::VERSION).not_to be nil
7
- end
8
-
9
- it "capitalises" do
10
- expect(Metanorma::Utils.strict_capitalize_phrase("ABC def gHI"))
11
- .to eq "ABC Def GHI"
12
- expect(Metanorma::Utils.strict_capitalize_first("aBC def gHI"))
13
- .to eq "ABC def gHI"
14
- end
15
-
16
- it "converts OS-specific external path" do
17
- pwd = if !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) ||
18
- (RUBY_PLATFORM =~ /mswin|mingw/))
19
- `echo %cd%`
20
- else `pwd`
21
- end
22
- expect(Metanorma::Utils.external_path(FileUtils.pwd.strip)).to eq pwd.strip
23
- end
24
-
25
- it "applies Asciidoctor substitutions" do
26
- expect(Metanorma::Utils.asciidoc_sub("A -- B", "html"))
27
- .to eq "A&#8201;&#8212;&#8201;B"
28
- expect(Metanorma::Utils.asciidoc_sub("*A* stem:[x]", "html"))
29
- .to eq "<strong>A</strong> \\$x\\$"
30
- end
31
-
32
- it "finds file path of docfile" do
33
- d = Dummy.new
34
- expect(Metanorma::Utils.localdir(d)).to eq "./"
35
- d.docfile = "spec/utils_spec.rb"
36
- expect(Metanorma::Utils.localdir(d)).to eq "spec/"
37
- end
38
-
39
- it "applies smart formatting" do
40
- expect(Metanorma::Utils.smartformat("A - B A -- B A--B '80s '80' <A>"))
41
- .to eq "A — B A — B A—B ’80s ‘80’ &lt;A&gt;"
42
- end
43
-
44
- it "applies en-dash normalisation" do
45
- a = Nokogiri::XML(<<~INPUT)
46
- <container>
47
- <a>A -- B A - B</a>
48
- <b>A--B</b>
49
- </container>
50
- INPUT
51
- Metanorma::Utils.endash_date(a)
52
- expect(a.to_xml).to be_equivalent_to <<~OUTPUT
53
- <?xml version=\"1.0\"?>
54
- <container><a>A&#x2013;B A&#x2013;B</a><b>A&#x2013;B</b></container>
55
- OUTPUT
56
- end
57
-
58
- it "sets hash values by dotted key path" do
59
- a = {}
60
- a = Metanorma::Utils.set_nested_value(a, ["X"], "x")
61
- a = Metanorma::Utils.set_nested_value(a, ["X1"], 9)
62
- a = Metanorma::Utils.set_nested_value(a, ["X2"], [3])
63
- a = Metanorma::Utils.set_nested_value(a, ["X3"], { "a" => "b" })
64
- expect(a.to_s).to be_equivalent_to <<~OUTPUT
65
- {"X"=>"x", "X1"=>9, "X2"=>[3], "X3"=>{"a"=>"b"}}
66
- OUTPUT
67
- a = Metanorma::Utils.set_nested_value(a, ["X2"], 4)
68
- a = Metanorma::Utils.set_nested_value(a, ["X1"], 4)
69
- expect(a.to_s).to be_equivalent_to <<~OUTPUT
70
- {"X"=>"x", "X1"=>[9, 4], "X2"=>[3, 4], "X3"=>{"a"=>"b"}}
71
- OUTPUT
72
- a = Metanorma::Utils.set_nested_value(a, ["X2", "A"], 5)
73
- a = Metanorma::Utils.set_nested_value(a, ["X2a"], [])
74
- a = Metanorma::Utils.set_nested_value(a, ["X2a", "A"], 6)
75
- a = Metanorma::Utils.set_nested_value(a, ["X4", "A"], 10)
76
- a = Metanorma::Utils.set_nested_value(a, ["X3", "A"], 7)
77
- a = Metanorma::Utils.set_nested_value(a, ["X3", "a"], 8)
78
- a = Metanorma::Utils.set_nested_value(a, ["X1", "a"], 11)
79
- expect(a.to_s).to be_equivalent_to <<~OUTPUT
80
- {"X"=>"x", "X1"=>[9, 4, {"a"=>11}], "X2"=>[3, 4, {"A"=>5}], "X3"=>{"a"=>["b", 8], "A"=>7}, "X2a"=>[{"A"=>6}], "X4"=>{"A"=>10}}
81
- OUTPUT
82
- end
83
-
84
- it "maps languages to scripts" do
85
- expect(Metanorma::Utils.default_script("hi")).to eq "Deva"
86
- expect(Metanorma::Utils.rtl_script?(Metanorma::Utils.default_script("el")))
87
- .to eq false
88
- expect(Metanorma::Utils.rtl_script?(Metanorma::Utils.default_script("fa")))
89
- .to eq true
90
- end
91
-
92
- # not testing Asciidoctor log extraction here
93
- it "generates log" do
94
- xml = Nokogiri::XML(<<~INPUT)
95
- <xml>
96
- <a>
97
- <b>
98
- c
99
- </b></a></xml>
100
- INPUT
101
- FileUtils.rm_f("log.txt")
102
- log = Metanorma::Utils::Log.new
103
- log.add("Category 1", nil, "Message 1")
104
- log.add("Category 1", "node", "Message 2")
105
- log.add("Category 2", xml.at("//xml/a/b"), "Message 3")
106
- log.write("log.txt")
107
- expect(File.exist?("log.txt")).to be true
108
- file = File.read("log.txt", encoding: "utf-8")
109
- expect(file).to eq <<~OUTPUT
110
- log.txt errors
111
-
112
-
113
- == Category 1
114
-
115
- (): Message 1
116
- (node): Message 2
117
-
118
-
119
- == Category 2
120
-
121
- (XML Line 000003): Message 3
122
- <b>
123
- c
124
- </b>
125
- OUTPUT
126
- end
127
-
128
- it "deals with illegal characters in log" do
129
- FileUtils.rm_f("log.txt")
130
- log = Metanorma::Utils::Log.new
131
- log.add("Category 1", nil, "é\xc2")
132
- log.write("log.txt")
133
- expect(File.exist?("log.txt")).to be true
134
- file = File.read("log.txt", encoding: "utf-8")
135
- expect(file).to eq <<~OUTPUT
136
- log.txt errors
137
-
138
-
139
- == Category 1
140
-
141
- (): é�
142
- OUTPUT
143
- end
144
-
145
- it "parses CSV" do
146
- expect(Metanorma::Utils.csv_split("A;'B;C'")).to eq ["A", "'B", "C'"]
147
- expect(Metanorma::Utils.csv_split('A;"B;C"')).to eq ["A", "B;C"]
148
- expect(Metanorma::Utils.csv_split('A; "B;C"')).to eq ["A", "B;C"]
149
- expect(Metanorma::Utils.csv_split('A; "B;C"', ",")).to eq ['A; "B;C"']
150
- expect(Metanorma::Utils.csv_split('A, "B,C"', ",")).to eq ["A", "B,C"]
151
- end
152
-
153
- it "parses attributes from definition list" do
154
- xml = Nokogiri::XML(<<~INPUT)
155
- <xml>
156
- <dummy/>
157
- <dl>
158
- <dt>attr1</dt><dd>value1</dd>
159
- <dt>attr2</dt><dd><p>value1</p><p>value cont</p></dd>
160
- </xml>
161
- INPUT
162
- Metanorma::Utils.dl_to_attrs(xml.at("//dummy"), xml.at("//dl"), "attr1")
163
- Metanorma::Utils.dl_to_attrs(xml.at("//dummy"), xml.at("//dl"), "attr2")
164
- expect(xml.to_xml).to be_equivalent_to <<~OUTPUT
165
- <xml>
166
- <dummy attr1="value1" attr2="value1"/>
167
- <dl>
168
- <dt>attr1</dt><dd>value1</dd>
169
- <dt>attr2</dt><dd><p>value1</p><p>value cont</p></dd>
170
- </dl>
171
- </xml>
172
- OUTPUT
173
- end
174
-
175
- it "parses attributes from definition list" do
176
- xml = Nokogiri::XML(<<~INPUT)
177
- <xml>
178
- <dummy/>
179
- <dl>
180
- <dt>attr1</dt><dd>value1</dd>
181
- <dt>attr2</dt><dd><p>value1</p><p>value cont</p></dd>
182
- </xml>
183
- INPUT
184
- Metanorma::Utils.dl_to_attrs(xml.at("//dummy"), xml.at("//dl"), "attr1")
185
- Metanorma::Utils.dl_to_attrs(xml.at("//dummy"), xml.at("//dl"), "attr2")
186
- expect(xml.to_xml).to be_equivalent_to <<~OUTPUT
187
- <xml>
188
- <dummy attr1="value1" attr2="value1"/>
189
- <dl>
190
- <dt>attr1</dt><dd>value1</dd>
191
- <dt>attr2</dt><dd><p>value1</p><p>value cont</p></dd>
192
- </dl>
193
- </xml>
194
- OUTPUT
195
- end
196
-
197
- it "parses elements from definition list" do
198
- xml = Nokogiri::XML(<<~INPUT)
199
- <xml>
200
- <dummy>
201
- <attr2>A</attr2>
202
- <attr3>A</attr3>
203
- <attr2>A</attr2>
204
- </dummy>
205
- <dl>
206
- <dt>attr1</dt><dd>value1</dd>
207
- <dt>attr2</dt><dd><p>value1</p><p>value cont</p></dd>
208
- </dl>
209
- <dummy1/>
210
- </xml>
211
- INPUT
212
- Metanorma::Utils.dl_to_elems(xml.at("//dummy1"), xml.at("//dummy"),
213
- xml.at("//dl"), "attr1")
214
- Metanorma::Utils.dl_to_elems(xml.at("//dummy1"), xml.at("//dummy"),
215
- xml.at("//dl"), "attr2")
216
- expect(xml.to_xml).to be_equivalent_to <<~OUTPUT
217
- <xml>
218
- <dummy>
219
- <attr2>A</attr2>
220
- <attr3>A</attr3>
221
- <attr2>A</attr2><attr2><p>value1</p><p>value cont</p></attr2>
222
- </dummy>
223
- <dl>
224
- <dt>attr1</dt>
225
- <dt>attr2</dt>
226
- </dl>
227
- <dummy1/><attr1>value1</attr1>
228
- </xml>
229
- OUTPUT
230
- end
231
- end
data/spec/xml_spec.rb DELETED
@@ -1,88 +0,0 @@
1
- require "spec_helper"
2
- require "fileutils"
3
-
4
- RSpec.describe Metanorma::Utils do
5
- it "normalises anchors" do
6
- expect(Metanorma::Utils.to_ncname("/:ab")).to eq "__ab"
7
- expect(Metanorma::Utils.to_ncname("Löwe")).to eq "L__xf6_we"
8
- expect(Metanorma::Utils.to_ncname("Löwe", asciionly: false)).to eq "Löwe"
9
- expect(Metanorma::Utils.to_ncname("Löwe",
10
- asciionly: true)).to eq "L__xf6_we"
11
- end
12
-
13
- it "sets metanorma IDs if not provided" do
14
- uuid = /^_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
15
- expect(Metanorma::Utils.anchor_or_uuid)
16
- .to match (uuid)
17
- expect(Metanorma::Utils.anchor_or_uuid(Dummy.new(nil)))
18
- .to match (uuid)
19
- expect(Metanorma::Utils.anchor_or_uuid(Dummy.new("")))
20
- .to match (uuid)
21
- expect(Metanorma::Utils.anchor_or_uuid(Dummy.new("A"))).to eq "A"
22
- end
23
-
24
- it "generates XML snippets from Asciidoctor" do
25
- input = <<~'EOS'
26
- <A> &#150;
27
- EOS
28
-
29
- doc = (Asciidoctor::Document.new input.lines,
30
- { standalone: false }).parse
31
- out = Metanorma::Utils.noko do |xml|
32
- xml << doc.blocks.first.content
33
- end.join
34
- expect(out).to be_equivalent_to <<~OUTPUT
35
- &lt;A&gt; –
36
- OUTPUT
37
- out = Metanorma::Utils.noko_html do |xml|
38
- xml << doc.blocks.first.content
39
- end.join
40
- expect(out).to be_equivalent_to <<~OUTPUT
41
- &lt;A&gt; –
42
- OUTPUT
43
- end
44
-
45
- it "wraps an Asciidoctor node in paragraph" do
46
- input = <<~'EOS'
47
- NOTE: XYZ
48
- EOS
49
- input2 = <<~'EOS'
50
- ====
51
- A
52
-
53
- B
54
- ====
55
- EOS
56
-
57
- doc = (Asciidoctor::Document.new input.lines,
58
- { standalone: false }).parse
59
- doc2 = (Asciidoctor::Document.new input2.lines,
60
- { standalone: false }).parse
61
-
62
- out = Metanorma::Utils.noko do |xml|
63
- Metanorma::Utils.wrap_in_para(doc.blocks.first, xml)
64
- end.join
65
- expect(out).to be_equivalent_to <<~OUTPUT
66
- <p>XYZ</p>
67
- OUTPUT
68
- out = Metanorma::Utils.noko do |xml|
69
- Metanorma::Utils.wrap_in_para(doc2.blocks.first, xml)
70
- end.join
71
- expect(out).to be_equivalent_to <<~OUTPUT
72
- <div class="paragraph"><p>A</p></div><div class="paragraph"><p>B</p></div>
73
- OUTPUT
74
- end
75
-
76
- it "applies namespace to xpath" do
77
- expect(Metanorma::Utils.ns("//ab/Bb/c1-d[ancestor::c][d = 'x'][e/f]"))
78
- .to be_equivalent_to("//xmlns:ab/xmlns:Bb/xmlns:c1-d[ancestor::xmlns:c]" \
79
- "[xmlns:d = 'x'][xmlns:e/xmlns:f]")
80
- end
81
-
82
- it "converts HTML escapes to hex" do
83
- expect(Metanorma::Utils.numeric_escapes("A&eacute;B"))
84
- .to be_equivalent_to "A&#xe9;B"
85
- expect(Metanorma::Utils.numeric_escapes("A<X>&eacute;</X>B"))
86
- .to be_equivalent_to "A<X>&#xe9;</X>B"
87
- end
88
- end