metanorma-iso 1.5.14 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +17 -0
  3. data/.rubocop.yml +0 -4
  4. data/lib/asciidoctor/iso/base.rb +13 -13
  5. data/lib/asciidoctor/iso/basicdoc.rng +20 -3
  6. data/lib/asciidoctor/iso/cleanup.rb +1 -1
  7. data/lib/asciidoctor/iso/front.rb +5 -5
  8. data/lib/asciidoctor/iso/isodoc.rng +118 -4
  9. data/lib/asciidoctor/iso/isostandard-amd.rng +11 -4
  10. data/lib/asciidoctor/iso/isostandard.rng +22 -10
  11. data/lib/asciidoctor/iso/validate.rb +78 -0
  12. data/lib/asciidoctor/iso/validate_section.rb +12 -9
  13. data/lib/isodoc/iso/html/header.html +12 -12
  14. data/lib/isodoc/iso/html/html_iso_intro.html +1 -1
  15. data/lib/isodoc/iso/html/html_iso_titlepage.html +1 -1
  16. data/lib/isodoc/iso/html/word_iso_intro.html +1 -1
  17. data/lib/isodoc/iso/html/word_iso_titlepage.html +1 -1
  18. data/lib/isodoc/iso/html_convert.rb +2 -2
  19. data/lib/isodoc/iso/i18n-en.yaml +2 -0
  20. data/lib/isodoc/iso/i18n-fr.yaml +1 -1
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +1 -1
  22. data/lib/isodoc/iso/iso.amendment.xsl +451 -208
  23. data/lib/isodoc/iso/iso.international-standard.xsl +451 -208
  24. data/lib/isodoc/iso/sections.rb +1 -1
  25. data/lib/isodoc/iso/word_convert.rb +2 -2
  26. data/lib/isodoc/iso/xref.rb +28 -12
  27. data/lib/metanorma/iso/processor.rb +11 -0
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +2 -2
  30. data/spec/asciidoctor-iso/amd_spec.rb +575 -573
  31. data/spec/asciidoctor-iso/base_spec.rb +449 -458
  32. data/spec/asciidoctor-iso/blocks_spec.rb +333 -288
  33. data/spec/asciidoctor-iso/cleanup_spec.rb +814 -699
  34. data/spec/asciidoctor-iso/inline_spec.rb +116 -91
  35. data/spec/asciidoctor-iso/lists_spec.rb +128 -121
  36. data/spec/asciidoctor-iso/refs_spec.rb +308 -250
  37. data/spec/asciidoctor-iso/section_spec.rb +273 -242
  38. data/spec/asciidoctor-iso/table_spec.rb +258 -242
  39. data/spec/asciidoctor-iso/validate_spec.rb +1223 -919
  40. data/spec/isodoc/amd_spec.rb +967 -946
  41. data/spec/isodoc/blocks_spec.rb +530 -507
  42. data/spec/isodoc/i18n_spec.rb +953 -911
  43. data/spec/isodoc/inline_spec.rb +355 -293
  44. data/spec/isodoc/iso_spec.rb +340 -316
  45. data/spec/isodoc/metadata_spec.rb +392 -382
  46. data/spec/isodoc/postproc_spec.rb +834 -656
  47. data/spec/isodoc/ref_spec.rb +374 -331
  48. data/spec/isodoc/section_spec.rb +608 -525
  49. data/spec/isodoc/table_spec.rb +472 -411
  50. data/spec/isodoc/terms_spec.rb +209 -185
  51. data/spec/isodoc/xref_spec.rb +1370 -1236
  52. data/spec/metanorma/processor_spec.rb +28 -26
  53. data/spec/spec_helper.rb +184 -189
  54. metadata +7 -10
  55. data/.rubocop.ribose.yml +0 -66
  56. data/lib/metanorma/iso/fonts_manifest.yaml +0 -6
  57. data/spec/assets/xref_error.adoc +0 -7
@@ -1,71 +1,91 @@
1
1
  require "spec_helper"
2
2
  require "fileutils"
3
3
 
4
- RSpec.describe IsoDoc do
4
+ WORD_HTML_CSS = {
5
+ wordstylesheet: "spec/assets/word.css",
6
+ htmlstylesheet: "spec/assets/html.css",
7
+ }.freeze
8
+
9
+ WORD_HTML_CSS_HEADER_HTML = {
10
+ wordstylesheet: "spec/assets/word.css",
11
+ htmlstylesheet: "spec/assets/html.css",
12
+ header: "spec/assets/header.html",
13
+ }.freeze
14
+
15
+ WORD_HTML_CSS_WORDINTRO = {
16
+ wordstylesheet: "spec/assets/word.css",
17
+ htmlstylesheet: "spec/assets/html.css",
18
+ wordintropage: "spec/assets/wordintro.html",
19
+ }.freeze
5
20
 
21
+ RSpec.describe IsoDoc do
6
22
  it "generates file based on string input" do
7
- FileUtils.rm_f "test.doc"
8
- FileUtils.rm_f "test.html"
9
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", filename: "test"}).convert("test", <<~"INPUT", false)
10
- <iso-standard xmlns="http://riboseinc.com/isoxml">
23
+ IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.merge(filename: "test")).convert("test", <<~"INPUT", false)
24
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
11
25
  <bibdata>
12
- <title>
13
- <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
14
- <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
15
- <title type="title-part" language="en" format="text/plain">Rice</title>
16
- </title>
17
- </bibdata>
18
- <preface><foreword>
19
- <note>
20
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
21
- </note>
22
- </foreword></preface>
23
- </iso-standard>
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>
24
40
  INPUT
25
41
  expect(File.exist?("test.html")).to be true
26
42
  html = File.read("test.html", encoding: "UTF-8")
