metanorma-iec 1.3.9 → 1.3.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asciidoctor/iec/isodoc.rng +23 -9
- data/lib/asciidoctor/iec/isostandard.rng +3 -0
- data/lib/isodoc/iec/iec.international-standard.xsl +268 -134
- data/lib/metanorma/iec/version.rb +1 -1
- data/spec/isodoc/iso_spec.rb +166 -172
- data/spec/spec_helper.rb +170 -165
- metadata +2 -2
data/spec/isodoc/iso_spec.rb
CHANGED
@@ -4,15 +4,16 @@ require "fileutils"
|
|
4
4
|
RSpec.describe IsoDoc::Iec do
|
5
5
|
FileUtils.rm_f "test.html"
|
6
6
|
it "processes isodoc as ISO: HTML output" do
|
7
|
-
IsoDoc::Iec::HtmlConvert.new({})
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
IsoDoc::Iec::HtmlConvert.new({})
|
8
|
+
.convert("test", <<~"INPUT", false)
|
9
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
10
|
+
<preface><foreword>
|
11
|
+
<note>
|
12
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
13
|
+
</note>
|
14
|
+
</foreword></preface>
|
15
|
+
</iso-standard>
|
16
|
+
INPUT
|
16
17
|
html = File.read("test.html", encoding: "utf-8")
|
17
18
|
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
18
19
|
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
|
@@ -20,16 +21,17 @@ RSpec.describe IsoDoc::Iec do
|
|
20
21
|
end
|
21
22
|
|
22
23
|
it "processes isodoc as ISO: Chinese HTML output" do
|
23
|
-
|
24
|
-
IsoDoc::Iec::HtmlConvert.new({script: "Hans"})
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
FileUtils.rm_f "test.html"
|
25
|
+
IsoDoc::Iec::HtmlConvert.new({ script: "Hans" })
|
26
|
+
.convert("test", <<~"INPUT", false)
|
27
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
28
|
+
<preface><foreword>
|
29
|
+
<note>
|
30
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
31
|
+
</note>
|
32
|
+
</foreword></preface>
|
33
|
+
</iso-standard>
|
34
|
+
INPUT
|
33
35
|
html = File.read("test.html", encoding: "utf-8")
|
34
36
|
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
35
37
|
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: "Source Han Sans", serif;]m)
|
@@ -37,16 +39,19 @@ RSpec.describe IsoDoc::Iec do
|
|
37
39
|
end
|
38
40
|
|
39
41
|
it "processes isodoc as ISO: user nominated fonts" do
|
40
|
-
|
41
|
-
IsoDoc::Iec::HtmlConvert
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
FileUtils.rm_f "test.html"
|
43
|
+
IsoDoc::Iec::HtmlConvert
|
44
|
+
.new({ bodyfont: "Zapf Chancery", headerfont: "Comic Sans",
|
45
|
+
monospacefont: "Andale Mono" })
|
46
|
+
.convert("test", <<~"INPUT", false)
|
47
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
48
|
+
<preface><foreword>
|
49
|
+
<note>
|
50
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
51
|
+
</note>
|
52
|
+
</foreword></preface>
|
53
|
+
</iso-standard>
|
54
|
+
INPUT
|
50
55
|
html = File.read("test.html", encoding: "utf-8")
|
51
56
|
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
|
52
57
|
expect(html).to match(%r[blockquote[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
@@ -54,16 +59,17 @@ RSpec.describe IsoDoc::Iec do
|
|
54
59
|
end
|
55
60
|
|
56
61
|
it "processes isodoc as ISO: Word output" do
|
57
|
-
|
58
|
-
IsoDoc::Iec::WordConvert.new({})
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
FileUtils.rm_f "test.doc"
|
63
|
+
IsoDoc::Iec::WordConvert.new({})
|
64
|
+
.convert("test", <<~"INPUT", false)
|
65
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
66
|
+
<preface><foreword>
|
67
|
+
<note>
|
68
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
69
|
+
</note>
|
70
|
+
</foreword></preface>
|
71
|
+
</iso-standard>
|
72
|
+
INPUT
|
67
73
|
html = File.read("test.doc", encoding: "utf-8")
|
68
74
|
expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
69
75
|
expect(html).to match(%r[Quote[^{]+\{[^{]+font-family: "Arial", sans-serif;]m)
|
@@ -71,147 +77,135 @@ RSpec.describe IsoDoc::Iec do
|
|
71
77
|
end
|
72
78
|
|
73
79
|
it "processes examples" do
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
</example>
|
81
|
-
|
82
|
-
|
80
|
+
input = <<~INPUT
|
81
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
82
|
+
<preface><foreword>
|
83
|
+
<example id="samplecode">
|
84
|
+
<name>EXAMPLE</name>
|
85
|
+
<p>Hello</p>
|
86
|
+
</example>
|
87
|
+
</foreword></preface>
|
88
|
+
</iso-standard>
|
83
89
|
INPUT
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
90
|
+
html = <<~OUTPUT
|
91
|
+
#{HTML_HDR}
|
92
|
+
<div>
|
93
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
94
|
+
<div class="boilerplate_legal"/>
|
95
|
+
<div id="samplecode" class="example">
|
96
|
+
<p><span class="example_label">EXAMPLE</span>  Hello</p>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
#{IEC_TITLE1}
|
100
|
+
</div>
|
101
|
+
</body>
|
102
|
+
</html>
|
96
103
|
OUTPUT
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
<div id="samplecode2" class="example">
|
123
|
-
<p><span class="example_label">EXAMPLE 2</span>  Hello</p>
|
124
|
-
</div>
|
125
|
-
</div>
|
126
|
-
#{IEC_TITLE1}
|
127
|
-
</div>
|
128
|
-
</body>
|
129
|
-
</html>
|
104
|
+
doc = <<~OUTPUT
|
105
|
+
<body lang="EN-US" link="blue" vlink="#954F72">
|
106
|
+
<div class="WordSection2">
|
107
|
+
<p>
|
108
|
+
<br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
|
109
|
+
</p>
|
110
|
+
#{IEC_TITLE}
|
111
|
+
<div>
|
112
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
113
|
+
<div class="boilerplate_legal"/>
|
114
|
+
<div id="samplecode" class="example">
|
115
|
+
<p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">  </span>Hello</p>
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
<p> </p>
|
119
|
+
</div>
|
120
|
+
<p>
|
121
|
+
<br clear="all" class="section"/>
|
122
|
+
</p>
|
123
|
+
<div class="WordSection3">
|
124
|
+
#{IEC_TITLE1}
|
125
|
+
</div>
|
126
|
+
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
127
|
+
<div class="colophon"/>
|
128
|
+
</body>
|
130
129
|
OUTPUT
|
130
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
131
|
+
.convert("test", input, true)))
|
132
|
+
.to be_equivalent_to xmlpp(html)
|
133
|
+
expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
|
134
|
+
.convert("test", input, true)
|
135
|
+
.sub(/^.*<body/m, "<body")
|
136
|
+
.sub(%r{</body>.*$}m, "</body>")))
|
137
|
+
.to be_equivalent_to xmlpp(doc)
|
131
138
|
end
|
132
139
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
</example>
|
141
|
-
|
142
|
-
|
140
|
+
it "processes sequences of examples" do
|
141
|
+
input = <<~INPUT
|
142
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
143
|
+
<preface><foreword>
|
144
|
+
<example id="samplecode">
|
145
|
+
<name>EXAMPLE 1</name>
|
146
|
+
<p>Hello</p>
|
147
|
+
</example>
|
148
|
+
<example id="samplecode2">
|
149
|
+
<name>EXAMPLE 2</name>
|
150
|
+
<p>Hello</p>
|
151
|
+
</example>
|
152
|
+
</foreword></preface>
|
153
|
+
</iso-standard>
|
143
154
|
INPUT
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
<br clear="all" class="section"/>
|
161
|
-
</p>
|
162
|
-
<div class="WordSection3">
|
163
|
-
#{IEC_TITLE1}
|
164
|
-
</div>
|
165
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
166
|
-
<div class="colophon"/>
|
167
|
-
</body>
|
155
|
+
html = <<~OUTPUT
|
156
|
+
#{HTML_HDR}
|
157
|
+
<div>
|
158
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
159
|
+
<div class="boilerplate_legal"/>
|
160
|
+
<div id="samplecode" class="example">
|
161
|
+
<p><span class="example_label">EXAMPLE 1</span>  Hello</p>
|
162
|
+
</div>
|
163
|
+
<div id="samplecode2" class="example">
|
164
|
+
<p><span class="example_label">EXAMPLE 2</span>  Hello</p>
|
165
|
+
</div>
|
166
|
+
</div>
|
167
|
+
#{IEC_TITLE1}
|
168
|
+
</div>
|
169
|
+
</body>
|
170
|
+
</html>
|
168
171
|
OUTPUT
|
169
|
-
end
|
170
|
-
|
171
172
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
</
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
<p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">  </span>Hello</p>
|
201
|
-
</div>
|
202
|
-
</div>
|
203
|
-
<p> </p>
|
204
|
-
</div>
|
205
|
-
<p>
|
206
|
-
<br clear="all" class="section"/>
|
207
|
-
</p>
|
208
|
-
<div class="WordSection3">
|
209
|
-
#{IEC_TITLE1}
|
210
|
-
</div>
|
211
|
-
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
212
|
-
<div class="colophon"/>
|
213
|
-
</body>
|
173
|
+
doc = <<~OUTPUT
|
174
|
+
<body lang="EN-US" link="blue" vlink="#954F72">
|
175
|
+
<div class="WordSection2">
|
176
|
+
<p>
|
177
|
+
<br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
|
178
|
+
</p>
|
179
|
+
#{IEC_TITLE}
|
180
|
+
<div>
|
181
|
+
<h1 class="ForewordTitle">FOREWORD</h1>
|
182
|
+
<div class="boilerplate_legal"/>
|
183
|
+
<div id="samplecode" class="example">
|
184
|
+
<p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">  </span>Hello</p>
|
185
|
+
</div>
|
186
|
+
<div id="samplecode2" class="example">
|
187
|
+
<p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">  </span>Hello</p>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
<p> </p>
|
191
|
+
</div>
|
192
|
+
<p>
|
193
|
+
<br clear="all" class="section"/>
|
194
|
+
</p>
|
195
|
+
<div class="WordSection3">
|
196
|
+
#{IEC_TITLE1}
|
197
|
+
</div>
|
198
|
+
<br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
|
199
|
+
<div class="colophon"/>
|
200
|
+
</body>
|
214
201
|
OUTPUT
|
202
|
+
expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({})
|
203
|
+
.convert("test", input, true)))
|
204
|
+
.to be_equivalent_to xmlpp(html)
|
205
|
+
expect(xmlpp(IsoDoc::Iec::WordConvert.new({})
|
206
|
+
.convert("test", input, true)
|
207
|
+
.sub(/^.*<body/m, "<body")
|
208
|
+
.sub(%r{</body>.*$}m, "</body>")))
|
209
|
+
.to be_equivalent_to xmlpp(doc)
|
215
210
|
end
|
216
|
-
|
217
211
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -25,218 +25,224 @@ RSpec.configure do |config|
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def metadata(
|
29
|
-
|
28
|
+
def metadata(xml)
|
29
|
+
xml.sort.to_h.delete_if do |_k, v|
|
30
|
+
v.nil? || v.respond_to?(:empty?) && v.empty?
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
|
-
def strip_guid(
|
33
|
-
|
34
|
+
def strip_guid(xml)
|
35
|
+
xml.gsub(%r{ id="_[^"]+"}, ' id="_"').gsub(%r{ target="_[^"]+"},
|
36
|
+
' target="_"')
|
34
37
|
end
|
35
38
|
|
36
|
-
def xmlpp(
|
39
|
+
def xmlpp(xml)
|
37
40
|
s = ""
|
38
41
|
f = REXML::Formatters::Pretty.new(2)
|
39
42
|
f.compact = true
|
40
|
-
f.write(REXML::Document.new(
|
43
|
+
f.write(REXML::Document.new(xml), s)
|
41
44
|
s
|
42
45
|
end
|
43
46
|
|
44
47
|
OPTIONS = [backend: :iec, header_footer: true, agree_to_terms: true].freeze
|
45
48
|
|
46
|
-
ASCIIDOC_BLANK_HDR = <<~"HDR"
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
ASCIIDOC_BLANK_HDR = <<~"HDR".freeze
|
50
|
+
= Document title
|
51
|
+
Author
|
52
|
+
:docfile: test.adoc
|
53
|
+
:nodoc:
|
54
|
+
:novalid:
|
55
|
+
:no-isobib:
|
53
56
|
|
54
57
|
HDR
|
55
58
|
|
56
|
-
ISOBIB_BLANK_HDR = <<~"HDR"
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
60
|
+
= Document title
|
61
|
+
Author
|
62
|
+
:docfile: test.adoc
|
63
|
+
:nodoc:
|
64
|
+
:novalid:
|
65
|
+
:no-isobib-cache:
|
63
66
|
|
64
67
|
HDR
|
65
68
|
|
66
|
-
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR"
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
FLUSH_CACHE_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
70
|
+
= Document title
|
71
|
+
Author
|
72
|
+
:docfile: test.adoc
|
73
|
+
:nodoc:
|
74
|
+
:novalid:
|
75
|
+
:flush-caches:
|
73
76
|
|
74
77
|
HDR
|
75
78
|
|
76
|
-
CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
80
|
+
= Document title
|
81
|
+
Author
|
82
|
+
:docfile: test.adoc
|
83
|
+
:nodoc:
|
84
|
+
:novalid:
|
82
85
|
|
83
86
|
HDR
|
84
87
|
|
85
|
-
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR"
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
LOCAL_CACHED_ISOBIB_BLANK_HDR = <<~"HDR".freeze
|
89
|
+
= Document title
|
90
|
+
Author
|
91
|
+
:docfile: test.adoc
|
92
|
+
:nodoc:
|
93
|
+
:novalid:
|
94
|
+
:local-cache:
|
92
95
|
|
93
96
|
HDR
|
94
97
|
|
95
|
-
VALIDATING_BLANK_HDR = <<~"HDR"
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
VALIDATING_BLANK_HDR = <<~"HDR".freeze
|
99
|
+
= Document title
|
100
|
+
Author
|
101
|
+
:docfile: test.adoc
|
102
|
+
:nodoc:
|
103
|
+
:no-isobib:
|
101
104
|
|
102
105
|
HDR
|
103
106
|
|
104
|
-
TERMS_BOILERPLATE = <<~"BOILERPLATE"
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
</ul>
|
107
|
+
TERMS_BOILERPLATE = <<~"BOILERPLATE".freeze
|
108
|
+
<p id="_">ISO and IEC maintain terminological databases for use in
|
109
|
+
standardization at the following addresses:</p>
|
110
|
+
#{' '}
|
111
|
+
<ul id="_">
|
112
|
+
<li> <p id="_">IEC Electropedia: available at
|
113
|
+
<link target="http://www.electropedia.org"/>
|
114
|
+
</p> </li>#{' '}
|
115
|
+
<li> <p id="_">ISO Online browsing platform: available at
|
116
|
+
<link target="http://www.iso.org/obp"/></p> </li>
|
117
|
+
</ul>
|
115
118
|
BOILERPLATE
|
116
119
|
|
117
120
|
def boilerplate(xmldoc)
|
118
|
-
file = File.read(
|
119
|
-
|
120
|
-
|
121
|
+
file = File.read(
|
122
|
+
File.join(File.dirname(__FILE__), "..", "lib", "asciidoctor", "iec",
|
123
|
+
"iec_intro_en.xml"), encoding: "utf-8"
|
124
|
+
)
|
125
|
+
conv = Asciidoctor::Iec::Converter.new(nil, backend: :iec,
|
126
|
+
header_footer: true)
|
127
|
+
conv.init(Asciidoctor::Document.new([]))
|
121
128
|
ret = Nokogiri::XML(
|
122
|
-
conv.boilerplate_isodoc(xmldoc).populate_template(file, nil)
|
123
|
-
gsub(/<p>/, "<p id='_'>")
|
124
|
-
gsub(/<ol>/, "<ol id='_'>")
|
129
|
+
conv.boilerplate_isodoc(xmldoc).populate_template(file, nil)
|
130
|
+
.gsub(/<p>/, "<p id='_'>")
|
131
|
+
.gsub(/<ol>/, "<ol id='_'>"),
|
132
|
+
)
|
125
133
|
conv.smartquotes_cleanup(ret)
|
126
134
|
HTMLEntities.new.decode(ret.to_xml)
|
127
135
|
end
|
128
136
|
|
129
|
-
BLANK_HDR = <<~"HDR"
|
130
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
131
|
-
<iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
|
132
|
-
<bibdata type="standard">
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
<organization>
|
143
|
-
<name>International Electrotechnical Commission</name>
|
144
|
-
<abbreviation>IEC</abbreviation>
|
145
|
-
</organization>
|
146
|
-
</contributor>
|
147
|
-
<language>en</language>
|
148
|
-
<script>Latn</script>
|
149
|
-
<status>
|
150
|
-
<stage abbreviation="PPUB">60</stage>
|
151
|
-
<substage abbreviation="PPUB">60</substage>
|
152
|
-
</status>
|
153
|
-
<copyright>
|
154
|
-
<from>#{Time.new.year}</from>
|
155
|
-
<owner>
|
137
|
+
BLANK_HDR = <<~"HDR".freeze
|
138
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
139
|
+
<iec-standard xmlns="https://www.metanorma.org/ns/iec" type="semantic" version="#{Metanorma::Iec::VERSION}">
|
140
|
+
<bibdata type="standard">
|
141
|
+
<contributor>
|
142
|
+
<role type="author"/>
|
143
|
+
<organization>
|
144
|
+
<name>International Electrotechnical Commission</name>
|
145
|
+
<abbreviation>IEC</abbreviation>
|
146
|
+
</organization>
|
147
|
+
</contributor>
|
148
|
+
<contributor>
|
149
|
+
<role type="publisher"/>
|
156
150
|
<organization>
|
157
151
|
<name>International Electrotechnical Commission</name>
|
158
152
|
<abbreviation>IEC</abbreviation>
|
159
153
|
</organization>
|
160
|
-
</
|
161
|
-
|
162
|
-
|
163
|
-
<
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
<
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
</
|
154
|
+
</contributor>
|
155
|
+
<language>en</language>
|
156
|
+
<script>Latn</script>
|
157
|
+
<status>
|
158
|
+
<stage abbreviation="PPUB">60</stage>
|
159
|
+
<substage abbreviation="PPUB">60</substage>
|
160
|
+
</status>
|
161
|
+
<copyright>
|
162
|
+
<from>#{Time.new.year}</from>
|
163
|
+
<owner>
|
164
|
+
<organization>
|
165
|
+
<name>International Electrotechnical Commission</name>
|
166
|
+
<abbreviation>IEC</abbreviation>
|
167
|
+
</organization>
|
168
|
+
</owner>
|
169
|
+
</copyright>
|
170
|
+
<ext>
|
171
|
+
<doctype>article</doctype>
|
172
|
+
<horizontal>false</horizontal>
|
173
|
+
<editorialgroup>
|
174
|
+
<technical-committee/>
|
175
|
+
<subcommittee/>
|
176
|
+
<workgroup/>
|
177
|
+
</editorialgroup>
|
178
|
+
<stagename>International standard</stagename>
|
179
|
+
</ext>
|
180
|
+
</bibdata>
|
173
181
|
HDR
|
174
182
|
|
175
183
|
def blank_hdr_gen
|
176
|
-
<<~"HDR"
|
177
|
-
#{BLANK_HDR}
|
178
|
-
#{boilerplate(Nokogiri::XML(BLANK_HDR
|
179
|
-
HDR
|
184
|
+
<<~"HDR"
|
185
|
+
#{BLANK_HDR}
|
186
|
+
#{boilerplate(Nokogiri::XML("#{BLANK_HDR}</iec-standard>"))}
|
187
|
+
HDR
|
180
188
|
end
|
181
189
|
|
190
|
+
IEC_TITLE = <<~TITLE.freeze
|
191
|
+
<p class="zzSTDTitle1">INTERNATIONAL ELECTROTECHNICAL COMMISSION</p>
|
192
|
+
<p class="zzSTDTitle1">____________</p>
|
193
|
+
<p class="zzSTDTitle1"> </p>
|
194
|
+
<p class="zzSTDTitle1">
|
195
|
+
<b/>
|
196
|
+
</p>
|
197
|
+
<p class="zzSTDTitle1"> </p>
|
198
|
+
TITLE
|
199
|
+
|
200
|
+
IEC_TITLE1 = <<~TITLE.freeze
|
201
|
+
<p class="zzSTDTitle1">
|
202
|
+
<b/>
|
203
|
+
</p>
|
204
|
+
<p class="zzSTDTitle1"> </p>
|
205
|
+
TITLE
|
206
|
+
|
207
|
+
HTML_HDR = <<~HDR.freeze
|
208
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
209
|
+
<head/>
|
210
|
+
<body lang="en">
|
211
|
+
<div class="title-section">
|
212
|
+
<p> </p>
|
213
|
+
</div>
|
214
|
+
<br/>
|
215
|
+
<div class="prefatory-section">
|
216
|
+
<p> </p>
|
217
|
+
</div>
|
218
|
+
<br/>
|
219
|
+
<div class="main-section">
|
220
|
+
<br/>
|
221
|
+
#{IEC_TITLE}
|
222
|
+
HDR
|
182
223
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
HTML_HDR = <<~END
|
201
|
-
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
202
|
-
<head/>
|
203
|
-
<body lang="en">
|
204
|
-
<div class="title-section">
|
205
|
-
<p> </p>
|
206
|
-
</div>
|
207
|
-
<br/>
|
208
|
-
<div class="prefatory-section">
|
209
|
-
<p> </p>
|
210
|
-
</div>
|
211
|
-
<br/>
|
212
|
-
<div class="main-section">
|
213
|
-
<br/>
|
214
|
-
#{IEC_TITLE}
|
215
|
-
END
|
216
|
-
|
217
|
-
WORD_HDR = <<~END
|
218
|
-
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
219
|
-
<head>
|
220
|
-
<title>test</title>
|
221
|
-
</head>
|
222
|
-
<body lang="EN-US" link="blue" vlink="#954F72">
|
223
|
-
<div class="WordSection1">
|
224
|
-
<p> </p>
|
225
|
-
</div>
|
226
|
-
<p><br clear="all" class="section"/></p>
|
227
|
-
<div class="WordSection2">
|
228
|
-
<p> </p>
|
229
|
-
</div>
|
230
|
-
<p><br clear="all" class="section"/></p>
|
231
|
-
<div class="WordSection3">
|
232
|
-
END
|
233
|
-
|
224
|
+
WORD_HDR = <<~HDR.freeze
|
225
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
226
|
+
<head>
|
227
|
+
<title>test</title>
|
228
|
+
</head>
|
229
|
+
<body lang="EN-US" link="blue" vlink="#954F72">
|
230
|
+
<div class="WordSection1">
|
231
|
+
<p> </p>
|
232
|
+
</div>
|
233
|
+
<p><br clear="all" class="section"/></p>
|
234
|
+
<div class="WordSection2">
|
235
|
+
<p> </p>
|
236
|
+
</div>
|
237
|
+
<p><br clear="all" class="section"/></p>
|
238
|
+
<div class="WordSection3">
|
239
|
+
HDR
|
234
240
|
|
235
241
|
def stub_fetch_ref(**opts)
|
236
242
|
xml = ""
|
237
243
|
|
238
244
|
hit = double("hit")
|
239
|
-
expect(hit).to receive(:
|
245
|
+
expect(hit).to receive(:[]).with("title") do
|
240
246
|
Nokogiri::XML(xml).at("//docidentifier").content
|
241
247
|
end.at_least(:once)
|
242
248
|
|
@@ -254,8 +260,8 @@ def stub_fetch_ref(**opts)
|
|
254
260
|
hit_pages = double("hit_pages")
|
255
261
|
expect(hit_pages).to receive(:first).and_return(hit_page).at_least :once
|
256
262
|
|
257
|
-
expect(Isobib::IsoBibliography).to receive(:search)
|
258
|
-
and_wrap_original do |search, *args|
|
263
|
+
expect(Isobib::IsoBibliography).to receive(:search)
|
264
|
+
.and_wrap_original do |search, *args|
|
259
265
|
code = args[0]
|
260
266
|
expect(code).to be_instance_of String
|
261
267
|
xml = get_xml(search, code, opts)
|
@@ -264,7 +270,7 @@ def stub_fetch_ref(**opts)
|
|
264
270
|
end
|
265
271
|
|
266
272
|
def mock_pdf
|
267
|
-
allow(::Mn2pdf).to receive(:convert) do |url, output,
|
273
|
+
allow(::Mn2pdf).to receive(:convert) do |url, output, _c, _d|
|
268
274
|
FileUtils.cp(url.gsub(/"/, ""), output.gsub(/"/, ""))
|
269
275
|
end
|
270
276
|
end
|
@@ -272,7 +278,7 @@ end
|
|
272
278
|
private
|
273
279
|
|
274
280
|
def get_xml(search, code, opts)
|
275
|
-
c = code.gsub(%r{[
|
281
|
+
c = code.gsub(%r{[/\s:-]}, "_").sub(%r{_+$}, "").downcase
|
276
282
|
o = opts.keys.join "_"
|
277
283
|
file = "spec/examples/#{[c, o].join '_'}.xml"
|
278
284
|
if File.exist? file
|
@@ -287,11 +293,10 @@ def get_xml(search, code, opts)
|
|
287
293
|
end
|
288
294
|
|
289
295
|
def mock_open_uri(code)
|
290
|
-
#expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
296
|
+
# expect(OpenURI).to receive(:open_uri).and_wrap_original do |m, *args|
|
291
297
|
expect(Iev).to receive(:get).with(code, "en") do |m, *args|
|
292
298
|
file = "spec/examples/#{code.tr('-', '_')}.html"
|
293
299
|
File.write file, m.call(*args).read unless File.exist? file
|
294
300
|
File.read file
|
295
301
|
end.at_least :once
|
296
302
|
end
|
297
|
-
|