metanorma-iso 1.7.3 → 1.8.3

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