27
- expect(html).to match(%r{<title>Cereals and pulses\&#xA0;\&#x2014; Specifications and test methods\&#xA0;\&#x2014; Rice</title>})
43
+ expect(html).to match(
44
+ %r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>}
45
+ )
28
46
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
29
47
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
30
48
  end
31
49
 
32
50
  it "generates HTML output docs with null configuration" do
33
- FileUtils.rm_f "test.doc"
34
- FileUtils.rm_f "test.html"
35
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
36
- <iso-standard xmlns="http://riboseinc.com/isoxml">
51
+ IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("test", <<~"INPUT", false)
52
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
37
53
  <bibdata>
38
- <title>
39
- <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
40
- <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
41
- <title type="title-part" language="en" format="text/plain">Rice</title>
42
- </title>
43
- </bibdata>
44
- <preface><foreword>
45
- <note>
46
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
47
- </note>
48
- </foreword></preface>
49
- </iso-standard>
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>
50
68
  INPUT
51
69
  expect(File.exist?("test.html")).to be true
52
70
  html = File.read("test.html", encoding: "UTF-8")
53
- expect(html).to match(%r{<title>Cereals and pulses\&#xA0;\&#x2014; Specifications and test methods\&#xA0;\&#x2014; Rice</title>})
71
+ expect(html).to match(
72
+ %r{<title>Cereals and pulses&#xA0;&#x2014; Specifications and test methods&#xA0;&#x2014; Rice</title>}
73
+ )
54
74
  expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/})
55
75
  expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/)
56
76
  end
57
77
 
58
78
  it "generates Word output docs with null configuration" do
59
- FileUtils.rm_f "test.doc"
60
- FileUtils.rm_f "test.html"
61
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
62
- <iso-standard xmlns="http://riboseinc.com/isoxml">
63
- <preface><foreword>
64
- <note>
65
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
66
- </note>
67
- </foreword></preface>
68
- </iso-standard>
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>
69
89
  INPUT
70
90
  expect(File.exist?("test.doc")).to be true
71
91
  word = File.read("test.doc", encoding: "UTF-8")
@@ -73,9 +93,7 @@ RSpec.describe IsoDoc do
73
93
  end
74
94
 
75
95
  it "generates HTML output docs with null configuration from file" do
76
- FileUtils.rm_f "spec/assets/iso.doc"
77
- FileUtils.rm_f "spec/assets/iso.html"
78
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/assets/iso.xml", nil, false)
96
+ IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("spec/assets/iso.xml", nil, false)
79
97
  expect(File.exist?("spec/assets/iso.html")).to be true
80
98
  html = File.read("spec/assets/iso.html", encoding: "UTF-8")
81
99
  expect(html).to match(/<style>/)
@@ -84,403 +102,499 @@ RSpec.describe IsoDoc do
84
102
  end
85
103
 
86
104
  it "generates Word output docs with null configuration from file" do
87
- FileUtils.rm_f "spec/assets/iso.doc"
88
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/assets/iso.xml", nil, false)
105
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("spec/assets/iso.xml", nil, false)
89
106
  expect(File.exist?("spec/assets/iso.doc")).to be true
90
107
  word = File.read("spec/assets/iso.doc", encoding: "UTF-8")
91
108
  expect(word).to match(/<w:WordDocument>/)
92
109
  expect(word).to match(/<style>/)
93
110
  end
94
111
 
95
- it "generates Pdf output docs with null configuration from file" do
96
- FileUtils.rm_f "spec/assets/iso.pdf"
97
- IsoDoc::Iso::PdfConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/assets/iso.xml", nil, false)
112
+ it "generates Pdf output docs with null configuration from file" do
113
+ mock_pdf
114
+ IsoDoc::Iso::PdfConvert.new(WORD_HTML_CSS.dup).convert("spec/assets/iso.xml", nil, false)
98
115
  expect(File.exist?("spec/assets/iso.pdf")).to be true
99
116
  end
100
117
 
101
118
  it "converts annex subheadings to h2Annex class for Word" do
102
- FileUtils.rm_f "test.doc"
103
- FileUtils.rm_f "test.html"
104
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
105
- <iso-standard xmlns="http://riboseinc.com/isoxml">
106
- <annex id="P" inline-header="false" obligation="normative">
107
- <title>Annex</title>
108
- <clause id="Q" inline-header="false" obligation="normative">
109
- <title>A.1<tab/>Annex A.1</title>
110
- </clause>
111
- <appendix id="Q2" inline-header="false" obligation="normative">
112
- <title>Appendix 1<tab/>An Appendix</title>
113
- </appendix>
114
- </annex>
115
- </iso-standard>
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>
116
135
  INPUT
117
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
118
- sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
136
+
137
+ word = File.read("test.doc", encoding: "UTF-8")
138
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
139
+ .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
140
+
119
141
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
120
- <div class="WordSection3">
121
- <p class="zzSTDTitle1"></p>
122
- <p class="MsoNormal"><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
123
- <div class="Section3"><a name="P" id="P"></a>
124
- <h1 class="Annex">Annex</h1>
125
- <div><a name="Q" id="Q"></a>
126
- <p class="h2Annex">A.1<span style="mso-tab-count:1">&#xA0; </span>Annex A.1</p>
127
- </div>
128
- <div><a name="Q2" id="Q2"></a>
129
- <p class="h2Annex">Appendix 1<span style="mso-tab-count:1">&#xA0; </span>An Appendix</p>
130
- </div>
131
- </div>
132
- </div>
142
+ <div class="WordSection3">
143
+ <p class="zzSTDTitle1"/>
144
+ <p class="MsoNormal">
145
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
146
+ </p>
147
+ <div class="Section3">
148
+ <a id="P" name="P"/>
149
+ <h1 class="Annex">Annex</h1>
150
+ <div>
151
+ <a id="Q" name="Q"/>
152
+ <p class="h2Annex">A.1
153
+ <span style="mso-tab-count:1">  </span>
154
+ Annex A.1</p>
155
+ </div>
156
+ <div>
157
+ <a id="Q2" name="Q2"/>
158
+ <p class="h2Annex">Appendix 1
159
+ <span style="mso-tab-count:1">  </span>
160
+ An Appendix</p>
161
+ </div>
162
+ </div>
163
+ </div>
133
164
  OUTPUT
134
165
  end
135
166
 
136
167
  it "populates Word template with terms reference labels" do
137
- FileUtils.rm_f "test.doc"
138
- FileUtils.rm_f "test.html"
139
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
140
- <iso-standard xmlns="http://riboseinc.com/isoxml">
141
- <sections>
142
- <terms id="_terms_and_definitions" obligation="normative"><title>1<tab/>Terms and Definitions</title>
143
-
144
- <term id="paddy1">
145
- <name>1.1</name>
146
- <preferred>paddy</preferred>
147
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
148
- <termsource status="modified">
149
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality>ISO 7301:2011, 3.1</origin>
150
- <modification>
151
- <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>
152
- </modification>
153
- </termsource></term>
154
-
155
- </terms>
156
- </sections>
157
- </iso-standard>
158
-
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>
159
194
  INPUT
160
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
161
- sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
195
+
196
+ word = File.read("test.doc", encoding: "UTF-8")
197
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
198
+ .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
199
+
162
200
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
163
- <div class="WordSection3">
164
- <p class="zzSTDTitle1"></p>
165
- <div><a name="_terms_and_definitions" id="_terms_and_definitions"></a><h1>1<span style="mso-tab-count:1">&#xA0; </span>Terms and Definitions</h1>
166
- <p class="TermNum"><a name="paddy1" id="paddy1"></a>1.1</p><p class="Terms" style="text-align:left;">paddy</p>
167
- <p class="MsoNormal"><a name="_eb29b35e-123e-4d1c-b50b-2714d41e747f" id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"></a>rice retaining its husk after threshing</p>
168
- <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>
169
- </div>
201
+ <div class="WordSection3">
202
+ <p class="zzSTDTitle1"/>
203
+ <div>
204
+ <a id="_terms_and_definitions" name="_terms_and_definitions"/>
205
+ <h1>1
206
+ <span style="mso-tab-count:1">  </span>
207
+ Terms and Definitions</h1>
208
+ <p class="TermNum">
209
+ <a id="paddy1" name="paddy1"/>1.1</p>
210
+ <p class="Terms" style="text-align:left;">paddy</p>
211
+ <p class="MsoNormal">
212
+ <a id="_eb29b35e-123e-4d1c-b50b-2714d41e747f" name="_eb29b35e-123e-4d1c-b50b-2714d41e747f"/>rice retaining its husk after threshing</p>
213
+ <p class="MsoNormal">[SOURCE:
214
+ <a href="#ISO7301">ISO 7301:2011, 3.1</a>
215
+ , modified — The term &quot;cargo rice&quot; is shown as deprecated, and Note 1 to entry is not included here]</p>
216
+ </div>
217
+ </div>
170
218
  OUTPUT
171
219
  end
172
220
 
173
221
  it "populates Word header" do
174
- FileUtils.rm_f "test.doc"
175
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", header: "spec/assets/header.html"}).convert("test", <<~"INPUT", false)
176
- <iso-standard xmlns="http://riboseinc.com/isoxml">
177
- <bibdata type="article">
178
- <docidentifier>
179
- <project-number part="1">1000</project-number>
180
- </docidentifier>
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>
181
228
  </bibdata>
182
- </iso-standard>
183
-
229
+ </iso-standard>
184
230
  INPUT
185
- word = File.read("test.doc", encoding: "UTF-8").sub(%r{^.*Content-Location: file:///C:/Doc/test_files/header.html}m, "Content-Location: file:///C:/Doc/test_files/header.html").
186
- sub(/------=_NextPart.*$/m, "")
187
- #expect(word).to include(%{Content-Location: file:///C:/Doc/test_files/header.html\nContent-Transfer-Encoding: base64\nContent-Type: text/html charset="utf-8" })
231
+ 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, "")
188
235
  expect(word).to include(%{Content-Location: file:///C:/Doc/test_files/header.html})
189
236
  end
190
237
 
191
238
  it "populates Word ToC" do
192
- FileUtils.rm_f "test.doc"
193
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
194
- <iso-standard xmlns="http://riboseinc.com/isoxml">
239
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", <<~"INPUT", false)
240
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
195
241
  <sections>
196
- <clause id="A" inline-header="false" obligation="normative"><title>1<tab/>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
197
-
198
- <title>1.1<tab/>Introduction<bookmark id="Q"/> to this<fn reference="1">
199
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
200
- </fn></title>
201
- </clause>
202
- <clause id="O" inline-header="false" obligation="normative">
203
- <title>1.2<tab/>Clause 4.2</title>
204
- <p>A<fn reference="1">
205
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
206
- </fn></p>
207
- </clause></clause>
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
248
+ <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>
264
+ </clause>
265
+ </clause>
208
266
  </sections>
209
- </iso-standard>
210
-
267
+ </iso-standard>
211
268
  INPUT
212
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*An empty word intro page\./m, '').
213
- sub(%r{</div>.*$}m, "</div>")
214
-
215
- expect(xmlpp("<div>" + word.gsub(/_Toc\d\d+/, "_Toc") )).to be_equivalent_to xmlpp(<<~'OUTPUT')
216
- <div>
217
- <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
218
- \o "1-3" \h \z \u <span style="mso-element:field-separator"></span></span>
219
- <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
220
- <a href="#_Toc">1 Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
221
- <span style="mso-tab-count:1 dotted">. </span>
222
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
223
- <span style="mso-element:field-begin"></span></span>
224
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
225
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
226
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
227
-
228
- <p class="MsoToc2">
229
- <span class="MsoHyperlink">
230
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
231
- <a href="#_Toc">1.1 Introduction to this<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
232
- <span style="mso-tab-count:1 dotted">. </span>
233
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
234
- <span style="mso-element:field-begin"></span></span>
235
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
236
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
237
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
238
- </span>
239
- </p>
240
-
241
- <p class="MsoToc2">
242
- <span class="MsoHyperlink">
243
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
244
- <a href="#_Toc">1.2 Clause 4.2<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
245
- <span style="mso-tab-count:1 dotted">. </span>
246
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
247
- <span style="mso-element:field-begin"></span></span>
248
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
249
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
250
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
251
- </span>
252
- </p>
253
-
254
- <p class="MsoToc1">
255
- <span lang="EN-GB" xml:lang="EN-GB">
256
- <span style="mso-element:field-end"></span>
257
- </span>
258
- <span lang="EN-GB" xml:lang="EN-GB">
259
- <p class="MsoNormal">&#xA0;</p>
260
- </span>
261
- </p>
262
-
263
-
264
- <p class="MsoNormal">&#xA0;</p>
265
- </div>
269
+
270
+ word = File.read("test.doc", encoding: "UTF-8")
271
+ .sub(/^.*An empty word intro page\./m, "")
272
+ .sub(%r{</div>.*$}m, "</div>")
273
+
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>
300
+ </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>
322
+ </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>
344
+ </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>
266
357
  OUTPUT
267
358
  end
268
359
 
269
360
  it "reorders footnote numbers" do
270
- FileUtils.rm_f "test.html"
271
361
  input = <<~INPUT
272
- <iso-standard xmlns="http://riboseinc.com/isoxml">
362
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
273
363
  <sections>
274
- <clause id="A" inline-header="false" obligation="normative"><title>1<tab/>Clause 4</title><fn reference="3">
275
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">This is a footnote.</p>
276
- </fn><clause id="N" inline-header="false" obligation="normative">
277
-
278
- <title>1.1<tab/>Introduction to this<fn reference="2">
279
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
280
- </fn></title>
281
- </clause>
282
- <clause id="O" inline-header="false" obligation="normative">
283
- <title>1.2<tab/>Clause 4.2</title>
284
- <p>A<fn reference="1">
285
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
286
- </fn></p>
287
- </clause></clause>
364
+ <clause id="A" inline-header="false" obligation="normative">
365
+ <title>1
366
+ <tab/>
367
+ Clause 4</title>
368
+ <fn reference="3">
369
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">This is a footnote.</p>
370
+ </fn>
371
+ <clause id="N" inline-header="false" obligation="normative">
372
+ <title>1.1 <tab/>
373
+ Introduction to this
374
+ <fn reference="2">
375
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
376
+ </title>
377
+ </clause>
378
+ <clause id="O" inline-header="false" obligation="normative">
379
+ <title>1.2 <tab/>
380
+ Clause 4.2</title>
381
+ <p>A
382
+ <fn reference="1">
383
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p></fn>
384
+ </p>
385
+ </clause>
386
+ </clause>
288
387
  </sections>
289
- </iso-standard>
388
+ </iso-standard>
290
389
  INPUT
291
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", input, false)
292
- html = File.read("test.html", encoding: "UTF-8").sub(/^.*<main class="main-section">/m, '<main xmlns:epub="epub" class="main-section">').
293
- sub(%r{</main>.*$}m, "</main>")
390
+
391
+ IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", input, false)
392
+
393
+ html = File.read("test.html", encoding: "UTF-8")
394
+ .sub(/^.*<main class="main-section">/m, '<main xmlns:epub="epub" class="main-section">')
395
+ .sub(%r{</main>.*$}m, "</main>")
396
+
294
397
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
295
- <main xmlns:epub="epub" class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
296
- <p class="zzSTDTitle1"></p>
297
- <div id="A">
298
- <h1 id="toc0">1&#xA0; Clause 4</h1>
299
- <a href="#fn:3" class="FootnoteRef" id="fnref:1">
300
- <sup>1)</sup>
301
- </a>
302
- <div id="N">
303
-
304
- <h2 id="toc1">1.1&#xA0; Introduction to this<a href="#fn:2" class="FootnoteRef" id="fnref:2"><sup>2)</sup></a></h2>
305
- </div>
306
- <div id="O">
307
- <h2 id="toc2">1.2&#xA0; Clause 4.2</h2>
308
- <p>A<a class="FootnoteRef" href="#fn:2"><sup>2)</sup></a></p>
309
- </div>
310
- </div>
311
- <aside id="fn:3" class="footnote">
312
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6"><a class="FootnoteRef" href="#fn:3">
313
- <sup>1)</sup>
314
- </a>This is a footnote.</p>
315
- <a href="#fnref:1">&#x21A9;</a></aside>
316
- <aside id="fn:2" class="footnote">
317
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6"><a href="#fn:2" class="FootnoteRef"><sup>2)</sup></a>Formerly denoted as 15 % (m/m).</p>
318
- <a href="#fnref:2">&#x21A9;</a></aside>
319
-
320
- </main>
398
+ <main class="main-section" xmlns:epub="epub">
399
+ <button id="myBtn" onclick="topFunction()" title="Go to top">Top</button>
400
+ <p class="zzSTDTitle1"/>
401
+ <div id="A">
402
+ <h1 id="toc0">1 &#xA0; Clause 4</h1>
403
+ <a class="FootnoteRef" href="#fn:3" id="fnref:1">
404
+ <sup>1)</sup>
405
+ </a>
406
+ <div id="N">
407
+ <h2 id="toc1">1.1 &#xA0; Introduction to this
408
+ <a class="FootnoteRef" href="#fn:2" id="fnref:2">
409
+ <sup>2)</sup></a>
410
+ </h2>
411
+ </div>
412
+ <div id="O">
413
+ <h2 id="toc2">1.2 &#xA0; Clause 4.2</h2>
414
+ <p>A
415
+ <a class="FootnoteRef" href="#fn:2">
416
+ <sup>2)</sup></a>
417
+ </p>
418
+ </div>
419
+ </div>
420
+ <aside class="footnote" id="fn:3">
421
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">
422
+ <a class="FootnoteRef" href="#fn:3">
423
+ <sup>1)</sup>
424
+ </a>This is a footnote.</p>
425
+ <a href="#fnref:1">↩</a>
426
+ </aside>
427
+ <aside class="footnote" id="fn:2">
428
+ <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">
429
+ <a class="FootnoteRef" href="#fn:2">
430
+ <sup>2)</sup>
431
+ </a>Formerly denoted as 15 % (m/m).</p>
432
+ <a href="#fnref:2">↩</a>
433
+ </aside>
434
+ </main>
321
435
  OUTPUT
