metanorma-iso 1.8.1 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -8
  5. data/lib/asciidoctor/iso/base.rb +1 -0
  6. data/lib/asciidoctor/iso/biblio.rng +1 -0
  7. data/lib/asciidoctor/iso/cleanup.rb +17 -5
  8. data/lib/asciidoctor/iso/front.rb +3 -1
  9. data/lib/asciidoctor/iso/front_id.rb +66 -50
  10. data/lib/asciidoctor/iso/isodoc.rng +209 -4
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +3 -0
  12. data/lib/asciidoctor/iso/isostandard.rng +12 -0
  13. data/lib/asciidoctor/iso/section.rb +2 -1
  14. data/lib/asciidoctor/iso/validate_section.rb +16 -9
  15. data/lib/isodoc/iso/base_convert.rb +13 -13
  16. data/lib/isodoc/iso/html/isodoc.css +475 -20
  17. data/lib/isodoc/iso/html/isodoc.scss +456 -23
  18. data/lib/isodoc/iso/html/wordstyle.css +202 -31
  19. data/lib/isodoc/iso/html/wordstyle.scss +194 -32
  20. data/lib/isodoc/iso/iso.amendment.xsl +679 -473
  21. data/lib/isodoc/iso/iso.international-standard.xsl +679 -473
  22. data/lib/isodoc/iso/metadata.rb +3 -2
  23. data/lib/isodoc/iso/presentation_xml_convert.rb +18 -9
  24. data/lib/isodoc/iso/sts_convert.rb +10 -13
  25. data/lib/isodoc/iso/word_convert.rb +153 -39
  26. data/lib/isodoc/iso/xref.rb +42 -27
  27. data/lib/metanorma/iso/version.rb +1 -1
  28. data/metanorma-iso.gemspec +4 -4
  29. data/spec/asciidoctor/base_spec.rb +426 -334
  30. data/spec/asciidoctor/blocks_spec.rb +96 -34
  31. data/spec/asciidoctor/cleanup_spec.rb +383 -25
  32. data/spec/asciidoctor/section_spec.rb +0 -14
  33. data/spec/asciidoctor/validate_spec.rb +119 -39
  34. data/spec/isodoc/amd_spec.rb +193 -201
  35. data/spec/isodoc/blocks_spec.rb +100 -88
  36. data/spec/isodoc/i18n_spec.rb +36 -36
  37. data/spec/isodoc/inline_spec.rb +282 -2
  38. data/spec/isodoc/iso_spec.rb +86 -138
  39. data/spec/isodoc/postproc_spec.rb +492 -442
  40. data/spec/isodoc/ref_spec.rb +6 -6
  41. data/spec/isodoc/section_spec.rb +301 -306
  42. data/spec/isodoc/table_spec.rb +166 -231
  43. data/spec/isodoc/terms_spec.rb +11 -8
  44. data/spec/isodoc/xref_spec.rb +147 -118
  45. data/spec/spec_helper.rb +16 -15
  46. metadata +9 -9
@@ -25,80 +25,86 @@ WORD_HTML_CSS_WORDINTRO = {
25
25
 
26
26
  RSpec.describe IsoDoc do
27
27
  it "generates file based on string input" do
28
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.merge(filename: "test")).convert("test", <<~"INPUT", false)
29
- <iso-standard xmlns="http://riboseinc.com/isoxml">
30
- <bibdata>
31
- <title>
32
- <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
33
- <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
34
- <title format="text/plain" language="en" type="title-part">Rice</title>
35
- </title>
36
- </bibdata>
37
- <preface>
38
- <foreword>
39
- <note>
40
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
41
- </note>
42
- </foreword>
43
- </preface>
44
- </iso-standard>
28
+ IsoDoc::Iso::HtmlConvert
29
+ .new(WORD_HTML_CSS.merge(filename: "test"))
30
+ .convert("test", <<~"INPUT", false)
31
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
32
+ <bibdata>
33
+ <title>
34
+ <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
35
+ <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
36
+ <title format="text/plain" language="en" type="title-part">Rice</title>
37
+ </title>
38
+ </bibdata>
39
+ <preface>
40
+ <foreword>
41
+ <note>
42
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
43
+ </note>
44
+ </foreword>
45
+ </preface>
46
+ </iso-standard>
45
47
  INPUT
46
48
  expect(File.exist?("test.html")).to be true
47
49
  html = File.read("test.html", encoding: "UTF-8")
48
- expect(html).to match(
49
- %r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>}
50
- )
50
+ expect(html).to include "<title>Cereals and pulses&#xA0;&#x2014; "\
51
+ "Specifications and test methods&#xA0;&#x2014; Rice</title>"
51
52
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
52
53
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
53
54
  end
54
55
 
55
56
  it "generates HTML output docs with null configuration" do
