metanorma-iso 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) 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 +12 -12
  6. data/lib/asciidoctor/iso/biblio.rng +4 -6
  7. data/lib/asciidoctor/iso/cleanup.rb +1 -1
  8. data/lib/asciidoctor/iso/front.rb +1 -1
  9. data/lib/asciidoctor/iso/front_id.rb +30 -25
  10. data/lib/asciidoctor/iso/isodoc.rng +235 -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 +1 -0
  14. data/lib/asciidoctor/iso/validate_title.rb +21 -13
  15. data/lib/isodoc/iso/base_convert.rb +11 -0
  16. data/lib/isodoc/iso/html/style-human.css +7 -0
  17. data/lib/isodoc/iso/html/style-iso.css +7 -0
  18. data/lib/isodoc/iso/html_convert.rb +0 -1
  19. data/lib/isodoc/iso/i18n-en.yaml +4 -0
  20. data/lib/isodoc/iso/i18n-fr.yaml +4 -0
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +4 -0
  22. data/lib/isodoc/iso/index.rb +140 -0
  23. data/lib/isodoc/iso/iso.amendment.xsl +1010 -324
  24. data/lib/isodoc/iso/iso.international-standard.xsl +1010 -324
  25. data/lib/isodoc/iso/presentation_xml_convert.rb +32 -25
  26. data/lib/isodoc/iso/word_convert.rb +0 -1
  27. data/lib/isodoc/iso/xref.rb +13 -5
  28. data/lib/metanorma/iso/version.rb +1 -1
  29. data/metanorma-iso.gemspec +8 -8
  30. data/spec/asciidoctor/amd_spec.rb +696 -0
  31. data/spec/asciidoctor/base_spec.rb +704 -0
  32. data/spec/asciidoctor/blocks_spec.rb +527 -0
  33. data/spec/asciidoctor/cleanup_spec.rb +1134 -0
  34. data/spec/asciidoctor/inline_spec.rb +195 -0
  35. data/spec/asciidoctor/lists_spec.rb +197 -0
  36. data/spec/asciidoctor/refs_spec.rb +375 -0
  37. data/spec/asciidoctor/section_spec.rb +393 -0
  38. data/spec/asciidoctor/table_spec.rb +329 -0
  39. data/spec/asciidoctor/validate_spec.rb +1572 -0
  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 +338 -314
  45. data/spec/isodoc/metadata_spec.rb +392 -382
  46. data/spec/isodoc/postproc_spec.rb +837 -657
  47. data/spec/isodoc/ref_spec.rb +374 -331
  48. data/spec/isodoc/section_spec.rb +821 -519
  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 +186 -189
  54. metadata +65 -67
  55. data/.rubocop.ribose.yml +0 -66
  56. data/lib/isodoc/iso/html/scripts.html +0 -178
  57. data/spec/asciidoctor-iso/amd_spec.rb +0 -694
  58. data/spec/asciidoctor-iso/base_spec.rb +0 -713
  59. data/spec/asciidoctor-iso/blocks_spec.rb +0 -482
  60. data/spec/asciidoctor-iso/cleanup_spec.rb +0 -1025
  61. data/spec/asciidoctor-iso/inline_spec.rb +0 -170
  62. data/spec/asciidoctor-iso/lists_spec.rb +0 -190
  63. data/spec/asciidoctor-iso/refs_spec.rb +0 -317
  64. data/spec/asciidoctor-iso/section_spec.rb +0 -362
  65. data/spec/asciidoctor-iso/table_spec.rb +0 -313
  66. data/spec/asciidoctor-iso/validate_spec.rb +0 -1619
  67. 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,403 +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"
97
- IsoDoc::Iso::PdfConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("spec/assets/iso.xml", nil, false)
117
+ it "generates Pdf output docs with null configuration from file" do
118
+ mock_pdf
119
+ IsoDoc::Iso::PdfConvert.new(WORD_HTML_CSS.dup).convert("spec/assets/iso.xml", nil, false)
98
120
  expect(File.exist?("spec/assets/iso.pdf")).to be true