322
436
 
323
- FileUtils.rm_f "test.doc"
324
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css", wordintropage: "spec/assets/wordintro.html"}).convert("test", input, false)
325
- html = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3"/m, '<body xmlns:epub="epub"><div class="WordSection3"').
326
- sub(%r{</body>.*$}m, "</body>").gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref")
437
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", input, false)
438
+
439
+ 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")
442
+
327
443
  expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
328
- <body xmlns:epub='epub'>
329
- <div class='WordSection3'>
330
- <p class='zzSTDTitle1'/>
331
- <div>
332
- <a name='A' id='A'/>
333
- <h1>
334
- 1
335
- <span style='mso-tab-count:1'>&#xA0; </span>
336
- Clause 4
337
- </h1>
338
- <span style='mso-bookmark:_Ref'>
339
- <a href='#_ftn1' class='FootnoteRef' epub:type='footnote' style='mso-footnote-id:ftn1' name='_ftnref1' title='' id='_ftnref1'>
340
- <span class='MsoFootnoteReference'>
341
- <span style='mso-special-character:footnote'/>
342
- </span>
343
- <span class='MsoFootnoteReference'>)</span>
344
- </a>
345
- </span>
346
- <div>
347
- <a name='N' id='N'/>
348
- <h2>
349
- 1.1
350
- <span style='mso-tab-count:1'>&#xA0; </span>
351
- Introduction to this
352
- <span style='mso-bookmark:_Ref'>
353
- <a href='#_ftn2' epub:type='footnote' class='FootnoteRef' style='mso-footnote-id:ftn2' name='_ftnref2' title='' id='_ftnref2'>
354
- <span class='MsoFootnoteReference'>
355
- <span style='mso-special-character:footnote'/>
356
- </span>
357
- <span class='MsoFootnoteReference'>)</span>
358
- </a>
359
- </span>
360
- </h2>
361
- </div>
362
- <div>
363
- <a name='O' id='O'/>
364
- <h2>
365
- 1.2
366
- <span style='mso-tab-count:1'>&#xA0; </span>
367
- Clause 4.2
368
- </h2>
369
- <p class='MsoNormal'>
370
- A
371
- <span style='mso-bookmark:_Ref'>
372
- <a href='#_ftn3' class='FootnoteRef' epub:type='footnote' style='mso-footnote-id:ftn3' name='_ftnref3' title='' id='_ftnref3'>
373
- <span class='MsoFootnoteReference'>
374
- <span style='mso-special-character:footnote'/>
375
- </span>
376
- <span class='MsoFootnoteReference'>)</span>
377
- </a>
378
- </span>
379
- </p>
380
- </div>
381
- </div>
382
- </div>
383
- <br clear='all' style='page-break-before:left;mso-break-type:section-break'/>
384
- <div class='colophon'/>
385
- <div style='mso-element:footnote-list'>
386
- <div style='mso-element:footnote' id='ftn1'>
387
- <p class='MsoFootnoteText'>
388
- <a name='_ff27c067-2785-4551-96cf-0a73530ff1e6' id='_ff27c067-2785-4551-96cf-0a73530ff1e6'/>
389
- <a style='mso-footnote-id:ftn1' href='#_ftn1' name='_ftnref1' title='' id='_ftnref1'>
390
- <span class='MsoFootnoteReference'>
391
- <span style='mso-special-character:footnote'/>
392
- </span>
393
- <span class='MsoFootnoteReference'>)</span>
394
- </a>
395
- This is a footnote.
396
- </p>
397
- </div>
398
- <div style='mso-element:footnote' id='ftn2'>
399
- <p class='MsoFootnoteText'>
400
- <a name='_ff27c067-2785-4551-96cf-0a73530ff1e6' id='_ff27c067-2785-4551-96cf-0a73530ff1e6'/>
401
- <a style='mso-footnote-id:ftn2' href='#_ftn2' name='_ftnref2' title='' id='_ftnref2'>
402
- <span class='MsoFootnoteReference'>
403
- <span style='mso-special-character:footnote'/>
404
- </span>
405
- <span class='MsoFootnoteReference'>)</span>
406
- </a>
407
- Formerly denoted as 15 % (m/m).
408
- </p>
409
- </div>
410
- <div style='mso-element:footnote' id='ftn3'>
411
- <p class='MsoFootnoteText'>
412
- <a name='_ff27c067-2785-4551-96cf-0a73530ff1e6' id='_ff27c067-2785-4551-96cf-0a73530ff1e6'/>
413
- <a style='mso-footnote-id:ftn3' href='#_ftn3' name='_ftnref3' title='' id='_ftnref3'>
414
- <span class='MsoFootnoteReference'>
415
- <span style='mso-special-character:footnote'/>
416
- </span>
417
- <span class='MsoFootnoteReference'>)</span>
418
- </a>
419
- Formerly denoted as 15 % (m/m).
420
- </p>
421
- </div>
422
- </div>
423
- </body>
444
+ <body xmlns:epub="epub">
445
+ <div class="WordSection3">
446
+ <p class="zzSTDTitle1"/>
447
+ <div>
448
+ <a id="A" name="A"/>
449
+ <h1>1
450
+ <span style="mso-tab-count:1">  </span>
451
+ Clause 4</h1>
452
+ <span style="mso-bookmark:_Ref">
453
+ <a class="FootnoteRef" epub:type="footnote" href="#_ftn1" id="_ftnref1" name="_ftnref1" style="mso-footnote-id:ftn1" title="">
454
+ <span class="MsoFootnoteReference">
455
+ <span style="mso-special-character:footnote"/>
456
+ </span>
457
+ <span class="MsoFootnoteReference">)</span>
458
+ </a>
459
+ </span>
460
+ <div>
461
+ <a id="N" name="N"/>
462
+ <h2>1.1
463
+ <span style="mso-tab-count:1">  </span>
464
+ Introduction to this
465
+ <span style="mso-bookmark:_Ref">
466
+ <a class="FootnoteRef" epub:type="footnote" href="#_ftn2" id="_ftnref2" name="_ftnref2" style="mso-footnote-id:ftn2" title="">
467
+ <span class="MsoFootnoteReference">
468
+ <span style="mso-special-character:footnote"/></span>
469
+ <span class="MsoFootnoteReference">)</span>
470
+ </a>
471
+ </span>
472
+ </h2>
473
+ </div>
474
+ <div>
475
+ <a id="O" name="O"/>
476
+ <h2>1.2
477
+ <span style="mso-tab-count:1">  </span>
478
+ Clause 4.2</h2>
479
+ <p class="MsoNormal">A
480
+ <span style="mso-bookmark:_Ref">
481
+ <a class="FootnoteRef" epub:type="footnote" href="#_ftn3" id="_ftnref3" name="_ftnref3" style="mso-footnote-id:ftn3" title="">
482
+ <span class="MsoFootnoteReference">
483
+ <span style="mso-special-character:footnote"/></span>
484
+ <span class="MsoFootnoteReference">)</span>
485
+ </a>
486
+ </span>
487
+ </p>
488
+ </div>
489
+ </div>
490
+ </div>
491
+ <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
492
+ <div class="colophon"/>
493
+ <div style="mso-element:footnote-list">
494
+ <div id="ftn1" style="mso-element:footnote">
495
+ <p class="MsoFootnoteText">
496
+ <a id="_ff27c067-2785-4551-96cf-0a73530ff1e6" name="_ff27c067-2785-4551-96cf-0a73530ff1e6"/>
497
+ <a href="#_ftn1" id="_ftnref1" name="_ftnref1" style="mso-footnote-id:ftn1" title="">
498
+ <span class="MsoFootnoteReference">
499
+ <span style="mso-special-character:footnote"/>
500
+ </span>
501
+ <span class="MsoFootnoteReference">)</span>
502
+ </a>This is a footnote.</p>
503
+ </div>
504
+ <div id="ftn2" style="mso-element:footnote">
505
+ <p class="MsoFootnoteText">
506
+ <a id="_ff27c067-2785-4551-96cf-0a73530ff1e6" name="_ff27c067-2785-4551-96cf-0a73530ff1e6"/>
507
+ <a href="#_ftn2" id="_ftnref2" name="_ftnref2" style="mso-footnote-id:ftn2" title="">
508
+ <span class="MsoFootnoteReference">
509
+ <span style="mso-special-character:footnote"/>
510
+ </span>
511
+ <span class="MsoFootnoteReference">)</span>
512
+ </a>Formerly denoted as 15 % (m/m).</p>
513
+ </div>
514
+ <div id="ftn3" style="mso-element:footnote">
515
+ <p class="MsoFootnoteText">
516
+ <a id="_ff27c067-2785-4551-96cf-0a73530ff1e6" name="_ff27c067-2785-4551-96cf-0a73530ff1e6"/>
517
+ <a href="#_ftn3" id="_ftnref3" name="_ftnref3" style="mso-footnote-id:ftn3" title="">
518
+ <span class="MsoFootnoteReference">
519
+ <span style="mso-special-character:footnote"/>
520
+ </span>
521
+ <span class="MsoFootnoteReference">)</span>
522
+ </a>Formerly denoted as 15 % (m/m).</p>
523
+ </div>
524
+ </div>
525
+ </body>
424
526
  OUTPUT