56
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
57
- <iso-standard xmlns="http://riboseinc.com/isoxml">
58
- <bibdata>
59
- <title>
60
- <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
61
- <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
62
- <title format="text/plain" language="en" type="title-part">Rice</title>
63
- </title>
64
- </bibdata>
65
- <preface>
66
- <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>
71
- </preface>
72
- </iso-standard>
73
- INPUT
57
+ IsoDoc::Iso::HtmlConvert
58
+ .new(WORD_HTML_CSS.dup)
59
+ .convert("test", <<~"INPUT", false)
60
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
61
+ <bibdata>
62
+ <title>
63
+ <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
64
+ <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
65
+ <title format="text/plain" language="en" type="title-part">Rice</title>
66
+ </title>
67
+ </bibdata>
68
+ <preface>
69
+ <foreword>
70
+ <note>
71
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
72
+ </note>
73
+ </foreword>
74
+ </preface>
75
+ </iso-standard>
76
+ INPUT
74
77
  expect(File.exist?("test.html")).to be true
75
78
  html = File.read("test.html", encoding: "UTF-8")
76
- expect(html).to match(
77
- %r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>}
78
- )
79
+ expect(html).to include "title>Cereals and pulses&#xA0;&#x2014; "\
80
+ "Specifications and test methods&#xA0;&#x2014; Rice</title>"
79
81
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
80
82
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
81
83
  end
82
84
 
83
85
  it "generates Word output docs with null configuration" do
84
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
85
- <iso-standard xmlns="http://riboseinc.com/isoxml">
86
- <preface>
87
- <foreword>
88
- <note>
89
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
90
- </note>
91
- </foreword>
92
- </preface>
93
- </iso-standard>
94
- INPUT
86
+ IsoDoc::Iso::WordConvert
87
+ .new(WORD_HTML_CSS.dup)
88
+ .convert("test", <<~"INPUT", false)
89
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
90
+ <preface>
91
+ <foreword>
92
+ <note>
93
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
94
+ </note>
95
+ </foreword>
96
+ </preface>
97
+ </iso-standard>
98
+ INPUT
95
99
  expect(File.exist?("test.doc")).to be true
96
100
  word = File.read("test.doc", encoding: "UTF-8")
97
101
  expect(word).to match(/<style>/)
98
102
  end
99
103
 
100
104
  it "generates HTML output docs with null configuration from file" do
101
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS_SUBDIR.dup).convert("spec/assets/iso.xml", nil, false)
105
+ IsoDoc::Iso::HtmlConvert
106
+ .new(WORD_HTML_CSS_SUBDIR.dup)
107
+ .convert("spec/assets/iso.xml", nil, false)
102
108
  expect(File.exist?("spec/assets/iso.html")).to be true
103
109
  html = File.read("spec/assets/iso.html", encoding: "UTF-8")
104
110
  expect(html).to match(/<style>/)
@@ -107,7 +113,9 @@ RSpec.describe IsoDoc do
107
113
  end
108
114
 
109
115
  it "generates Word output docs with null configuration from file" do
110
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_SUBDIR.dup).convert("spec/assets/iso.xml", nil, false)
116
+ IsoDoc::Iso::WordConvert
117
+ .new(WORD_HTML_CSS_SUBDIR.dup)
118
+ .convert("spec/assets/iso.xml", nil, false)
111
119
  expect(File.exist?("spec/assets/iso.doc")).to be true
112
120
  word = File.read("spec/assets/iso.doc", encoding: "UTF-8")
113
121
  expect(word).to match(/<w:WordDocument>/)
@@ -116,28 +124,35 @@ RSpec.describe IsoDoc do
116
124
 
117
125
  it "generates Pdf output docs with null configuration from file" do
118
126
  mock_pdf
119
- IsoDoc::Iso::PdfConvert.new(WORD_HTML_CSS.dup).convert("spec/assets/iso.xml", nil, false)
127
+ IsoDoc::Iso::PdfConvert
128
+ .new(WORD_HTML_CSS.dup)
129
+ .convert("spec/assets/iso.xml", nil, false)
120
130
  expect(File.exist?("spec/assets/iso.pdf")).to be true
121
131
  end
122
132
 
123
133
  it "converts annex subheadings to h2Annex class for Word" do
124
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
125
- <iso-standard xmlns="http://riboseinc.com/isoxml">
126
- <annex id="P" inline-header="false" obligation="normative">
127
- <title>Annex</title>
128
- <clause id="Q" inline-header="false" obligation="normative">
129
- <title>A.1
130
- <tab/>
131
- Annex A.1</title>
132
- </clause>
133
- <appendix id="Q2" inline-header="false" obligation="normative">
134
- <title>Appendix 1
135
- <tab/>
136
- An Appendix</title>
137
- </appendix>
138
- </annex>
139
- </iso-standard>
140
- INPUT
134
+ IsoDoc::Iso::WordConvert
135
+ .new(WORD_HTML_CSS.dup)
136
+ .convert("test", <<~"INPUT", false)
137
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
138
+ <annex id="P" inline-header="false" obligation="normative">
139
+ <title>Annex</title>
140
+ <clause id="Q" inline-header="false" obligation="normative">
141
+ <title>A.1
142
+ <tab/>
143
+ Annex A.1</title>
144
+ </clause>
145
+ <appendix id="Q2" inline-header="false" obligation="normative">
146
+ <title>Appendix 1
147
+ <tab/>
148
+ An Appendix</title>
149
+ </appendix>
150
+ </annex>
151
+ <bibliography>
152
+ <references id="R" normative="false"><title>Bibliography</title></references>
153
+ </bibliography>
154
+ </iso-standard>
155
+ INPUT
141
156
 