99
121
  end
100
122
 
101
123
  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>
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>
116
140
  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, "")
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
+
119
146
  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>
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>
133
169
  OUTPUT
134
170
  end
135
171
 
136
172
  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
-
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>
159
199
  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, "")
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
+
162
205
  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>
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>
170
223
  OUTPUT
171
224
  end
172
225
 
173
226
  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>
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>
181
233
  </bibdata>
182
- </iso-standard>
183
-
234
+ </iso-standard>
184
235
  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" })
188
- 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"')
189
238
  end
190
239
 
191
240
  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">
241
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS_WORDINTRO.dup).convert("test", <<~"INPUT", false)
242
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
195
243
  <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>
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>
208
268
  </sections>
209
- </iso-standard>
210
-
269
+ </iso-standard>
211
270
  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>
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>
266
359
  OUTPUT
267
360
  end
268
361
 
269
362
  it "reorders footnote numbers" do
270
- FileUtils.rm_f "test.html"
271
363
  input = <<~INPUT
272
- <iso-standard xmlns="http://riboseinc.com/isoxml">
364
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
273
365
  <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>
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>
288
389
  </sections>
289
- </iso-standard>
390
+ </iso-standard>
290
391
  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>")
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
+
294
399
  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>
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>
321
437
  OUTPUT
322
438
 
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")
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
+
327
445
  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>
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>
424
528
  OUTPUT
425
529
  end
426
530
 
427
-
428
531
  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>
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>
484
600
  INPUT
485
601
  expect(File.exist?("test.html")).to be true
486
602
  html = File.read("test.html", encoding: "UTF-8")
@@ -488,296 +604,360 @@ RSpec.describe IsoDoc do
488
604
  expect(html).to match(%r{<h2 class="TermNum" id="paddy">1\.2</h2>})
489
605
  end
490
606
 
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>
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>
505
619
  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, "")
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, "")
508
623
  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>
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>
523
643
  OUTPUT
524
644
  end
525
645
 
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">
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">
531
649
  <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>
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>
542
664
  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, "")
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, "")
545
668
  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
-
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>
560
701
  OUTPUT
561
702
  end
562
703
 
563
- it "processes boilerplate" do
564
- input = <<~INPUT
565
- <iso-standard xmlns="http://riboseinc.com/isoxml">
704
+ it "processes boilerplate" do
705
+ input = <<~INPUT
706
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
566
707
  <bibdata type="standard">
567
- <status><stage>30</stage></status>
708
+ <status>
709
+ <stage>30</stage>
710
+ </status>
568
711
  </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>
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>
611
747
  INPUT
612
748
 
613
749
  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>
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>
660
793
  OUTPUT
661
794
 
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)
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
+
666
802
  word = File.read("test.html", encoding: "UTF-8")
667
803
  expect((word)).to include '<h1 class="IntroTitle">Warning for Stuff</h1>'
668
804
  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)
805
+
806
+ IsoDoc::Iso::WordConvert.new(WORD_HTML_CSS.dup).convert("test", presxml, false)
670
807
  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/>
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/>
690
823
  Ch. de Blandonnet 8 ?~@? CP 401
691
- <br/>
824
+
825
+ <br/>
692
826
  CH-1214 Vernier, Geneva, Switzerland
693
- <br/>
827
+
828
+ <br/>
694
829
  Tel. + 41 22 749 01 11
695
- <br/>
830
+
831
+ <br/>
696
832
  Fax + 41 22 749 09 47
697
- <br/>
833
+
834
+ <br/>
698
835
  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
836
 
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">
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">
712
848
  <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>
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>
727
870
  </sections>
728
- </iso-standard>
871
+ </iso-standard>
729
872
  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, "")
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
+
732
877
  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>
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>
780
961
  OUTPUT
781
962
  end
782
-
783
963
  end