425
527
  end
426
528
 
427
-
428
529
  it "processes IsoXML terms for HTML" do
429
- FileUtils.rm_f "test.html"
430
- FileUtils.rm_f "test.doc"
431
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
432
- <iso-standard xmlns="http://riboseinc.com/isoxml">
433
- <sections>
434
- <terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
435
-
436
- <term id="paddy1">
437
- <name>1.1</name>
438
- <preferred>paddy</preferred>
439
- <domain>rice</domain>
440
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
441
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
442
- <p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
443
- <ul>
444
- <li>A</li>
445
- </ul>
446
- </termexample>
447
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
448
- <ul>
449
- <li>A</li>
450
- </ul>
451
- </termexample>
452
-
453
- <termsource status="modified">
454
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
455
- <modification>
456
- <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>
457
- </modification>
458
- </termsource></term>
459
-
460
- <term id="paddy">
461
- <name>1.2</name>
462
- <preferred>paddy</preferred><admitted>paddy rice</admitted>
463
- <admitted>rough rice</admitted>
464
- <deprecates>cargo rice</deprecates>
465
- <definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
466
- <termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
467
- <ul>
468
- <li>A</li>
469
- </ul>
470
- </termexample>
471
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
472
- <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>
473
- </termnote>
474
- <termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
475
- <ul><li>A</li></ul>
476
- <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>
477
- </termnote>
478
- <termsource status="identical">
479
- <origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
480
- </termsource></term>
481
- </terms>
482
- </sections>
483
- </iso-standard>
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>
484
598
  INPUT