142
157
  word = File.read("test.doc", encoding: "UTF-8")
143
158
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
@@ -151,7 +166,7 @@ RSpec.describe IsoDoc do
151
166
  </p>
152
167
  <div class="Section3">
153
168
  <a id="P" name="P"/>
154
- <h1 class="Annex">Annex</h1>
169
+ <p class="ANNEX">Annex</p>
155
170
  <div>
156
171
  <a id="Q" name="Q"/>
157
172
  <p class="h2Annex">A.1
@@ -165,38 +180,46 @@ RSpec.describe IsoDoc do
165
180
  An Appendix</p>
166
181
  </div>
167
182
  </div>
183
+ <p class='MsoNormal'>
184
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
185
+ </p>
186
+ <div>
187
+ <p class='BiblioTitle'>Bibliography</p>
188
+ </div>
168
189
  </div>
169
190
  OUTPUT
170
191
  end
171
192
 
172
193
  it "populates Word template with terms reference labels" do
173
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
174
- <iso-standard xmlns="http://riboseinc.com/isoxml">
175
- <sections>
176
- <terms id="_terms_and_definitions" obligation="normative">
177
- <title>1
178
- <tab/>
179
- Terms and Definitions</title>
180
- <term id="paddy1">
181
- <name>1.1</name>
182
- <preferred>paddy</preferred>
183
- <definition>
184
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
185
- </definition>
186
- <termsource status="modified">
187
- <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
188
- <locality type="clause">
189
- <referenceFrom>3.1</referenceFrom>
190
- </locality>ISO 7301:2011, 3.1</origin>
191
- <modification>
192
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here</p>
193
- </modification>
194
- </termsource>
195
- </term>
196
- </terms>
197
- </sections>
198
- </iso-standard>
199
- INPUT
194
+ IsoDoc::Iso::WordConvert
195
+ .new(WORD_HTML_CSS.dup)
196
+ .convert("test", <<~"INPUT", false)
197
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
198
+ <sections>
199
+ <terms id="_terms_and_definitions" obligation="normative">
200
+ <title>1
201
+ <tab/>
202
+ Terms and Definitions</title>
203
+ <term id="paddy1">
204
+ <name>1.1</name>
205
+ <preferred>paddy</preferred>
206
+ <definition>
207
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
208
+ </definition>
209
+ <termsource status="modified">
210
+ <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
211
+ <locality type="clause">
212
+ <referenceFrom>3.1</referenceFrom>
213
+ </locality>ISO 7301:2011, 3.1</origin>
214
+ <modification>
215
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here</p>
216
+ </modification>
217
+ </termsource>
218
+ </term>
219
+ </terms>
220
+ </sections>
221
+ </iso-standard>
222
+ INPUT
200
223
 
201
224
  word = File.read("test.doc", encoding: "UTF-8")
202
225
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
@@ -213,9 +236,9 @@ RSpec.describe IsoDoc do
213
236
  <p class="TermNum">
214
237
  <a id="paddy1" name="paddy1"/>1.1</p>
215
238
  <p class="Terms" style="text-align:left;">paddy</p>
216
- <p class="MsoNormal">
239
+ <p class="Definition">
217
240
  <a id="_eb29b35e-123e-4d1c-b50b-2714d41e747f" name="_eb29b35e-123e-4d1c-b50b-2714d41e747f"/>rice retaining its husk after threshing</p>
218
- <p class="MsoNormal">[SOURCE:
241
+ <p class="Source">[SOURCE:
219
242
  <a href="#ISO7301">ISO 7301:2011, 3.1</a>
220
243
  , modified — The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here]</p>
221
244
  </div>
@@ -224,139 +247,145 @@ RSpec.describe IsoDoc do
224
247
  end
225
248
 
226
249
  it "populates Word header" do
227
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_HEADER_HTML.dup).convert("test", <<~"INPUT", false)
228
- <iso-standard xmlns="http://riboseinc.com/isoxml">
229
- <bibdata type="article">
230
- <docidentifier>
231
- <project-number part="1">1000</project-number>
232
- </docidentifier>
233
- </bibdata>
234
- </iso-standard>
235
- INPUT
250
+ IsoDoc::Iso::WordConvert
251
+ .new(WORD_HTML_CSS_HEADER_HTML.dup)
252
+ .convert("test", <<~"INPUT", false)
253
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
254
+ <bibdata type="article">
255
+ <docidentifier>
256
+ <project-number part="1">1000</project-number>
257
+ </docidentifier>
258
+ </bibdata>
259
+ </iso-standard>
260
+ INPUT
236
261
  word = File.read("test.doc", encoding: "UTF-8")
237
262
  expect(word).to include('Content-Disposition: inline; filename="header.html"')
238
263
  end
239
264
 
240
265
  it "populates Word ToC" do
