metanorma-iec 0.0.9 → 0.0.10
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/README.adoc +4 -4
- data/lib/asciidoctor/iec/basicdoc.rng +6 -8
- data/lib/isodoc/iec/html/html_iec_titlepage.html +3 -3
- data/lib/isodoc/iec/html/htmlstyle.scss +2 -2
- data/lib/isodoc/iec/html/isodoc.scss +24 -0
- data/lib/metanorma/iec/version.rb +1 -1
- data/metanorma-iec.gemspec +0 -1
- data/spec/asciidoctor-iec/base_spec.rb +7 -7
- data/spec/asciidoctor-iec/blocks_spec.rb +22 -23
- data/spec/asciidoctor-iec/cleanup_spec.rb +19 -125
- data/spec/asciidoctor-iec/inline_spec.rb +7 -7
- data/spec/asciidoctor-iec/lists_spec.rb +3 -3
- data/spec/asciidoctor-iec/section_spec.rb +51 -41
- data/spec/asciidoctor-iec/table_spec.rb +4 -4
- data/spec/isodoc/i18n_spec.rb +4 -4
- data/spec/isodoc/inline_spec.rb +8 -8
- data/spec/isodoc/iso_spec.rb +4 -82
- data/spec/isodoc/postproc_spec.rb +13 -19
- data/spec/isodoc/section_spec.rb +8 -11
- data/spec/isodoc/terms_spec.rb +2 -7
- data/spec/metanorma/processor_spec.rb +2 -2
- data/spec/spec_helper.rb +9 -0
- metadata +2 -17
- data/spec/asciidoctor-iec/macros_spec.rb +0 -21
@@ -114,8 +114,8 @@ RSpec.describe IsoDoc do
|
|
114
114
|
|
115
115
|
INPUT
|
116
116
|
word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
|
117
|
-
sub(%r{<
|
118
|
-
expect(word).to be_equivalent_to <<~"OUTPUT"
|
117
|
+
sub(%r{<br.*$}m, "")
|
118
|
+
expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
119
119
|
<div class="WordSection3">
|
120
120
|
#{IEC_TITLE}
|
121
121
|
<div><a name="_terms_and_definitions" id="_terms_and_definitions"></a><h1 class="main">1<span style="mso-tab-count:1">  </span>Terms and definitions</h1>
|
@@ -123,8 +123,6 @@ RSpec.describe IsoDoc do
|
|
123
123
|
<p class="MsoNormal"><a name="_eb29b35e-123e-4d1c-b50b-2714d41e747f" id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"></a>rice retaining its husk after threshing</p>
|
124
124
|
<p class="MsoNormal">[SOURCE: <a href="#ISO7301">ISO 7301:2011, 3.1</a>, modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p></div>
|
125
125
|
</div>
|
126
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
127
|
-
<div class="colophon"></div>
|
128
126
|
OUTPUT
|
129
127
|
end
|
130
128
|
|
@@ -169,7 +167,8 @@ RSpec.describe IsoDoc do
|
|
169
167
|
INPUT
|
170
168
|
word = File.read("test.doc", encoding: "UTF-8").sub(/^.*An empty word intro page\./m, '').
|
171
169
|
sub(%r{<p class="zzSTDTitle1">.*$}m, "")
|
172
|
-
expect(word.gsub(/_Toc\d\d+/, "_Toc")).to be_equivalent_to <<~'OUTPUT'
|
170
|
+
expect(xmlpp("<div>" + word.gsub(/_Toc\d\d+/, "_Toc") + "</div>")).to be_equivalent_to xmlpp(<<~'OUTPUT')
|
171
|
+
<div>
|
173
172
|
<p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes"> </span>TOC
|
174
173
|
\o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
|
175
174
|
<span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
@@ -234,6 +233,7 @@ RSpec.describe IsoDoc do
|
|
234
233
|
<p class="MsoNormal">
|
235
234
|
<br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
|
236
235
|
</p>
|
236
|
+
</div>
|
237
237
|
OUTPUT
|
238
238
|
end
|
239
239
|
|
@@ -259,10 +259,10 @@ RSpec.describe IsoDoc do
|
|
259
259
|
</sections>
|
260
260
|
</iso-standard>
|
261
261
|
INPUT
|
262
|
-
html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
|
262
|
+
html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main xmlns:epub="epub" class="main-section">').
|
263
263
|
sub(%r{</main>.*$}m, "</main>")
|
264
|
-
expect(html).to be_equivalent_to <<~"OUTPUT"
|
265
|
-
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
264
|
+
expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
265
|
+
<main xmlns:epub="epub" class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
266
266
|
<br/>
|
267
267
|
#{IEC_TITLE}
|
268
268
|
<div id="">
|
@@ -316,7 +316,7 @@ RSpec.describe IsoDoc do
|
|
316
316
|
html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main class="main-section">').
|
317
317
|
sub(%r{</main>.*$}m, "</main>")
|
318
318
|
expect(`ls test_htmlimages`).to match(/\.png$/)
|
319
|
-
expect(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")).to be_equivalent_to <<~"OUTPUT"
|
319
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
320
320
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
321
321
|
<br />
|
322
322
|
#{IEC_TITLE}
|
@@ -410,8 +410,8 @@ RSpec.describe IsoDoc do
|
|
410
410
|
</iso-standard>
|
411
411
|
INPUT
|
412
412
|
word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
|
413
|
-
sub(%r{<div
|
414
|
-
expect(word).to be_equivalent_to <<~"OUTPUT"
|
413
|
+
sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
|
414
|
+
expect((word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
415
415
|
<div class="WordSection3">
|
416
416
|
#{IEC_TITLE}
|
417
417
|
<p class="MsoNormal">
|
@@ -426,9 +426,6 @@ RSpec.describe IsoDoc do
|
|
426
426
|
</div>
|
427
427
|
</div>
|
428
428
|
</div>
|
429
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
430
|
-
<div class="colophon"></div>
|
431
|
-
|
432
429
|
OUTPUT
|
433
430
|
end
|
434
431
|
|
@@ -450,8 +447,8 @@ RSpec.describe IsoDoc do
|
|
450
447
|
</iso-standard>
|
451
448
|
INPUT
|
452
449
|
word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
|
453
|
-
sub(%r{<div
|
454
|
-
expect(word).to be_equivalent_to <<~"OUTPUT"
|
450
|
+
sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
|
451
|
+
expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
455
452
|
<div class="WordSection3">
|
456
453
|
#{IEC_TITLE.gsub(/\ /, " ")}
|
457
454
|
<p class="MsoNormal">
|
@@ -473,9 +470,6 @@ RSpec.describe IsoDoc do
|
|
473
470
|
</div>
|
474
471
|
</div>
|
475
472
|
</div>
|
476
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
477
|
-
<div class="colophon"></div>
|
478
|
-
|
479
473
|
OUTPUT
|
480
474
|
end
|
481
475
|
|
data/spec/isodoc/section_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes section names" do
|
5
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
5
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<preface>
|
8
8
|
<foreword obligation="informative">
|
@@ -159,7 +159,7 @@ OUTPUT
|
|
159
159
|
end
|
160
160
|
|
161
161
|
it "processes section names (Word)" do
|
162
|
-
expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ")).to be_equivalent_to <<~"OUTPUT"
|
162
|
+
expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
163
163
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
164
164
|
<preface>
|
165
165
|
<foreword obligation="informative">
|
@@ -308,12 +308,11 @@ OUTPUT
|
|
308
308
|
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
309
309
|
<div class="colophon"/>
|
310
310
|
</body>
|
311
|
-
</html>
|
312
311
|
OUTPUT
|
313
312
|
end
|
314
313
|
|
315
314
|
it "processes simple terms & definitions" do
|
316
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
315
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
317
316
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
318
317
|
<sections>
|
319
318
|
<terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
|
@@ -341,7 +340,7 @@ OUTPUT
|
|
341
340
|
end
|
342
341
|
|
343
342
|
it "processes inline section headers" do
|
344
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
343
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
345
344
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
346
345
|
<sections>
|
347
346
|
<clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
|
@@ -376,7 +375,7 @@ OUTPUT
|
|
376
375
|
end
|
377
376
|
|
378
377
|
it "adds colophon to published standard (Word)" do
|
379
|
-
|
378
|
+
expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
380
379
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
381
380
|
<bibdata>
|
382
381
|
<status>
|
@@ -406,12 +405,11 @@ OUTPUT
|
|
406
405
|
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
407
406
|
<div class="colophon"/>
|
408
407
|
</body>
|
409
|
-
</html>
|
410
408
|
OUTPUT
|
411
409
|
end
|
412
410
|
|
413
411
|
it "does not add colophon to draft standard (Word)" do
|
414
|
-
expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ")).to be_equivalent_to <<~"OUTPUT"
|
412
|
+
expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*<body /m, "<body ").sub(%r{</body>.*$}m, "</body>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
415
413
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
416
414
|
<bibdata>
|
417
415
|
<status>
|
@@ -439,12 +437,11 @@ OUTPUT
|
|
439
437
|
#{IEC_TITLE}
|
440
438
|
</div>
|
441
439
|
</body>
|
442
|
-
</html>
|
443
440
|
OUTPUT
|
444
441
|
end
|
445
442
|
|
446
443
|
it "adds boilerplate to foreword" do
|
447
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
444
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
448
445
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
449
446
|
<bibdata>
|
450
447
|
<ext><doctype>International Standard</doctype></ext>
|
@@ -472,7 +469,7 @@ OUTPUT
|
|
472
469
|
end
|
473
470
|
|
474
471
|
it "does not add boilerplate to foreword in amendments" do
|
475
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
472
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
476
473
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
477
474
|
<bibdata>
|
478
475
|
<ext><doctype>Amendment</doctype></ext>
|
data/spec/isodoc/terms_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes IsoXML terms" do
|
5
|
-
expect(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
5
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<sections>
|
8
8
|
<terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
|
@@ -95,7 +95,7 @@ OUTPUT
|
|
95
95
|
end
|
96
96
|
|
97
97
|
it "processes IsoXML terms (Word)" do
|
98
|
-
expect(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{^.*<div id="_terms_and_definitions">}m, '<div id="_terms_and_definitions">')).to be_equivalent_to <<~"OUTPUT"
|
98
|
+
expect((IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{^.*<div id="_terms_and_definitions">}m, '<div id="_terms_and_definitions">').sub(%r{<br[^>]*>\s*<div class="colophon"/>.*$}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
99
99
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
100
100
|
<sections>
|
101
101
|
<terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
|
@@ -175,11 +175,6 @@ OUTPUT
|
|
175
175
|
<p>[TERMREF]
|
176
176
|
<a href="#ISO7301">ISO 7301:2011, 3.1</a>
|
177
177
|
[/TERMREF]</p></div>
|
178
|
-
</div>
|
179
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
180
|
-
<div class="colophon"/>
|
181
|
-
</body>
|
182
|
-
</html>
|
183
178
|
|
184
179
|
OUTPUT
|
185
180
|
end
|
@@ -24,7 +24,7 @@ RSpec.describe Metanorma::Iec::Processor do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "generates IsoDoc XML from a blank document" do
|
27
|
-
expect(strip_guid(processor.input_to_isodoc(<<~"INPUT", nil))).to be_equivalent_to <<~"OUTPUT"
|
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}
|
@@ -46,7 +46,7 @@ RSpec.describe Metanorma::Iec::Processor do
|
|
46
46
|
</sections>
|
47
47
|
</iso-standard>
|
48
48
|
INPUT
|
49
|
-
expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>")).to be_equivalent_to <<~"OUTPUT"
|
49
|
+
expect(xmlpp(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
50
50
|
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
51
51
|
<br />
|
52
52
|
<p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,7 @@ require "equivalent-xml"
|
|
11
11
|
require "metanorma"
|
12
12
|
require "metanorma/iec"
|
13
13
|
require "iev"
|
14
|
+
require "rexml/document"
|
14
15
|
|
15
16
|
RSpec.configure do |config|
|
16
17
|
# Enable flags like --only-failures and --next-failure
|
@@ -28,6 +29,14 @@ def strip_guid(x)
|
|
28
29
|
x.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"}, ' target="_"')
|
29
30
|
end
|
30
31
|
|
32
|
+
def xmlpp(x)
|
33
|
+
s = ""
|
34
|
+
f = REXML::Formatters::Pretty.new(2)
|
35
|
+
f.compact = true
|
36
|
+
f.write(REXML::Document.new(x),s)
|
37
|
+
s
|
38
|
+
end
|
39
|
+
|
31
40
|
ASCIIDOC_BLANK_HDR = <<~"HDR"
|
32
41
|
= Document title
|
33
42
|
Author
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-iec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: asciidoctor
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.5.7
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.5.7
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: ruby-jing
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,7 +279,6 @@ files:
|
|
293
279
|
- spec/asciidoctor-iec/cleanup_spec.rb
|
294
280
|
- spec/asciidoctor-iec/inline_spec.rb
|
295
281
|
- spec/asciidoctor-iec/lists_spec.rb
|
296
|
-
- spec/asciidoctor-iec/macros_spec.rb
|
297
282
|
- spec/asciidoctor-iec/section_spec.rb
|
298
283
|
- spec/asciidoctor-iec/table_spec.rb
|
299
284
|
- spec/asciidoctor-iec/validate_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe Asciidoctor::Iec do
|
4
|
-
it "processes the Asciidoctor::ISO inline macros" do
|
5
|
-
expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
|
6
|
-
#{ASCIIDOC_BLANK_HDR}
|
7
|
-
alt:[term1]
|
8
|
-
deprecated:[term1]
|
9
|
-
domain:[term1]
|
10
|
-
INPUT
|
11
|
-
#{BLANK_HDR}
|
12
|
-
<sections>
|
13
|
-
<admitted>term1</admitted>
|
14
|
-
<deprecates>term1</deprecates>
|
15
|
-
<domain>term1</domain>
|
16
|
-
</sections>
|
17
|
-
</iso-standard>
|
18
|
-
OUTPUT
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|