metanorma-iec 1.2.11 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
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
- #{BLANK_HDR}
361
+ #{@blank_hdr}
358
362
  <sections>
359
363
  <clause id="_" inline-header="false" obligation="normative">
360
364
  <title>Clause 1</title>
@@ -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
- #{BLANK_HDR}
30
+ #{blank_hdr_gen}
31
31
  <sections/>
32
32
  </iec-standard>
33
33
  OUTPUT
@@ -112,38 +112,17 @@ TERMS_BOILERPLATE = <<~"BOILERPLATE"
112
112
  </ul>
113
113
  BOILERPLATE
114
114
 
115
- BOILERPLATE =
116
- HTMLEntities.new.decode(
117
- File.read(File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iec", "iec_intro_en.xml"), encoding: "utf-8").
118
- gsub(/\{\{ agency \}\}/, "IEC").gsub(/\{\{ docyear \}\}/, Date.today.year.to_s).
119
- gsub(/\{% if unpublished %\}.*\{% endif %\}/m, "").
120
- gsub(/(?<=\p{Alnum})'(?=\p{Alpha})/, "’").
121
- gsub(/<p>/, "<p id='_'>").
122
- gsub(/<ol>/, "<ol id='_'>").
123
- gsub(/ - /, " — ").
124
- gsub(/\.\.\./, "…")
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>
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.11
4
+ version: 1.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-28 00:00:00.000000000 Z
11
+ date: 2021-01-11 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.6.0
33
+ version: 1.6.1
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.6.0
40
+ version: 1.6.1
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: byebug
43
43
  requirement: !ruby/object:Gem::Requirement