241
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", <<~"INPUT", false)
242
- <iso-standard xmlns="http://riboseinc.com/isoxml">
243
- <sections>
244
- <clause id="A" inline-header="false" obligation="normative">
245
- <title>1
246
- <tab/>
247
- Clause 4</title>
248
- <clause id="N" inline-header="false" obligation="normative">
249
- <title>1.1
266
+ IsoDoc::Iso::WordConvert
267
+ .new(WORD_HTML_CSS_WORDINTRO.dup)
268
+ .convert("test", <<~"INPUT", false)
269
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
270
+ <sections>
271
+ <clause id="A" inline-header="false" obligation="normative">
272
+ <title>1
250
273
  <tab/>
251
- Introduction
252
- <bookmark id="Q"/>
253
- to this
254
- <fn reference="1">
255
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
256
- </title>
257
- </clause>
258
- <clause id="O" inline-header="false" obligation="normative">
259
- <title>1.2
260
- <tab/>
261
- Clause 4.2</title>
262
- <p>A
263
- <fn reference="1">
264
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
265
- </p>
274
+ Clause 4</title>
275
+ <clause id="N" inline-header="false" obligation="normative">
276
+ <title>1.1
277
+ <tab/>
278
+ Introduction
279
+ <bookmark id="Q"/>
280
+ to this
281
+ <fn reference="1">
282
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
283
+ </title>
284
+ </clause>
285
+ <clause id="O" inline-header="false" obligation="normative">
286
+ <title>1.2
287
+ <tab/>
288
+ Clause 4.2</title>
289
+ <p>A
290
+ <fn reference="1">
291
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
292
+ </p>
293
+ </clause>
266
294
  </clause>
267
- </clause>
268
- </sections>
269
- </iso-standard>
270
- INPUT
295
+ </sections>
296
+ </iso-standard>
297
+ INPUT
271
298
 
272
299
  word = File.read("test.doc", encoding: "UTF-8")
273
300
  .sub(/^.*An empty word intro page\./m, "")
274
301
  .sub(%r{</div>.*$}m, "</div>")
275
302
 
276
- expect(xmlpp("<div>#{word.gsub(/_Toc\d\d+/, '_Toc')}")).to be_equivalent_to xmlpp(<<~'OUTPUT')
277
- <div>
278
- <p class="MsoToc1">
279
- <span lang="EN-GB" xml:lang="EN-GB">
280
- <span style="mso-element:field-begin"/>
281
- <span style="mso-spacerun:yes"> </span>TOC
282
- \o &quot;1-3&quot; \h \z \u
283
- <span style="mso-element:field-separator"/></span>
284
- <span class="MsoHyperlink">
285
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
286
- <a href="#_Toc">1 Clause 4
287
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
288
- <span style="mso-tab-count:1 dotted">. </span></span>
289
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
290
- <span style="mso-element:field-begin"/>
291
- </span>
292
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
293
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
294
- <span style="mso-element:field-separator"/>
295
- </span>
296
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
297
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
298
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
299
- <span style="mso-element:field-end"/>
300
- </span>
301
- </a>
303
+ expect(xmlpp("<div>#{word.gsub(/_Toc\d\d+/, '_Toc')}"))
304
+ .to be_equivalent_to xmlpp(<<~'OUTPUT')
305
+ <div>
306
+ <p class="MsoToc1">
307
+ <span lang="EN-GB" xml:lang="EN-GB">
308
+ <span style="mso-element:field-begin"/>
309
+ <span style='mso-spacerun:yes'>&#xA0;</span>
310
+ TOC \o "1-3" \h \z \t "Heading 1;1;ANNEX;1;Biblio Title;1;Foreword
311
+ Title;1;Intro Title;1"
312
+ <span style="mso-element:field-separator"/></span>
313
+ <span class="MsoHyperlink">
314
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
315
+ <a href="#_Toc">1 Clause 4
316
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
317
+ <span style="mso-tab-count:1 dotted">. </span></span>
318
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
319
+ <span style="mso-element:field-begin"/>
320
+ </span>
321
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
322
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
323
+ <span style="mso-element:field-separator"/>
324
+ </span>
325
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
326
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
327
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
328
+ <span style="mso-element:field-end"/>
329
+ </span>
330
+ </a>
331
+ </span>
302
332
  </span>
303
- </span>
304
- </p>
305
- <p class="MsoToc2">
306
- <span class="MsoHyperlink">
307
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
308
- <a href="#_Toc">1.1 Introduction to this
309
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
310
- <span style="mso-tab-count:1 dotted">. </span></span>
311
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
312
- <span style="mso-element:field-begin"/>
313
- </span>
314
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
315
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
316
- <span style="mso-element:field-separator"/>
317
- </span>
318
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
319
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
320
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
321
- <span style="mso-element:field-end"/>
322
- </span>
323
- </a>
333
+ </p>
334
+ <p class="MsoToc2">
335
+ <span class="MsoHyperlink">
336
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
337
+ <a href="#_Toc">1.1 Introduction to this
338
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
339
+ <span style="mso-tab-count:1 dotted">. </span></span>
340
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
341
+ <span style="mso-element:field-begin"/>
342
+ </span>
343
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
344
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
345
+ <span style="mso-element:field-separator"/>
346
+ </span>
347
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
348
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
349
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
350
+ <span style="mso-element:field-end"/>
351
+ </span>
352
+ </a>
353
+ </span>
324
354
  </span>
