metanorma-iec 1.2.11 → 1.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +9 -29
- data/.rubocop.yml +0 -4
- data/lib/asciidoctor/iec/basicdoc.rng +5 -3
- data/lib/asciidoctor/iec/converter.rb +20 -0
- data/lib/asciidoctor/iec/front.rb +22 -58
- data/lib/asciidoctor/iec/iec.rng +37 -0
- data/lib/asciidoctor/iec/iec_intro_en.xml +37 -12
- data/lib/asciidoctor/iec/iec_intro_fr.xml +38 -6
- data/lib/asciidoctor/iec/isodoc.rng +134 -5
- data/lib/asciidoctor/iec/isostandard.rng +33 -107
- data/lib/isodoc/iec/base_convert.rb +2 -2
- data/lib/isodoc/iec/html/html_iec_intro.html +1 -1
- data/lib/isodoc/iec/html/word_iec_intro.html +1 -1
- data/lib/isodoc/iec/html_convert.rb +2 -2
- data/lib/isodoc/iec/iec.international-standard.xsl +732 -295
- data/lib/isodoc/iec/word_convert.rb +2 -2
- data/lib/metanorma/iec/version.rb +1 -1
- data/metanorma-iec.gemspec +3 -3
- data/spec/asciidoctor-iec/base_spec.rb +429 -9
- data/spec/asciidoctor-iec/blocks_spec.rb +24 -20
- data/spec/asciidoctor-iec/cleanup_spec.rb +92 -12
- data/spec/asciidoctor-iec/iev_spec.rb +12 -6
- data/spec/asciidoctor-iec/inline_spec.rb +11 -7
- data/spec/asciidoctor-iec/lists_spec.rb +7 -3
- data/spec/asciidoctor-iec/section_spec.rb +9 -5
- data/spec/asciidoctor-iec/validate_spec.rb +22 -21
- data/spec/isodoc/iso_spec.rb +2 -2
- data/spec/metanorma/processor_spec.rb +1 -1
- data/spec/spec_helper.rb +25 -33
- metadata +8 -8
@@ -1,6 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe Asciidoctor::Iec do
|
4
|
+
before(:all) do
|
5
|
+
@blank_hdr = blank_hdr_gen
|
6
|
+
end
|
7
|
+
|
4
8
|
it "processes simple lists" do
|
5
9
|
output = Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
6
10
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -17,7 +21,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
17
21
|
|
18
22
|
INPUT
|
19
23
|
expect(xmlpp(strip_guid(output))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
20
|
-
#{
|
24
|
+
#{@blank_hdr}
|
21
25
|
<sections>
|
22
26
|
<ul id="_">
|
23
27
|
<li>
|
@@ -99,7 +103,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
99
103
|
|
100
104
|
INPUT
|
101
105
|
expect(xmlpp(strip_guid(output))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
102
|
-
#{
|
106
|
+
#{@blank_hdr}
|
103
107
|
<sections><ul id="id">
|
104
108
|
<li>
|
105
109
|
<p id="_">First</p>
|
@@ -172,7 +176,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
172
176
|
* Hello [[id3]] List item
|
173
177
|
|
174
178
|
INPUT
|
175
|
-
#{
|
179
|
+
#{@blank_hdr}
|
176
180
|
<sections>
|
177
181
|
<ul id="id1">
|
178
182
|
<li id="id2">
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
RSpec.describe Asciidoctor::Iec do
|
4
|
+
before(:all) do
|
5
|
+
@blank_hdr = blank_hdr_gen
|
6
|
+
end
|
7
|
+
|
4
8
|
it "processes sections" do
|
5
9
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
6
10
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -52,7 +56,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
52
56
|
|
53
57
|
=== Bibliography Subsection
|
54
58
|
INPUT
|
55
|
-
#{
|
59
|
+
#{@blank_hdr}
|
56
60
|
<preface><foreword id="_" obligation="informative">
|
57
61
|
<title>FOREWORD</title>
|
58
62
|
<p id="_">Text</p>
|
@@ -189,7 +193,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
189
193
|
|
190
194
|
=== Bibliography Subsection
|
191
195
|
INPUT
|
192
|
-
#{
|
196
|
+
#{@blank_hdr}
|
193
197
|
<preface>
|
194
198
|
<foreword id="_" obligation="informative">
|
195
199
|
<title>FOREWORD</title>
|
@@ -298,7 +302,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
298
302
|
[appendix,obligation=informative]
|
299
303
|
== Annex
|
300
304
|
INPUT
|
301
|
-
#{
|
305
|
+
#{@blank_hdr}
|
302
306
|
<sections><clause id="_" inline-header="false" obligation="informative">
|
303
307
|
<title>Clause 1</title>
|
304
308
|
<clause id="_" inline-header="false" obligation="informative">
|
@@ -329,7 +333,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
329
333
|
[%inline-header]
|
330
334
|
=== Clause Aa
|
331
335
|
INPUT
|
332
|
-
#{
|
336
|
+
#{@blank_hdr}
|
333
337
|
<sections><clause id="_" inline-header="false" obligation="normative">
|
334
338
|
<title>Clause 1</title>
|
335
339
|
<clause id="_" inline-header="true" obligation="normative">
|
@@ -354,7 +358,7 @@ RSpec.describe Asciidoctor::Iec do
|
|
354
358
|
=== {blank}
|
355
359
|
|
356
360
|
INPUT
|
357
|
-
#{
|
361
|
+
#{@blank_hdr}
|
358
362
|
<sections>
|
359
363
|
<clause id="_" inline-header="false" obligation="normative">
|
360
364
|
<title>Clause 1</title>
|
@@ -15,41 +15,42 @@ RSpec.describe Asciidoctor::Iec do
|
|
15
15
|
|
16
16
|
it "generates error file" do
|
17
17
|
expect do
|
18
|
+
mock_pdf
|
18
19
|
Metanorma::Compile
|
19
20
|
.new
|
20
|
-
.compile("spec/assets/xref_error.adoc", type: "iec")
|
21
|
+
.compile("spec/assets/xref_error.adoc", type: "iec", no_install_fonts: true)
|
21
22
|
end.to(change { File.exist?("spec/assets/xref_error.err") }
|
22
23
|
.from(false).to(true))
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
26
|
-
it "Warns of illegal doctype" do
|
27
|
+
it "Warns of illegal doctype" do
|
27
28
|
FileUtils.rm_f "test.err"
|
28
29
|
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
= Document title
|
31
|
+
Author
|
32
|
+
:docfile: test.adoc
|
33
|
+
:nodoc:
|
34
|
+
:no-isobib:
|
35
|
+
:doctype: pizza
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
text
|
38
|
+
INPUT
|
38
39
|
expect(File.read("test.err")).to include "pizza is not a recognised document type"
|
39
|
-
end
|
40
|
+
end
|
40
41
|
|
41
|
-
it "Warns of illegal function" do
|
42
|
+
it "Warns of illegal function" do
|
42
43
|
FileUtils.rm_f "test.err"
|
43
44
|
Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
45
|
+
= Document title
|
46
|
+
Author
|
47
|
+
:docfile: test.adoc
|
48
|
+
:nodoc:
|
49
|
+
:no-isobib:
|
50
|
+
:function: pizza
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
text
|
53
|
+
INPUT
|
53
54
|
expect(File.read("test.err")).to include "pizza is not a recognised document function"
|
54
|
-
end
|
55
|
+
end
|
55
56
|
end
|
data/spec/isodoc/iso_spec.rb
CHANGED
@@ -32,8 +32,8 @@ RSpec.describe IsoDoc::Iec do
|
|
32
32
|
INPUT
|
33
33
|
html = File.read("test.html", encoding: "utf-8")
|
34
34
|
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
35
|
-
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "
|
36
|
-
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "
|
35
|
+
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
|
36
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Source Han Sans", sans-serif;]m)
|
37
37
|
end
|
38
38
|
|
39
39
|
it "processes isodoc as ISO: user nominated fonts" do
|
@@ -27,7 +27,7 @@ RSpec.describe Metanorma::Iec::Processor do
|
|
27
27
|
expect(xmlpp(strip_guid(processor.input_to_isodoc(<<~"INPUT", nil)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
28
28
|
#{ASCIIDOC_BLANK_HDR}
|
29
29
|
INPUT
|
30
|
-
#{
|
30
|
+
#{blank_hdr_gen}
|
31
31
|
<sections/>
|
32
32
|
</iec-standard>
|
33
33
|
OUTPUT
|
data/spec/spec_helper.rb
CHANGED
@@ -112,38 +112,17 @@ TERMS_BOILERPLATE = <<~"BOILERPLATE"
|
|
112
112
|
</ul>
|
113
113
|
BOILERPLATE
|
114
114
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
BOILERPLATE_LICENSE = <<~END
|
128
|
-
<license-statement>
|
129
|
-
<clause>
|
130
|
-
<title>Warning for CDs, CDVs and FDISs</title>
|
131
|
-
<p id='_'>
|
132
|
-
This document is not an IEC International Standard. It is distributed
|
133
|
-
for review and comment. It is subject to change without notice and may
|
134
|
-
not be referred to as an International Standard.
|
135
|
-
</p>
|
136
|
-
<p id='_'>
|
137
|
-
Recipients of this draft are invited to submit, with their comments,
|
138
|
-
notification of any relevant patent rights of which they are aware and
|
139
|
-
to provide supporting documentation.
|
140
|
-
</p>
|
141
|
-
</clause>
|
142
|
-
</license-statement>
|
143
|
-
END
|
144
|
-
|
145
|
-
UNPUBLISHED_BOILERPLATE = BOILERPLATE.sub(/<\/boilerplate>/, "#{BOILERPLATE_LICENSE}</boilerplate>")
|
146
|
-
|
115
|
+
def boilerplate(xmldoc)
|
116
|
+
file = File.read(File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iec", "iec_intro_en.xml"), encoding: "utf-8")
|
117
|
+
conv = Asciidoctor::Iec::Converter.new(nil, backend: :iec, header_footer: true)
|
118
|
+
conv.init(Asciidoctor::Document.new [])
|
119
|
+
ret = Nokogiri::XML(
|
120
|
+
conv.boilerplate_isodoc(xmldoc).populate_template(file, nil).
|
121
|
+
gsub(/<p>/, "<p id='_'>").
|
122
|
+
gsub(/<ol>/, "<ol id='_'>"))
|
123
|
+
conv.smartquotes_cleanup(ret)
|
124
|
+
HTMLEntities.new.decode(ret.to_xml)
|
125
|
+
end
|
147
126
|
|
148
127
|
BLANK_HDR = <<~"HDR"
|
149
128
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -189,9 +168,16 @@ BLANK_HDR = <<~"HDR"
|
|
189
168
|
<stagename>International standard</stagename>
|
190
169
|
</ext>
|
191
170
|
</bibdata>
|
192
|
-
#{BOILERPLATE}
|
193
171
|
HDR
|
194
172
|
|
173
|
+
def blank_hdr_gen
|
174
|
+
<<~"HDR"
|
175
|
+
#{BLANK_HDR}
|
176
|
+
#{boilerplate(Nokogiri::XML(BLANK_HDR + "</iec-standard>"))}
|
177
|
+
HDR
|
178
|
+
end
|
179
|
+
|
180
|
+
|
195
181
|
IEC_TITLE = <<~END
|
196
182
|
<p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
|
197
183
|
<p class="zzSTDTitle1">____________</p>
|
@@ -275,6 +261,12 @@ def stub_fetch_ref(**opts)
|
|
275
261
|
end.at_least :once
|
276
262
|
end
|
277
263
|
|
264
|
+
def mock_pdf
|
265
|
+
allow(::Mn2pdf).to receive(:convert) do |url, output, c, d|
|
266
|
+
FileUtils.cp(url.gsub(/"/, ""), output.gsub(/"/, ""))
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
278
270
|
private
|
279
271
|
|
280
272
|
def get_xml(search, code, opts)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-jing
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.7.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.7.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
117
|
+
version: '13.0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
124
|
+
version: '13.0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,7 +193,7 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 0.2.0
|
195
195
|
description: |
|
196
|
-
metanorma-
|
196
|
+
metanorma-iec lets you write IEC standards in AsciiDoc syntax.
|
197
197
|
|
198
198
|
This gem is in active development.
|
199
199
|
email:
|
@@ -307,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
307
|
- !ruby/object:Gem::Version
|
308
308
|
version: '0'
|
309
309
|
requirements: []
|
310
|
-
rubygems_version: 3.
|
310
|
+
rubygems_version: 3.1.4
|
311
311
|
signing_key:
|
312
312
|
specification_version: 4
|
313
313
|
summary: metanorma-iec lets you write IEC standards in AsciiDoc.
|