485
599
  expect(File.exist?("test.html")).to be true
486
600
  html = File.read("test.html", encoding: "UTF-8")
@@ -488,296 +602,360 @@ RSpec.describe IsoDoc do
488
602
  expect(html).to match(%r{<h2 class="TermNum" id="paddy">1\.2</h2>})
489
603
  end
490
604
 
491
- it "inserts default paragraph between two tables for Word" do
492
- FileUtils.rm_f "test.doc"
493
- FileUtils.rm_f "test.html"
494
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
495
- <iso-standard xmlns="http://riboseinc.com/isoxml">
496
- <annex id="P" inline-header="false" obligation="normative">
497
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851c">
498
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c968">'1M', '01M', and '0001M' all describe the calendar month January.</p>
499
- </example>
500
- <example id="_63112cbc-cde0-435f-9553-e0b8c4f5851d">
501
- <p id="_158d4efa-b1c9-4aec-b325-756de8e4c969">'2M', '02M', and '0002M' all describe the calendar month February.</p>
502
- </example>
503
- </annex>
504
- </iso-standard>
605
+ 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>
505
617
  INPUT
506
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
507
- sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
618
+ word = File.read("test.doc", encoding: "UTF-8")
619
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
620
+ .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
508
621
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
509
- <div class="WordSection3">
510
- <p class="zzSTDTitle1"></p>
511
- <p class="MsoNormal">
512
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
513
- </p>
514
- <div class="Section3"><a name="P" id="P"></a>
515
- <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851c" id="_63112cbc-cde0-435f-9553-e0b8c4f5851c"></a>
516
- <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
517
- </div>
518
- <div class="example"><a name="_63112cbc-cde0-435f-9553-e0b8c4f5851d" id="_63112cbc-cde0-435f-9553-e0b8c4f5851d"></a>
519
- <p class="example"><span style="mso-tab-count:1">&#xA0; </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
520
- </div>
521
- </div>
522
- </div>
622
+ <div class="WordSection3">
623
+ <p class="zzSTDTitle1"/>
624
+ <p class="MsoNormal">
625
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
626
+ </p>
627
+ <div class="Section3">
628
+ <a id="P" name="P"/>
629
+ <div class="example">
630
+ <a id="_63112cbc-cde0-435f-9553-e0b8c4f5851c" name="_63112cbc-cde0-435f-9553-e0b8c4f5851c"/>
631
+ <p class="example">
632
+ <span style="mso-tab-count:1"</span>'1M', '01M', and '0001M' all describe the calendar month January.</p>
633
+ </div>
634
+ <div class="example">
635
+ <a id="_63112cbc-cde0-435f-9553-e0b8c4f5851d" name="_63112cbc-cde0-435f-9553-e0b8c4f5851d"/>
636
+ <p class="example">
637
+ <span style="mso-tab-count:1">  </span>'2M', '02M', and '0002M' all describe the calendar month February.</p>
638
+ </div>
639
+ </div>
640
+ </div>
523
641
  OUTPUT