325
- </span>
326
- </p>
327
- <p class="MsoToc2">
328
- <span class="MsoHyperlink">
329
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
330
- <a href="#_Toc">1.2 Clause 4.2
331
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
332
- <span style="mso-tab-count:1 dotted">. </span></span>
333
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
334
- <span style="mso-element:field-begin"/>
335
- </span>
336
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
337
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
338
- <span style="mso-element:field-separator"/>
339
- </span>
340
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
341
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
342
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
343
- <span style="mso-element:field-end"/>
344
- </span>
345
- </a>
355
+ </p>
356
+ <p class="MsoToc2">
357
+ <span class="MsoHyperlink">
358
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
359
+ <a href="#_Toc">1.2 Clause 4.2
360
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
361
+ <span style="mso-tab-count:1 dotted">. </span></span>
362
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
363
+ <span style="mso-element:field-begin"/>
364
+ </span>
365
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
366
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
367
+ <span style="mso-element:field-separator"/>
368
+ </span>
369
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
370
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
371
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
372
+ <span style="mso-element:field-end"/>
373
+ </span>
374
+ </a>
375
+ </span>
346
376
  </span>
347
- </span>
348
- </p>
349
- <p class="MsoToc1">
350
- <span lang="EN-GB" xml:lang="EN-GB">
351
- <span style="mso-element:field-end"/>
352
- </span>
353
- <span lang="EN-GB" xml:lang="EN-GB">
354
- <p class="MsoNormal"> </p>
355
- </span>
356
- </p>
357
- <p class="MsoNormal"> </p>
358
- </div>
359
- OUTPUT
377
+ </p>
378
+ <p class="MsoToc1">
379
+ <span lang="EN-GB" xml:lang="EN-GB">
380
+ <span style="mso-element:field-end"/>
381
+ </span>
382
+ <span lang="EN-GB" xml:lang="EN-GB">
383
+ <p class="MsoNormal"> </p>
384
+ </span>
385
+ </p>
386
+ <p class="MsoNormal"> </p>
387
+ </div>
388
+ OUTPUT
360
389
  end
361
390
 
362
391
  it "reorders footnote numbers" do
@@ -390,10 +419,13 @@ RSpec.describe IsoDoc do
390
419
  </iso-standard>
391
420
  INPUT
392
421
 
393
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", input, false)
422
+ IsoDoc::Iso::HtmlConvert
423
+ .new(WORD_HTML_CSS_WORDINTRO.dup)
424
+ .convert("test", input, false)
394
425
 
395
426
  html = File.read("test.html", encoding: "UTF-8")
396
- .sub(/^.*<main class="main-section">/m, '<main xmlns:epub="epub" class="main-section">')
427
+ .sub(/^.*<main class="main-section">/m,
428
+ '<main xmlns:epub="epub" class="main-section">')
397
429
  .sub(%r{</main>.*$}m, "</main>")
398
430
 
399
431
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
@@ -436,11 +468,15 @@ RSpec.describe IsoDoc do
436
468
  </main>
437
469
  OUTPUT
438
470
 
439
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", input, false)
471
+ IsoDoc::Iso::WordConvert
472
+ .new(WORD_HTML_CSS_WORDINTRO.dup)
473
+ .convert("test", input, false)
440
474
 
441
475
  html = File.read("test.doc", encoding: "UTF-8")
442
- .sub(/^.*<div class="WordSection3"/m, '<body xmlns:epub="epub"><div class="WordSection3"')
443
- .sub(%r{</body>.*$}m, "</body>").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")
476
+ .sub(/^.*<div class="WordSection3"/m,
477
+ '<body xmlns:epub="epub"><div class="WordSection3"')
478
+ .sub(%r{</body>.*$}m, "</body>")
479
+ .gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")
444
480
 
445
481
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
446
482
  <body xmlns:epub="epub">
@@ -529,75 +565,77 @@ RSpec.describe IsoDoc do
529
565
  end
530
566
 
531
567
  it "processes IsoXML terms for HTML" do
