metanorma-iec 1.3.3 → 1.3.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -187,7 +187,7 @@ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INP
187
187
  <?xml version='1.0'?>
188
188
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
189
189
  <preface>
190
- <foreword>
190
+ <foreword displayorder="1">
191
191
  <p>
192
192
  <eref type='inline' bibitemid='IEV' citeas='IEV'>
193
193
  <locality type='clause'>
@@ -261,7 +261,7 @@ expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}).convert("test", <<~"INP
261
261
  </foreword>
262
262
  </preface>
263
263
  <bibliography>
264
- <references id='_normative_references' obligation='informative' normative='true'>
264
+ <references id='_normative_references' obligation='informative' normative='true' displayorder="2">
265
265
  <title depth='1'>
266
266
  1
267
267
  <tab/>
@@ -5,25 +5,29 @@ RSpec.describe IsoDoc do
5
5
  it "generates file based on string input" do
6
6
  FileUtils.rm_f "test.doc"
7
7
  FileUtils.rm_f "test.html"
8
- IsoDoc::Iec::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", filename: "test"}).convert("test", <<~"INPUT", false)
9
- <iso-standard xmlns="http://riboseinc.com/isoxml">
10
- <bibdata>
11
- <title>
12
- <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
13
- <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
14
- <title type="title-part" language="en" format="text/plain">Rice</title>
15
- </title>
16
- </bibdata>
17
- <preface><foreword>
18
- <note>
19
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
20
- </note>
21
- </foreword></preface>
22
- </iso-standard>
8
+ input = <<~INPUT
9
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
10
+ <bibdata>
11
+ <title>
12
+ <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
13
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
14
+ <title type="title-part" language="en" format="text/plain">Rice</title>
15
+ </title>
16
+ </bibdata>
17
+ <preface><foreword>
18
+ <note>
19
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
20
+ </note>
21
+ </foreword></preface>
22
+ </iso-standard>
23
23
  INPUT
24
+ IsoDoc::Iec::HtmlConvert
25
+ .new({ wordstylesheet: "spec/assets/word.css",
26
+ htmlstylesheet: "spec/assets/html.css", filename: "test" })
27
+ .convert("test", input, false)
24
28
  expect(File.exist?("test.html")).to be true
25
29
  html = File.read("test.html", encoding: "UTF-8")
26
- expect(html).to match(%r{<title>Cereals and pulses\&#xA0;\&#x2014; Specifications and test methods\&#xA0;\&#x2014; Rice</title>})
30
+ expect(html).to match(%r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>})
27
31
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
28
32
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
29
33
  end
@@ -31,25 +35,29 @@ RSpec.describe IsoDoc do
31
35
  it "generates HTML output docs with null configuration" do
32
36
  FileUtils.rm_f "test.doc"
33
37
  FileUtils.rm_f "test.html"
34
- IsoDoc::Iec::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
35
- <iso-standard xmlns="http://riboseinc.com/isoxml">
36
- <bibdata>
37
- <title>
38
- <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
39
- <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
40
- <title type="title-part" language="en" format="text/plain">Rice</title>
41
- </title>
42
- </bibdata>
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>
38
+ input = <<~INPUT
39
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
40
+ <bibdata>
41
+ <title>
42
+ <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
43
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
44
+ <title type="title-part" language="en" format="text/plain">Rice</title>
45
+ </title>
46
+ </bibdata>
47
+ <preface><foreword>
48
+ <note>
49
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
50
+ </note>
51
+ </foreword></preface>
52
+ </iso-standard>
49
53
  INPUT
54
+ IsoDoc::Iec::HtmlConvert
55
+ .new({ wordstylesheet: "spec/assets/word.css",
56
+ htmlstylesheet: "spec/assets/html.css" })
57
+ .convert("test", input, false)
50
58
  expect(File.exist?("test.html")).to be true
51
59
  html = File.read("test.html", encoding: "UTF-8")
52
- expect(html).to match(%r{<title>Cereals and pulses\&#xA0;\&#x2014; Specifications and test methods\&#xA0;\&#x2014; Rice</title>})
60
+ expect(html).to match(%r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>})
53
61
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
54
62
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
55
63
  end
@@ -57,15 +65,19 @@ RSpec.describe IsoDoc do
57
65
  it "generates Word output docs with null configuration" do
58
66
  FileUtils.rm_f "test.doc"
59
67
  FileUtils.rm_f "test.html"
60
- IsoDoc::Iec::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
61
- <iso-standard xmlns="http://riboseinc.com/isoxml">
62
- <preface><foreword>
63
- <note>
64
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
65
- </note>
66
- </foreword></preface>
67
- </iso-standard>
68
+ input = <<~INPUT
69
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
70
+ <preface><foreword>
71
+ <note>
72
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
73
+ </note>
74
+ </foreword></preface>
75
+ </iso-standard>
68
76
  INPUT
77
+ IsoDoc::Iec::WordConvert
78
+ .new({ wordstylesheet: "spec/assets/word.css",
79
+ htmlstylesheet: "spec/assets/html.css" })
80
+ .convert("test", input, false)
69
81
  expect(File.exist?("test.doc")).to be true
70
82
  word = File.read("test.doc", encoding: "UTF-8")
71
83
  expect(word).to match(/<style>/)
@@ -74,7 +86,9 @@ RSpec.describe IsoDoc do
74
86
  it "generates HTML output docs with null configuration from file" do
75
87
  FileUtils.rm_f "spec/assets/iso.doc"
76
88
  FileUtils.rm_f "spec/assets/iso.html"
77
- IsoDoc::Iec::HtmlConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.css"}).convert("spec/assets/iso.xml", nil, false)
89
+ IsoDoc::Iec::HtmlConvert
90
+ .new({ wordstylesheet: "word.css", htmlstylesheet: "html.css" })
91
+ .convert("spec/assets/iso.xml", nil, false)
78
92
  expect(File.exist?("spec/assets/iso.html")).to be true
79
93
  html = File.read("spec/assets/iso.html", encoding: "UTF-8")
80
94
  expect(html).to match(/<style>/)
@@ -84,198 +98,213 @@ RSpec.describe IsoDoc do
84
98
 
85
99
  it "generates Word output docs with null configuration from file" do
86
100
  FileUtils.rm_f "spec/assets/iso.doc"
87
- IsoDoc::Iec::WordConvert.new({wordstylesheet: "word.css", htmlstylesheet: "html.css"}).convert("spec/assets/iso.xml", nil, false)
101
+ IsoDoc::Iec::WordConvert
102
+ .new({ wordstylesheet: "word.css", htmlstylesheet: "html.css" })
103
+ .convert("spec/assets/iso.xml", nil, false)
88
104
  expect(File.exist?("spec/assets/iso.doc")).to be true
89
105
  word = File.read("spec/assets/iso.doc", encoding: "UTF-8")
90
106
  expect(word).to match(/<w:WordDocument>/)
91
107
  expect(word).to match(/<style>/)
92
108
  end
93
109
 
94
- it "generates Pdf output docs with null configuration from file" do
110
+ it "generates Pdf output docs with null configuration from file" do
95
111
  FileUtils.rm_f "spec/assets/iso.pdf"
96
- IsoDoc::Iec::PdfConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/assets/iso.xml", nil, false)
112
+ IsoDoc::Iec::PdfConvert
113
+ .new({ wordstylesheet: "spec/assets/word.css",
114
+ htmlstylesheet: "spec/assets/html.css" })
115
+ .convert("spec/assets/iso.xml", nil, false)
97
116
  expect(File.exist?("spec/assets/iso.pdf")).to be true
98
117
  end
99
118
 
100
119
  it "populates Word template with terms reference labels" do
101
120
  FileUtils.rm_f "test.doc"
102
121
  FileUtils.rm_f "test.html"
103
- IsoDoc::Iec::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
104
- <iso-standard xmlns="http://riboseinc.com/isoxml">
105
- <sections>
106
- <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
107
-
108
- <term id="paddy1">
109
- <name>1.1</name>
110
- <preferred>paddy</preferred>
111
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
112
- <termsource status="modified">
113
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
114
- <modification>
115
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
116
- </modification>
117
- </termsource></term>
118
-
119
- </terms>
120
- </sections>
121
- </iso-standard>
122
-
122
+ input = <<~INPUT
123
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
124
+ <sections>
125
+ <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
126
+ <term id="paddy1">
127
+ <name>1.1</name>
128
+ <preferred>paddy</preferred>
129
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
130
+ <termsource status="modified">
131
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
132
+ <modification>
133
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
134
+ </modification>
135
+ </termsource></term>
136
+ </terms>
137
+ </sections>
138
+ </iso-standard>
123
139
  INPUT
124
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
125
- sub(%r{<br.*$}m, "")
140
+ IsoDoc::Iec::WordConvert
141
+ .new({ wordstylesheet: "spec/assets/word.css",
142
+ htmlstylesheet: "spec/assets/html.css" })
143
+ .convert("test", input, false)
144
+ word = File.read("test.doc", encoding: "UTF-8")
145
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
146
+ .sub(%r{<br.*$}m, "")
126
147
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
127
- <div class="WordSection3">
128
- #{IEC_TITLE1.gsub(/\&#160;/, "&#xA0;")}
129
- <div><a name="_terms_and_definitions" id="_terms_and_definitions"></a><h1 class="main">1<span style="mso-tab-count:1">&#xA0; </span>Terms and Definitions</h1>
130
- <p class="TermNum"><a name="paddy1" id="paddy1"></a>1.1</p><p class="Terms" style="text-align:left;">paddy</p>
131
- <p class="MsoNormal"><a name="_eb29b35e-123e-4d1c-b50b-2714d41e747f" id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"></a>rice retaining its husk after threshing</p>
132
- <p class="MsoNormal">[SOURCE: <a href="#ISO7301">ISO 7301:2011, 3.1</a>, modified &#x2014; The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p></div>
133
- </div>
148
+ <div class="WordSection3">
149
+ #{IEC_TITLE1.gsub(/&#160;/, '&#xA0;')}
150
+ <div><a name="_terms_and_definitions" id="_terms_and_definitions"></a><h1 class="main">1<span style="mso-tab-count:1">&#xA0; </span>Terms and Definitions</h1>
151
+ <p class="TermNum"><a name="paddy1" id="paddy1"></a>1.1</p><p class="Terms" style="text-align:left;">paddy</p>
152
+ <p class="MsoNormal"><a name="_eb29b35e-123e-4d1c-b50b-2714d41e747f" id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"></a>rice retaining its husk after threshing</p>
153
+ <p class="MsoNormal">[SOURCE: <a href="#ISO7301">ISO 7301:2011, 3.1</a>, modified &#x2014; The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p></div>
154
+ </div>
134
155
  OUTPUT
135
156
  end
136
157
 
137
158
  it "processes IsoXML terms for HTML" do
138
159
  FileUtils.rm_f "test.html"
139
160
  FileUtils.rm_f "test.doc"
140
- IsoDoc::Iec::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
141
- <iso-standard xmlns="http://riboseinc.com/isoxml">
142
- <sections>
143
- <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
144
-
145
- <term id="paddy1">
146
- <name>1.1</name>
147
- <preferred>paddy</preferred>
148
- <domain>rice</domain>
149
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
150
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
151
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
152
- <ul>
153
- <li>A</li>
154
- </ul>
155
- </termexample>
156
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
157
- <ul>
158
- <li>A</li>
159
- </ul>
160
- </termexample>
161
-
162
- <termsource status="modified">
163
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
164
- <modification>
165
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
166
- </modification>
167
- </termsource></term>
168
-
169
- <term id="paddy">
170
- <name>1.2</name>
171
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
172
- <admitted>rough rice</admitted>
173
- <deprecates>cargo rice</deprecates>
174
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
175
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
176
- <ul>
177
- <li>A</li>
178
- </ul>
179
- </termexample>
180
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
181
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
182
- </termnote>
183
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
184
- <ul><li>A</li></ul>
185
- <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
186
- </termnote>
187
- <termsource status="identical">
188
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
189
- </termsource></term>
190
- </terms>
191
- </sections>
192
- </iso-standard>
161
+ input = <<~INPUT
162
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
163
+ <sections>
164
+ <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
165
+ <term id="paddy1">
166
+ <name>1.1</name>
167
+ <preferred>paddy</preferred>
168
+ <domain>rice</domain>
169
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
170
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
171
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
172
+ <ul>
173
+ <li>A</li>
174
+ </ul>
175
+ </termexample>
176
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
177
+ <ul>
178
+ <li>A</li>
179
+ </ul>
180
+ </termexample>
181
+ <termsource status="modified">
182
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
183
+ <modification>
184
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
185
+ </modification>
186
+ </termsource></term>
187
+ <term id="paddy">
188
+ <name>1.2</name>
189
+ <preferred>paddy</preferred><admitted>paddy rice</admitted>
190
+ <admitted>rough rice</admitted>
191
+ <deprecates>cargo rice</deprecates>
192
+ <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
193
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
194
+ <ul>
195
+ <li>A</li>
196
+ </ul>
197
+ </termexample>
198
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
199
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
200
+ </termnote>
201
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
202
+ <ul><li>A</li></ul>
203
+ <p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
204
+ </termnote>
205
+ <termsource status="identical">
206
+ <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
207
+ </termsource></term>
208
+ </terms>
209
+ </sections>
210
+ </iso-standard>
193
211
  INPUT
212
+ IsoDoc::Iec::HtmlConvert
213
+ .new({ wordstylesheet: "spec/assets/word.css",
214
+ htmlstylesheet: "spec/assets/html.css" })
215
+ .convert("test", input, false)
194
216
  expect(File.exist?("test.html")).to be true
195
217
  html = File.read("test.html", encoding: "UTF-8")
196
218
  expect(html).to match(%r{<h2 class="TermNum" id="paddy1">1\.1</h2>})
197
219
  expect(html).to match(%r{<h2 class="TermNum" id="paddy">1\.2</h2>})
198
220
  end
199
221
 
200
- it "inserts default paragraph between two tables for Word" do
222
+ it "inserts default paragraph between two tables for Word" do
201
223
  FileUtils.rm_f "test.doc"
202
224
  FileUtils.rm_f "test.html"
203
- IsoDoc::Iec::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
204
- <iso-standard xmlns="http://riboseinc.com/isoxml">
205
- <annex id="P" inline-header="false" obligation="normative">
206
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
207
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
208
- </example>
209
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
210
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
211
- </example>
212
- </annex>
213
- </iso-standard>
225
+ input = <<~INPUT
226
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
227
+ <annex id="P" inline-header="false" obligation="normative">
228
+ <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
229
+ <p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
230
+ </example>
231
+ <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
232
+ <p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
233
+ </example>
234
+ </annex>
235
+ </iso-standard>
214
236
  INPUT
215
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
216
- sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
237
+ IsoDoc::Iec::WordConvert
238
+ .new({ wordstylesheet: "spec/assets/word.css",
239
+ htmlstylesheet: "spec/assets/html.css" })
240
+ .convert("test", input, false)
241
+ word = File.read("test.doc", encoding: "UTF-8")
242
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
243
+ .sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
217
244
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
218
- <div class="WordSection3">
219
- #{IEC_TITLE1.gsub(/\&#160;/, "&#xA0;")}
220
- <p class="MsoNormal">
221
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
222
- </p>
223
- <div class="Section3"><a name="P" id="P"></a>
224
- <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851c" id="_63112cbc-cde0-435f-9553-e0b8c4f5851c"></a>
225
- <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
226
- </div>
227
- <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851d" id="_63112cbc-cde0-435f-9553-e0b8c4f5851d"></a>
228
- <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
245
+ <div class="WordSection3">
246
+ #{IEC_TITLE1.gsub(/&#160;/, '&#xA0;')}
247
+ <p class="MsoNormal">
248
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
249
+ </p>
250
+ <div class="Section3"><a name="P" id="P"></a>
251
+ <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851c" id="_63112cbc-cde0-435f-9553-e0b8c4f5851c"></a>
252
+ <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
253
+ </div>
254
+ <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851d" id="_63112cbc-cde0-435f-9553-e0b8c4f5851d"></a>
255
+ <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
256
+ </div>
229
257
  </div>
230
258
  </div>
231
- </div>
232
259
  OUTPUT
233
260
  end
234
261
 
235
- it "processes source code in tables (Word)" do
236
- FileUtils.rm_f "test.doc"
262
+ it "processes source code in tables (Word)" do
263
+ FileUtils.rm_f "test.doc"
237
264
  FileUtils.rm_f "test.html"
238
- IsoDoc::Iec::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
239
- <iso-standard xmlns="http://riboseinc.com/isoxml">
240
- <annex id="P" inline-header="false" obligation="normative">
241
- <sourcecode lang="ruby" id="A">puts "Hello, world."</sourcecode>
242
- <table id="samplecode">
243
- <tbody>
244
- <tr><td>
245
- <sourcecode lang="ruby" id="B">puts "Hello, world."</sourcecode>
246
- </td></tr>
247
- </tbody>
248
- </table>
249
- </annex>
250
- </iso-standard>
265
+ input = <<~INPUT
266
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
267
+ <annex id="P" inline-header="false" obligation="normative">
268
+ <sourcecode lang="ruby" id="A">puts "Hello, world."</sourcecode>
269
+ <table id="samplecode">
270
+ <tbody>
271
+ <tr><td>
272
+ <sourcecode lang="ruby" id="B">puts "Hello, world."</sourcecode>
273
+ </td></tr>
274
+ </tbody>
275
+ </table>
276
+ </annex>
277
+ </iso-standard>
251
278
  INPUT
252
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
253
- sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
279
+ IsoDoc::Iec::WordConvert
280
+ .new({ wordstylesheet: "spec/assets/word.css",
281
+ htmlstylesheet: "spec/assets/html.css" })
282
+ .convert("test", input, false)
283
+ word = File.read("test.doc", encoding: "UTF-8")
284
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
285
+ .sub(%r{<br[^>]*>\s*<div class="colophon">.*$}m, "")
254
286
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
255
- <div class="WordSection3">
256
- #{IEC_TITLE1.gsub(/\&#160;/, "&#xA0;")}
257
- <p class="MsoNormal">
258
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
259
- </p>
260
- <div class="Section3"><a name="P" id="P"></a>
261
- <p class="Sourcecode"><a name="A" id="A"></a>puts "Hello, world."</p>
262
- <div align='center' class='table_container'>
263
- <table class='MsoISOTable' style='mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;'>
264
- <a name='samplecode' id='samplecode'/>
265
- <tbody>
266
- <tr>
267
- <td style="border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;" class="TABLE-cell">
268
- <p class="CODE-TableCell"><a name="B" id="B"></a>puts "Hello, world."</p>
269
- </td>
270
- </tr>
271
- </tbody>
272
- </table>
287
+ <div class="WordSection3">
288
+ #{IEC_TITLE1.gsub(/&#160;/, '&#xA0;')}
289
+ <p class="MsoNormal">
290
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
291
+ </p>
292
+ <div class="Section3"><a name="P" id="P"></a>
293
+ <p class="Sourcecode"><a name="A" id="A"></a>puts "Hello, world."</p>
294
+ <div align='center' class='table_container'>
295
+ <table class='MsoISOTable' style='mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;'>
296
+ <a name='samplecode' id='samplecode'/>
297
+ <tbody>
298
+ <tr>
299
+ <td style="border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;" class="TABLE-cell">
300
+ <p class="CODE-TableCell"><a name="B" id="B"></a>puts "Hello, world."</p>
301
+ </td>
302
+ </tr>
303
+ </tbody>
304
+ </table>
305
+ </div>
273
306
  </div>
274
307
  </div>
275
- </div>
276
308
  OUTPUT
277
- end
278
-
279
-
280
-
309
+ end
281
310
  end