524
642
  end
525
643
 
526
- it "processes figure keys (Word)" do
527
- FileUtils.rm_f "test.doc"
528
- FileUtils.rm_f "test.html"
529
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
530
- <iso-standard xmlns="http://riboseinc.com/isoxml">
644
+ 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">
531
647
  <annex id="P" inline-header="false" obligation="normative">
532
- <figure id="samplecode">
533
- <p>Hello</p>
534
- <p>Key</p>
535
- <dl>
536
- <dt><p>A</p></dt>
537
- <dd><p>B</p></dd>
538
- </dl>
539
- </figure>
540
- </annex>
541
- </iso-standard>
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>
542
662
  INPUT
543
- word = File.read("test.doc", encoding: "UTF-8").sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">').
544
- sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
663
+ word = File.read("test.doc", encoding: "UTF-8")
664
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
665
+ .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
545
666
  expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
546
- <div class="WordSection3">
547
- <p class="zzSTDTitle1"></p>
548
- <p class="MsoNormal">
549
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
550
- </p>
551
- <div class="Section3"><a name="P" id="P"></a>
552
- <div class="figure"><a name="samplecode" id="samplecode"></a>
553
- <p class="MsoNormal">Hello</p>
554
- <p class="MsoNormal">Key</p>
555
- <p style='page-break-after:avoid;' class='MsoNormal'><b>Key</b></p><div class="figdl" style="page-break-after:avoid;"><table class="figdl"><tr><td valign="top" align="left"><p align="left" style="margin-left:0pt;text-align:left;" class="MsoNormal"><p class="MsoNormal">A</p></p></td><td valign="top"><p class="MsoNormal">B</p></td></tr></table></div>
556
- <p class="FigureTitle" style="text-align:center;"/></div>
557
- </div>
558
- </div>
559
-
667
+ <div class="WordSection3">
668
+ <p class="zzSTDTitle1"/>
669
+ <p class="MsoNormal">
670
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
671
+ </p>
672
+ <div class="Section3">
673
+ <a id="P" name="P"/>
674
+ <div class="figure">
675
+ <a id="samplecode" name="samplecode"/>
676
+ <p class="MsoNormal">Hello</p>
677
+ <p class="MsoNormal">Key</p>
678
+ <p class="MsoNormal" style="page-break-after:avoid;">
679
+ <b>Key</b>
680
+ </p>
681
+ <div class="figdl" style="page-break-after:avoid;">
682
+ <table class="figdl">
683
+ <tr>
684
+ <td align="left" valign="top">
685
+ <p align="left" class="MsoNormal" style="margin-left:0pt;text-align:left;">
686
+ <p class="MsoNormal">A</p>
687
+ </p>
688
+ </td>
689
+ <td valign="top">
690
+ <p class="MsoNormal">B</p>
691
+ </td>
692
+ </tr>
693
+ </table>
694
+ </div>
695
+ <p class="FigureTitle" style="text-align:center;"/>
696
+ </div>
697
+ </div>
698
+ </div>
560
699
  OUTPUT