532
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
533
- <iso-standard xmlns="http://riboseinc.com/isoxml">
534
- <sections>
535
- <terms id="_terms_and_definitions" obligation="normative">
536
- <title>Terms and Definitions</title>
537
- <term id="paddy1">
538
- <name>1.1</name>
539
- <preferred>paddy</preferred>
540
- <domain>rice</domain>
541
- <definition>
542
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
543
- </definition>
544
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
545
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
546
- <ul>
547
- <li>A</li>
548
- </ul>
549
- </termexample>
550
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
551
- <ul>
552
- <li>A</li>
553
- </ul>
554
- </termexample>
555
- <termsource status="modified">
556
- <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
557
- <locality type="clause">
558
- <referenceFrom>3.1</referenceFrom>
559
- </locality>
560
- </origin>
561
- <modification>
562
- <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here</p>
563
- </modification>
564
- </termsource>
565
- </term>
566
- <term id="paddy">
567
- <name>1.2</name>
568
- <preferred>paddy</preferred>
569
- <admitted>paddy rice</admitted>
570
- <admitted>rough rice</admitted>
571
- <deprecates>cargo rice</deprecates>
572
- <definition>
573
- <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
574
- </definition>
575
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
576
- <ul>
577
- <li>A</li>
578
- </ul>
579
- </termexample>
580
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
581
- <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>
582
- </termnote>
583
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
584
- <ul>
585
- <li>A</li>
586
- </ul>
587
- <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>
588
- </termnote>
589
- <termsource status="identical">
590
- <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
591
- <locality type="clause">
592
- <referenceFrom>3.1</referenceFrom>
593
- </locality>
594
- </origin>
595
- </termsource>
596
- </term>
597
- </terms>
598
- </sections>
599
- </iso-standard>
600
- INPUT
568
+ IsoDoc::Iso::HtmlConvert
569
+ .new(WORD_HTML_CSS.dup)
570
+ .convert("test", <<~"INPUT", false)
571
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
572
+ <sections>
573
+ <terms id="_terms_and_definitions" obligation="normative">
574
+ <title>Terms and Definitions</title>
575
+ <term id="paddy1">
576
+ <name>1.1</name>
577
+ <preferred>paddy</preferred>
578
+ <domain>rice</domain>
579
+ <definition>
580
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
581
+ </definition>
582
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
583
+ <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
584
+ <ul>
585
+ <li>A</li>
586
+ </ul>
587
+ </termexample>
588
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
589
+ <ul>
590
+ <li>A</li>
591
+ </ul>
592
+ </termexample>
593
+ <termsource status="modified">
594
+ <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
595
+ <locality type="clause">
596
+ <referenceFrom>3.1</referenceFrom>
597
+ </locality>
598
+ </origin>
599
+ <modification>
600
+ <p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here</p>
601
+ </modification>
602
+ </termsource>
603
+ </term>
604
+ <term id="paddy">
605
+ <name>1.2</name>
606
+ <preferred>paddy</preferred>
607
+ <admitted>paddy rice</admitted>
608
+ <admitted>rough rice</admitted>
609
+ <deprecates>cargo rice</deprecates>
610
+ <definition>
611
+ <p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p>
612
+ </definition>
613
+ <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
614
+ <ul>
615
+ <li>A</li>
616
+ </ul>
617
+ </termexample>
618
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
619
+ <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>
620
+ </termnote>
621
+ <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
622
+ <ul>
623
+ <li>A</li>
624
+ </ul>
625
+ <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>
626
+ </termnote>
627
+ <termsource status="identical">
628
+ <origin bibitemid="ISO7301" citeas="ISO 7301:2011" type="inline">
629
+ <locality type="clause">
630
+ <referenceFrom>3.1</referenceFrom>
631
+ </locality>
632
+ </origin>
633
+ </termsource>
634
+ </term>
635
+ </terms>
636
+ </sections>
637
+ </iso-standard>
638
+ INPUT
601
639
  expect(File.exist?("test.html")).to be true
602
640
  html = File.read("test.html", encoding: "UTF-8")
603
641
  expect(html).to match(%r{<h2 class="TermNum" id="paddy1">1\.1</h2>})
@@ -605,18 +643,20 @@ RSpec.describe IsoDoc do
605
643
  end
606
644
 
607
645
  it "inserts default paragraph between two tables for Word" do
608
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
609
- <iso-standard xmlns="http://riboseinc.com/isoxml">
610
- <annex id="P" inline-header="false" obligation="normative">
611
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
612
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
613
- </example>
614
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
615
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
616
- </example>
617
- </annex>
618
- </iso-standard>
619
- INPUT
646
+ IsoDoc::Iso::WordConvert
647
+ .new(WORD_HTML_CSS.dup)
648
+ .convert("test", <<~"INPUT", false)
649
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
650
+ <annex id="P" inline-header="false" obligation="normative">
651
+ <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
652
+ <p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
653
+ </example>
654
+ <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
655
+ <p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
656
+ </example>
657
+ </annex>
658
+ </iso-standard>
659
+ INPUT
620
660
  word = File.read("test.doc", encoding: "UTF-8")
621
661
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
622
662
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
@@ -628,14 +668,14 @@ RSpec.describe IsoDoc do
628
668
  </p>
629
669
  <div class="Section3">
630
670
  <a id="P" name="P"/>
631
- <div class="example">
671
+ <div class="Example">
632
672
  <a id="_63112cbc-cde0-435f-9553-e0b8c4f5851c" name="_63112cbc-cde0-435f-9553-e0b8c4f5851c"/>
633
- <p class="example">
673
+ <p class="Example">
634
674
  <span style="mso-tab-count:1">  </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
635
675
  </div>
636
- <div class="example">
676
+ <div class="Example">
637
677
  <a id="_63112cbc-cde0-435f-9553-e0b8c4f5851d" name="_63112cbc-cde0-435f-9553-e0b8c4f5851d"/>
638
- <p class="example">
678
+ <p class="Example">
639
679
  <span style="mso-tab-count:1">  </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
640
680
  </div>
641
681
  </div>
@@ -644,24 +684,26 @@ RSpec.describe IsoDoc do
644
684
  end
645
685
 
646
686
  it "processes figure keys (Word)" do
