metanorma-iso 1.7.1 → 1.8.1

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