561
700
  end
562
701
 
563
- it "processes boilerplate" do
564
- input = <<~INPUT
565
- <iso-standard xmlns="http://riboseinc.com/isoxml">
702
+ it "processes boilerplate" do
703
+ input = <<~INPUT
704
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
566
705
  <bibdata type="standard">
567
- <status><stage>30</stage></status>
706
+ <status>
707
+ <stage>30</stage>
708
+ </status>
568
709
  </bibdata>
569
- <boilerplate>
570
- <copyright-statement>
571
- <clause>
572
- <p id="boilerplate-year">
573
- © ISO 2019, Published in Switzerland
574
- </p>
575
-
576
- <p id="boilerplate-message">
577
- I am the Walrus.
578
- </p>
579
-
580
- <p id="boilerplate-name">ISO copyright office</p>
581
- <p id="boilerplate-address" align="left">
582
- ISO copyright office<br/>
583
- Ch. de Blandonnet 8 ?~@? CP 401<br/>
584
- CH-1214 Vernier, Geneva, Switzerland<br/>
585
- Tel. + 41 22 749 01 11<br/>
586
- Fax + 41 22 749 09 47<br/>
587
- copyright@iso.org<br/>
588
- www.iso.org
589
- </p>
590
- </clause>
591
- </copyright-statement>
592
-
593
-
594
- <license-statement>
595
- <clause>
596
- <title>Warning for Stuff</title>
597
-
598
- <p>This document is not an ISO International Standard. It is distributed for review and
599
- comment. It is subject to change without notice and may not be referred to as
600
- an International Standard.</p>
601
-
602
- <p>Recipients
603
- of this draft are invited to submit, with their comments, notification of any
604
- relevant patent rights of which they are aware and to provide supporting
605
- documentation.</p>
606
- </clause>
607
- </license-statement>
608
-
609
- </boilerplate>
610
- </iso-standard>
710
+ <boilerplate>
711
+ <copyright-statement>
712
+ <clause>
713
+ <p id="boilerplate-year">© ISO 2019, Published in Switzerland</p>
714
+ <p id="boilerplate-message">I am the Walrus.</p>
715
+ <p id="boilerplate-name">ISO copyright office</p>
716
+ <p align="left" id="boilerplate-address">ISO copyright office
717
+ <br/>
718
+ Ch. de Blandonnet 8 ?~@? CP 401
719
+ <br/>
720
+ CH-1214 Vernier, Geneva, Switzerland
721
+ <br/>
722
+ Tel. + 41 22 749 01 11
723
+ <br/>
724
+ Fax + 41 22 749 09 47
725
+ <br/>
726
+ copyright@iso.org
727
+ <br/>
728
+ www.iso.org</p>
729
+ </clause>
730
+ </copyright-statement>
731
+ <license-statement>
732
+ <clause>
733
+ <title>Warning for Stuff</title>
734
+ <p>This document is not an ISO International Standard. It is distributed for review and
735
+ comment. It is subject to change without notice and may not be referred to as
736
+ an International Standard.</p>
737
+ <p>Recipients
738
+ of this draft are invited to submit, with their comments, notification of any
739
+ relevant patent rights of which they are aware and to provide supporting
740
+ documentation.</p>
741
+ </clause>
742
+ </license-statement>
743
+ </boilerplate>
744
+ </iso-standard>
611
745
  INPUT
612
746
 
613
747
  presxml = <<~OUTPUT
614
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
615
- <bibdata type="standard">
616
- <status><stage language="">30</stage></status>
617
- </bibdata>
618
- <boilerplate>
619
- <copyright-statement>
620
- <clause inline-header="true">
621
- <p id="boilerplate-year">
622
- &#xA9; ISO 2019, Published in Switzerland
623
- </p>
624
-
625
- <p id="boilerplate-message">
626
- I am the Walrus.
627
- </p>
628
-
629
- <p id="boilerplate-name">ISO copyright office</p>
630
- <p id="boilerplate-address" align="left">
631
- ISO copyright office<br/>
632
- Ch. de Blandonnet 8 ?~@? CP 401<br/>
633
- CH-1214 Vernier, Geneva, Switzerland<br/>
634
- Tel. + 41 22 749 01 11<br/>
635
- Fax + 41 22 749 09 47<br/>
636
- copyright@iso.org<br/>
637
- www.iso.org
638
- </p>
639
- </clause>
640
- </copyright-statement>
641
-
642
-
643
- <license-statement>
644
- <clause>
645
- <title depth="1">Warning for Stuff</title>
646
-
647
- <p>This document is not an ISO International Standard. It is distributed for review and
648
- comment. It is subject to change without notice and may not be referred to as
649
- an International Standard.</p>
650
-
651
- <p>Recipients
652
- of this draft are invited to submit, with their comments, notification of any
653
- relevant patent rights of which they are aware and to provide supporting
654
- documentation.</p>
655
- </clause>
656
- </license-statement>
657
-
658
- </boilerplate>
659
- </iso-standard>
748
+ <iso-standard type="presentation" xmlns="http://riboseinc.com/isoxml">
749
+ <bibdata type="standard">
750
+ <status>
751
+ <stage language="">30</stage>
752
+ </status>
753
+ </bibdata>
754
+ <boilerplate>
755
+ <copyright-statement>
756
+ <clause inline-header="true">
757
+ <p id="boilerplate-year">© ISO 2019, Published in Switzerland
758
+ </p>
759
+ <p id="boilerplate-message">I am the Walrus.
760
+ </p>
761
+ <p id="boilerplate-name">ISO copyright office</p>
762
+ <p align="left" id="boilerplate-address">ISO copyright office
763
+ <br/>
764
+ Ch. de Blandonnet 8 ?~@? CP 401
765
+ <br/>
766
+ CH-1214 Vernier, Geneva, Switzerland
767
+ <br/>
768
+ Tel. + 41 22 749 01 11
769
+ <br/>
770
+ Fax + 41 22 749 09 47
771
+ <br/>
772
+ copyright@iso.org
773
+ <br/>
774
+ www.iso.org</p>
775
+ </clause>
776
+ </copyright-statement>
777
+ <license-statement>
778
+ <clause>
779
+ <title depth="1">Warning for Stuff</title>
780
+ <p>This document is not an ISO International Standard. It is distributed for review and
781
+ comment. It is subject to change without notice and may not be referred to as
782
+ an International Standard.</p>
783
+ <p>Recipients
784
+ of this draft are invited to submit, with their comments, notification of any
785
+ relevant patent rights of which they are aware and to provide supporting
786
+ documentation.</p>
787
+ </clause>
788
+ </license-statement>
789
+ </boilerplate>
790
+ </iso-standard>
660
791
  OUTPUT