647
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
648
- <iso-standard xmlns="http://riboseinc.com/isoxml">
649
- <annex id="P" inline-header="false" obligation="normative">
650
- <figure id="samplecode">
651
- <p>Hello</p>
652
- <p>Key</p>
653
- <dl>
654
- <dt>
655
- <p>A</p>
656
- </dt>
657
- <dd>
658
- <p>B</p>
659
- </dd>
660
- </dl>
661
- </figure>
662
- </annex>
663
- </iso-standard>
664
- INPUT
687
+ IsoDoc::Iso::WordConvert
688
+ .new(WORD_HTML_CSS.dup)
689
+ .convert("test", <<~"INPUT", false)
690
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
691
+ <annex id="P" inline-header="false" obligation="normative">
692
+ <figure id="samplecode">
693
+ <p>Hello</p>
694
+ <p>Key</p>
695
+ <dl>
696
+ <dt>
697
+ <p>A</p>
698
+ </dt>
699
+ <dd>
700
+ <p>B</p>
701
+ </dd>
702
+ </dl>
703
+ </figure>
704
+ </annex>
705
+ </iso-standard>
706
+ INPUT
665
707
  word = File.read("test.doc", encoding: "UTF-8")
666
708
  .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
667
709
  .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
@@ -694,7 +736,6 @@ RSpec.describe IsoDoc do
694
736
  </tr>
695
737
  </table>
696
738
  </div>
697
- <p class="FigureTitle" style="text-align:center;"/>
698
739
  </div>
699
740
  </div>
700
741
  </div>
@@ -797,17 +838,22 @@ RSpec.describe IsoDoc do
797
838
  .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
798
839
  .to be_equivalent_to xmlpp(presxml)
799
840
 
800
- IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("test", presxml, false)
841
+ IsoDoc::Iso::HtmlConvert
842
+ .new(WORD_HTML_CSS.dup)
843
+ .convert("test", presxml, false)
801
844
 
802
845
  word = File.read("test.html", encoding: "UTF-8")
803
846
  expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
804
847
  expect((word)).to include "I am the Walrus."
805
848
 
806
- IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", presxml, false)
849
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup)
850
+ .convert("test", presxml, false)
807
851
  word = File.read("test.doc", encoding: "UTF-8")
808
852
  expect(xmlpp(word
809
- .sub(%r{^.*<div class="boilerplate-copyright">}m, '<div class="boilerplate-copyright">')
810
- .sub(%r{</div>.*$}m, "</div></div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
853
+ .sub(%r{^.*<div class="boilerplate-copyright">}m,
854
+ '<div class="boilerplate-copyright">')
855
+ .sub(%r{</div>.*$}m, "</div></div>")))
856
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
811
857
  <div class="boilerplate-copyright">
812
858
  <div>
813
859
  <p class="zzCopyright">
@@ -839,125 +885,129 @@ RSpec.describe IsoDoc do
839
885
  </div>
840
886
  </div>
841
887
  OUTPUT
842
- expect(word).to include '<p class="zzWarning">This document is not an ISO International Standard'
888
+ expect(word).to include '<p class="zzWarning">This document is not '\
889
+ "an ISO International Standard"
843
890
  end
844
891
 
845
892
  it "populates Word ToC" do
846
- IsoDoc::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", <<~"INPUT", false)
847
- <iso-standard xmlns="http://riboseinc.com/isoxml">
848
- <sections>
849
- <clause id="A" inline-header="false" obligation="normative">
850
- <title>Clause 4</title>
851
- <clause id="N" inline-header="false" obligation="normative">
852
- <title>Introduction
853
- <bookmark id="Q"/>
854
- to this
855
- <fn reference="1">
856
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
857
- </title>
858
- </clause>
859
- <clause id="O" inline-header="false" obligation="normative">
860
- <title>Clause 4.2</title>
861
- <p>A
862
- <fn reference="1">
863
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
864
- </p>
865
- <clause id="P" inline-header="false" obligation="normative">
866
- <title>Clause 4.2.1</title>
893
+ IsoDoc::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup)
894
+ .convert("test", <<~"INPUT", false)
895
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
896
+ <sections>
897
+ <clause id="A" inline-header="false" obligation="normative">
898
+ <title>Clause 4</title>
899
+ <clause id="N" inline-header="false" obligation="normative">
900
+ <title>Introduction
901
+ <bookmark id="Q"/>
902
+ to this
903
+ <fn reference="1">
904
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
905
+ </title>
906
+ </clause>
907
+ <clause id="O" inline-header="false" obligation="normative">
908
+ <title>Clause 4.2</title>
909
+ <p>A
910
+ <fn reference="1">
911
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
912
+ </p>
913
+ <clause id="P" inline-header="false" obligation="normative">
914
+ <title>Clause 4.2.1</title>
915
+ </clause>
867
916
  </clause>
868
917
  </clause>
869
- </clause>
870
- </sections>
871
- </iso-standard>
872
- INPUT
918
+ </sections>
919
+ </iso-standard>
920
+ INPUT
873
921
  word = File.read("test.doc")
874
- .sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
922
+ .sub(/^.*<div class="WordSection2">/m,
923
+ '<div class="WordSection2">')
875
924
  .sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
876
925
 
