metanorma-iec 1.3.8 → 1.3.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,7 +24,7 @@ module Metanorma
24
24
  "Times New Roman" => nil,
25
25
  "STIX Two Math" => nil,
26
26
  "Source Han Sans" => nil,
27
- "Courier" => nil,
27
+ "Source Han Sans Normal" => nil,
28
28
  "Courier New" => nil,
29
29
  }
30
30
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.3.8".freeze
3
+ VERSION = "1.3.12".freeze
4
4
  end
5
5
  end
6
6
 
@@ -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({}).convert("test", <<~"INPUT", false)
8
- <iso-standard xmlns="http://riboseinc.com/isoxml">
9
- <preface><foreword>
10
- <note>
11
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
12
- </note>
13
- </foreword></preface>
14
- </iso-standard>
15
- INPUT
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
- FileUtils.rm_f "test.html"
24
- IsoDoc::Iec::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
25
- <iso-standard xmlns="http://riboseinc.com/isoxml">
26
- <preface><foreword>
27
- <note>
28
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
29
- </note>
30
- </foreword></preface>
31
- </iso-standard>
32
- INPUT
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
- FileUtils.rm_f "test.html"
41
- IsoDoc::Iec::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
42
- <iso-standard xmlns="http://riboseinc.com/isoxml">
43
- <preface><foreword>
44
- <note>
45
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
46
- </note>
47
- </foreword></preface>
48
- </iso-standard>
49
- INPUT
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
- FileUtils.rm_f "test.doc"
58
- IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", false)
59
- <iso-standard xmlns="http://riboseinc.com/isoxml">
60
- <preface><foreword>
61
- <note>
62
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
63
- </note>
64
- </foreword></preface>
65
- </iso-standard>
66
- INPUT
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
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
75
- <iso-standard xmlns="http://riboseinc.com/isoxml">
76
- <preface><foreword>
77
- <example id="samplecode">
78
- <name>EXAMPLE</name>
79
- <p>Hello</p>
80
- </example>
81
- </foreword></preface>
82
- </iso-standard>
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
- #{HTML_HDR}
85
- <div>
86
- <h1 class="ForewordTitle">FOREWORD</h1>
87
- <div class="boilerplate_legal"/>
88
- <div id="samplecode" class="example">
89
- <p><span class="example_label">EXAMPLE</span>&#160; Hello</p>
90
- </div>
91
- </div>
92
- #{IEC_TITLE1}
93
- </div>
94
- </body>
95
- </html>
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>&#160; Hello</p>
97
+ </div>
98
+ </div>
99
+ #{IEC_TITLE1}
100
+ </div>
101
+ </body>
102
+ </html>
96
103
  OUTPUT
97
- end
98
-
99
-
100
- it "processes sequences of examples" do
101
- expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
102
- <iso-standard xmlns="http://riboseinc.com/isoxml">
103
- <preface><foreword>
104
- <example id="samplecode">
105
- <name>EXAMPLE 1</name>
106
- <p>Hello</p>
107
- </example>
108
- <example id="samplecode2">
109
- <name>EXAMPLE 2</name>
110
- <p>Hello</p>
111
- </example>
112
- </foreword></preface>
113
- </iso-standard>
114
- INPUT
115
- #{HTML_HDR}
116
- <div>
117
- <h1 class="ForewordTitle">FOREWORD</h1>
118
- <div class="boilerplate_legal"/>
119
- <div id="samplecode" class="example">
120
- <p><span class="example_label">EXAMPLE 1</span>&#160; Hello</p>
121
- </div>
122
- <div id="samplecode2" class="example">
123
- <p><span class="example_label">EXAMPLE 2</span>&#160; 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">&#160; </span>Hello</p>
116
+ </div>
117
+ </div>
118
+ <p>&#160;</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
- it "processes examples (Word)" do
134
- 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")
135
- <iso-standard xmlns="http://riboseinc.com/isoxml">
136
- <preface><foreword>
137
- <example id="samplecode">
138
- <name>EXAMPLE</name>
139
- <p>Hello</p>
140
- </example>
141
- </foreword></preface>
142
- </iso-standard>
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
- <body lang="EN-US" link="blue" vlink="#954F72">
145
- <div class="WordSection2">
146
- <p>
147
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
148
- </p>
149
- #{IEC_TITLE}
150
- <div>
151
- <h1 class="ForewordTitle">FOREWORD</h1>
152
- <div class="boilerplate_legal"/>
153
- <div id="samplecode" class="example">
154
- <p><span class="example_label">EXAMPLE</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
155
- </div>
156
- </div>
157
- <p>&#160;</p>
158
- </div>
159
- <p>
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>&#160; Hello</p>
162
+ </div>
163
+ <div id="samplecode2" class="example">
164
+ <p><span class="example_label">EXAMPLE 2</span>&#160; Hello</p>
165
+ </div>
166
+ </div>
167
+ #{IEC_TITLE1}
168
+ </div>
169
+ </body>
170
+ </html>
168
171
  OUTPUT
169
- end
170
-
171
172
 
172
- it "processes sequences of examples (Word)" do
173
- 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")
174
- <iso-standard xmlns="http://riboseinc.com/isoxml">
175
- <preface><foreword>
176
- <example id="samplecode">
177
- <name>EXAMPLE 1</name>
178
- <p>Hello</p>
179
- </example>
180
- <example id="samplecode2">
181
- <name>EXAMPLE 2</name>
182
- <p>Hello</p>
183
- </example>
184
- </foreword></preface>
185
- </iso-standard>
186
- INPUT
187
- <body lang="EN-US" link="blue" vlink="#954F72">
188
- <div class="WordSection2">
189
- <p>
190
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
191
- </p>
192
- #{IEC_TITLE}
193
- <div>
194
- <h1 class="ForewordTitle">FOREWORD</h1>
195
- <div class="boilerplate_legal"/>
196
- <div id="samplecode" class="example">
197
- <p><span class="example_label">EXAMPLE 1</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
198
- </div>
199
- <div id="samplecode2" class="example">
200
- <p><span class="example_label">EXAMPLE 2</span><span style="mso-tab-count:1">&#160; </span>Hello</p>
201
- </div>
202
- </div>
203
- <p>&#160;</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">&#160; </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">&#160; </span>Hello</p>
188
+ </div>
189
+ </div>
190
+ <p>&#160;</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