661
792
 
662
- FileUtils.rm_f "test.doc"
663
- FileUtils.rm_f "test.html"
664
- expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", input, true)).sub(%r{<localized-strings>.*</localized-strings>}m, "")).to be_equivalent_to xmlpp(presxml)
665
- IsoDoc::Iso::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", presxml, false)
793
+ expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new(WORD_HTML_CSS.dup)
794
+ .convert("test", input, true))
795
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
796
+ .to be_equivalent_to xmlpp(presxml)
797
+
798
+ IsoDoc::Iso::HtmlConvert.new(WORD_HTML_CSS.dup).convert("test", presxml, false)
799
+
666
800
  word = File.read("test.html", encoding: "UTF-8")
667
801
  expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
668
802
  expect((word)).to include "I am the Walrus."
669
- IsoDoc::Iso::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", presxml, false)
803
+
804
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", presxml, false)
670
805
  word = File.read("test.doc", encoding: "UTF-8")
671
- expect(xmlpp(word.sub(%r{^.*<div class="boilerplate-copyright">}m, '<div class="boilerplate-copyright">').sub(%r{</div>.*$}m, '</div></div>'))).to be_equivalent_to xmlpp(<<~"OUTPUT")
672
- <div class='boilerplate-copyright'>
673
- <div>
674
- <p class='zzCopyright'>
675
- <a name='boilerplate-year' id='boilerplate-year'/>
676
- &#xA9; ISO 2019, Published in Switzerland
677
- </p>
678
- <p class='zzCopyright1'>
679
- <a name='boilerplate-message' id='boilerplate-message'/>
680
- I am the Walrus.
681
- </p>
682
- <p class='zzCopyright'>
683
- <a name='boilerplate-name' id='boilerplate-name'/>
684
- ISO copyright office
685
- </p>
686
- <p style='text-align:left;' align='left' class='zzAddress'>
687
- <a name='boilerplate-address' id='boilerplate-address'/>
688
- ISO copyright office
689
- <br/>
806
+ 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")
809
+ <div class="boilerplate-copyright">
810
+ <div>
811
+ <p class="zzCopyright">
812
+ <a id="boilerplate-year" name="boilerplate-year"/>© ISO 2019, Published in Switzerland#{' '}</p>
813
+ <p class="zzCopyright1">
814
+ <a id="boilerplate-message" name="boilerplate-message"/>I am the Walrus.#{' '}</p>
815
+ <p class="zzCopyright">
816
+ <a id="boilerplate-name" name="boilerplate-name"/>ISO copyright office</p>
817
+ <p align="left" class="zzAddress" style="text-align:left;">
818
+ <a id="boilerplate-address" name="boilerplate-address"/>ISO copyright office
819
+
820
+ <br/>
690
821
  Ch. de Blandonnet 8 ?~@? CP 401
691
- <br/>
822
+
823
+ <br/>
692
824
  CH-1214 Vernier, Geneva, Switzerland
693
- <br/>
825
+
826
+ <br/>
694
827
  Tel. + 41 22 749 01 11
695
- <br/>
828
+
829
+ <br/>
696
830
  Fax + 41 22 749 09 47
697
- <br/>
831
+
832
+ <br/>
698
833
  copyright@iso.org
699
- <br/>
700
- www.iso.org
701
- </p>
702
- </div>
703
- </div>
704
- OUTPUT
705
- expect(word).to include '<p class="zzWarning">This document is not an ISO International Standard'
706
- end
707
834
 
708
- it "populates Word ToC" do
709
- FileUtils.rm_f "test.doc"
710
- IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", wordintropage: "spec/assets/wordintro.html"}).convert("test", <<~"INPUT", false)
711
- <iso-standard xmlns="http://riboseinc.com/isoxml">
835
+ <br/>
836
+ www.iso.org#{' '}</p>
837
+ </div>
838
+ </div>
839
+ OUTPUT
840
+ expect(word).to include '<p class="zzWarning">This document is not an ISO International Standard'
841
+ end
842
+
843
+ 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">
712
846
  <sections>
713
- <clause id="A" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
714
- <title>Introduction<bookmark id="Q"/> to this<fn reference="1">
715
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
716
- </fn></title>
717
- </clause>
718
- <clause id="O" inline-header="false" obligation="normative">
719
- <title>Clause 4.2</title>
720
- <p>A<fn reference="1">
721
- <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p>
722
- </fn></p>
723
- <clause id="P" inline-header="false" obligation="normative">
724
- <title>Clause 4.2.1</title>
725
- </clause>
726
- </clause></clause>
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>
865
+ </clause>
866
+ </clause>
867
+ </clause>
727
868
  </sections>
728
- </iso-standard>
869
+ </iso-standard>
729
870
  INPUT
730
- word = File.read("test.doc").sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">').
731
- sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
871
+ word = File.read("test.doc")
872
+ .sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
873
+ .sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
874
+
732
875
  expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc"))).to be_equivalent_to xmlpp(<<~'OUTPUT')
733
- <div class="WordSection2">
734
- An empty word intro page.
735
-
736
- <p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes">&#xA0;</span>TOC
737
- \o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
738
- <span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
739
- <a href="#_Toc">Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
740
- <span style="mso-tab-count:1 dotted">. </span>
741
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
742
- <span style="mso-element:field-begin"></span></span>
743
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
744
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
745
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
746
- <p class="MsoToc2">
747
- <span class="MsoHyperlink">
748
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
749
- <a href="#_Toc">Introduction to this<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
750
- <span style="mso-tab-count:1 dotted">. </span>
751
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
752
- <span style="mso-element:field-begin"></span></span>
753
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
754
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
755
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
756
- </span>
757
- </p>
758
- <p class="MsoToc2">
759
- <span class="MsoHyperlink">
760
- <span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
761
- <a href="#_Toc">Clause 4.2<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
762
- <span style="mso-tab-count:1 dotted">. </span>
763
- </span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
764
- <span style="mso-element:field-begin"></span></span>
765
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
766
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
767
- <span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
768
- </span>
769
- </p>
770
- <p class="MsoToc1">
771
- <span lang="EN-GB" xml:lang="EN-GB">
772
- <span style="mso-element:field-end"></span>
773
- </span>
774
- <span lang="EN-GB" xml:lang="EN-GB">
775
- <p class="MsoNormal">&#xA0;</p>
776
- </span>
777
- </p>
778
- <p class="MsoNormal">&#xA0;</p>
779
- </div>
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>
902
+ </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>
924
+ </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>
946
+ </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>
780
959
  OUTPUT
781
960
  end
782
-
783
961
  end