metanorma-iec 1.3.9 → 1.3.13
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/lib/asciidoctor/iec/basicdoc.rng +21 -4
- data/lib/asciidoctor/iec/front.rb +0 -4
- data/lib/asciidoctor/iec/isodoc.rng +241 -61
- data/lib/asciidoctor/iec/isostandard.rng +10 -23
- data/lib/asciidoctor/iec/reqt.rng +23 -2
- data/lib/isodoc/iec/html/isodoc.css +5 -3
- data/lib/isodoc/iec/html/isodoc.scss +5 -3
- data/lib/isodoc/iec/html/wordstyle.css +24 -0
- data/lib/isodoc/iec/html/wordstyle.scss +24 -0
- data/lib/isodoc/iec/iec.international-standard.xsl +435 -144
- 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
|