877
- expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc"))).to be_equivalent_to xmlpp(<<~'OUTPUT')
878
- <div class="WordSection2">An empty word intro page.
879
- <p class="MsoToc1">
880
- <span lang="EN-GB" xml:lang="EN-GB">
881
- <span style="mso-element:field-begin"/>
882
- <span style="mso-spacerun:yes"> </span>
883
- TOC
884
- \o &quot;1-2&quot; \h \z \u
885
- <span style="mso-element:field-separator"/></span>
886
- <span class="MsoHyperlink">
887
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
888
- <a href="#_Toc">Clause 4
889
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
890
- <span style="mso-tab-count:1 dotted">. </span></span>
891
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
892
- <span style="mso-element:field-begin"/>
893
- </span>
894
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
895
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
896
- <span style="mso-element:field-separator"/>
897
- </span>
898
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
899
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
900
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
901
- <span style="mso-element:field-end"/>
902
- </span>
903
- </a>
926
+ expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")))
927
+ .to be_equivalent_to xmlpp(<<~'OUTPUT')
928
+ <div class="WordSection2">An empty word intro page.
929
+ <p class="MsoToc1">
930
+ <span lang="EN-GB" xml:lang="EN-GB">
931
+ <span style="mso-element:field-begin"/>
932
+ <span style="mso-spacerun:yes"> </span>
933
+ TOC
934
+ \o &quot;1-2&quot; \h \z \u
935
+ <span style="mso-element:field-separator"/></span>
936
+ <span class="MsoHyperlink">
937
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
938
+ <a href="#_Toc">Clause 4
939
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
940
+ <span style="mso-tab-count:1 dotted">. </span></span>
941
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
942
+ <span style="mso-element:field-begin"/>
943
+ </span>
944
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
945
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
946
+ <span style="mso-element:field-separator"/>
947
+ </span>
948
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
949
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
950
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
951
+ <span style="mso-element:field-end"/>
952
+ </span>
953
+ </a>
954
+ </span>
904
955
  </span>
905
- </span>
906
- </p>
907
- <p class="MsoToc2">
908
- <span class="MsoHyperlink">
909
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
910
- <a href="#_Toc">Introduction to this
911
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
912
- <span style="mso-tab-count:1 dotted">. </span></span>
913
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
914
- <span style="mso-element:field-begin"/>
915
- </span>
916
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
917
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
918
- <span style="mso-element:field-separator"/>
919
- </span>
920
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
921
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
922
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
923
- <span style="mso-element:field-end"/>
924
- </span>
925
- </a>
956
+ </p>
957
+ <p class="MsoToc2">
958
+ <span class="MsoHyperlink">
959
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
960
+ <a href="#_Toc">Introduction to this
961
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
962
+ <span style="mso-tab-count:1 dotted">. </span></span>
963
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
964
+ <span style="mso-element:field-begin"/>
965
+ </span>
966
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
967
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
968
+ <span style="mso-element:field-separator"/>
969
+ </span>
970
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
971
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
972
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
973
+ <span style="mso-element:field-end"/>
974
+ </span>
975
+ </a>
976
+ </span>
926
977
  </span>
927
- </span>
928
- </p>
929
- <p class="MsoToc2">
930
- <span class="MsoHyperlink">
931
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
932
- <a href="#_Toc">Clause 4.2
933
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
934
- <span style="mso-tab-count:1 dotted">. </span></span>
935
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
936
- <span style="mso-element:field-begin"/>
937
- </span>
938
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
939
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
940
- <span style="mso-element:field-separator"/>
941
- </span>
942
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
943
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
944
- <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
945
- <span style="mso-element:field-end"/>
946
- </span>
947
- </a>
978
+ </p>
979
+ <p class="MsoToc2">
980
+ <span class="MsoHyperlink">
981
+ <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
982
+ <a href="#_Toc">Clause 4.2
983
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
984
+ <span style="mso-tab-count:1 dotted">. </span></span>
985
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
986
+ <span style="mso-element:field-begin"/>
987
+ </span>
988
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">PAGEREF _Toc \h </span>
989
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
990
+ <span style="mso-element:field-separator"/>
991
+ </span>
992
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">1</span>
993
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB"/>
994
+ <span class="MsoTocTextSpan" lang="EN-GB" xml:lang="EN-GB">
995
+ <span style="mso-element:field-end"/>
996
+ </span>
997
+ </a>
998
+ </span>
948
999
  </span>
949
- </span>
950
- </p>
951
- <p class="MsoToc1">
952
- <span lang="EN-GB" xml:lang="EN-GB">
953
- <span style="mso-element:field-end"/>
954
- </span>
955
- <span lang="EN-GB" xml:lang="EN-GB">
956
- <p class="MsoNormal"> </p>
957
- </span>
958
- </p>
959
- <p class="MsoNormal"> </p>
960
- </div>
961
- OUTPUT
1000
+ </p>
1001
+ <p class="MsoToc1">
1002
+ <span lang="EN-GB" xml:lang="EN-GB">
1003
+ <span style="mso-element:field-end"/>
1004
+ </span>
1005
+ <span lang="EN-GB" xml:lang="EN-GB">
1006
+ <p class="MsoNormal"> </p>
1007
+ </span>
1008
+ </p>
1009
+ <p class="MsoNormal"> </p>
1010
+ </div>
1011
+ OUTPUT
962
1012
  end
963
1013
  end