isodoc 0.5.5 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +46 -0
  3. data/LICENSE +25 -0
  4. data/README.adoc +1 -1
  5. data/Rakefile +6 -0
  6. data/isodoc.gemspec +1 -0
  7. data/lib/isodoc.rb +4 -95
  8. data/lib/isodoc/cleanup.rb +14 -10
  9. data/lib/isodoc/{notes.rb → comments.rb} +0 -73
  10. data/lib/isodoc/convert.rb +97 -0
  11. data/lib/isodoc/footnotes.rb +74 -0
  12. data/lib/isodoc/html.rb +41 -4
  13. data/lib/isodoc/i18n-en.yaml +1 -0
  14. data/lib/isodoc/i18n-fr.yaml +1 -0
  15. data/lib/isodoc/i18n-zh-Hans.yaml +1 -0
  16. data/lib/isodoc/i18n.rb +1 -0
  17. data/lib/isodoc/inline.rb +4 -12
  18. data/lib/isodoc/iso2wordhtml.rb +26 -13
  19. data/lib/isodoc/metadata.rb +23 -10
  20. data/lib/isodoc/references.rb +20 -22
  21. data/lib/isodoc/section.rb +4 -3
  22. data/lib/isodoc/table.rb +0 -2
  23. data/lib/isodoc/terms.rb +2 -13
  24. data/lib/isodoc/utils.rb +24 -3
  25. data/lib/isodoc/version.rb +1 -1
  26. data/lib/isodoc/wordconvert/comments.rb +155 -0
  27. data/lib/isodoc/wordconvert/convert.rb +31 -0
  28. data/lib/isodoc/wordconvert/footnotes.rb +80 -0
  29. data/lib/isodoc/wordconvert/wordconvertmodule.rb +212 -0
  30. data/lib/isodoc/xref_gen.rb +50 -79
  31. data/lib/isodoc/xref_sect_gen.rb +82 -0
  32. data/spec/assets/header.html +7 -0
  33. data/spec/assets/html.css +2 -0
  34. data/spec/assets/htmlcover.html +4 -0
  35. data/spec/assets/htmlintro.html +5 -0
  36. data/spec/assets/i18n.yaml +2 -0
  37. data/spec/assets/iso.xml +8 -0
  38. data/spec/assets/rice_image1.png +0 -0
  39. data/spec/assets/std.css +2 -0
  40. data/spec/assets/word.css +2 -0
  41. data/spec/assets/wordcover.html +3 -0
  42. data/spec/assets/wordintro.html +4 -0
  43. data/spec/isodoc/blocks_spec.rb +130 -47
  44. data/spec/isodoc/cleanup_spec.rb +693 -0
  45. data/spec/isodoc/footnotes_spec.rb +282 -0
  46. data/spec/isodoc/i18n_spec.rb +662 -0
  47. data/spec/isodoc/inline_spec.rb +344 -0
  48. data/spec/isodoc/lists_spec.rb +81 -18
  49. data/spec/isodoc/metadata_spec.rb +141 -0
  50. data/spec/isodoc/postproc_spec.rb +444 -0
  51. data/spec/isodoc/ref_spec.rb +158 -0
  52. data/spec/isodoc/section_spec.rb +275 -112
  53. data/spec/isodoc/table_spec.rb +146 -8
  54. data/spec/isodoc/terms_spec.rb +118 -0
  55. data/spec/isodoc/xref_spec.rb +490 -114
  56. metadata +46 -4
  57. data/lib/isodoc/postprocessing.rb +0 -176
@@ -0,0 +1,344 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe IsoDoc do
4
+ it "processes inline formatting" do
5
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
6
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
7
+ <foreword>
8
+ <p>
9
+ <em>A</em> <strong>B</strong> <sup>C</sup> <sub>D</sub> <tt>E</tt>
10
+ <strike>F</strike> <smallcap>G</smallcap> <br/> <hr/>
11
+ <bookmark id="H"/> <pagebreak/>
12
+ </p>
13
+ </foreword>
14
+ <sections>
15
+ </iso-standard>
16
+ INPUT
17
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
18
+ <head>
19
+ <title>test</title>
20
+ <body lang="EN-US" link="blue" vlink="#954F72">
21
+ <div class="WordSection1">
22
+ <p>&#160;</p>
23
+ </div>
24
+ <br/>
25
+ <div class="WordSection2">
26
+ <br/>
27
+ <div>
28
+ <h1 class="ForewordTitle">Foreword</h1>
29
+ <p>
30
+ <i>A</i> <b>B</b> <sup>C</sup> <sub>D</sub> <tt>E</tt>
31
+ <s>F</s> <span style="font-variant:small-caps;">G</span> <br/> <hr/>
32
+ <a id="H"/> <br/>
33
+ </p>
34
+ </div>
35
+ <p>&#160;</p>
36
+ </div>
37
+ <br/>
38
+ <div class="WordSection3">
39
+ <p class="zzSTDTitle1"/>
40
+ </div>
41
+ </body>
42
+ </head>
43
+ </html>
44
+ OUTPUT
45
+ end
46
+
47
+ it "processes links" do
48
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
49
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
50
+ <foreword>
51
+ <p>
52
+ <link target="http://example.com"/>
53
+ <link target="http://example.com">example</link>
54
+ </p>
55
+ </foreword>
56
+ <sections>
57
+ </iso-standard>
58
+ INPUT
59
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
60
+ <head>
61
+ <title>test</title>
62
+ <body lang="EN-US" link="blue" vlink="#954F72">
63
+ <div class="WordSection1">
64
+ <p>&#160;</p>
65
+ </div>
66
+ <br/>
67
+ <div class="WordSection2">
68
+ <br/>
69
+ <div>
70
+ <h1 class="ForewordTitle">Foreword</h1>
71
+ <p>
72
+ <a href="http://example.com">http://example.com</a>
73
+ <a href="http://example.com">example</a>
74
+ </p>
75
+ </div>
76
+ <p>&#160;</p>
77
+ </div>
78
+ <br/>
79
+ <div class="WordSection3">
80
+ <p class="zzSTDTitle1"/>
81
+ </div>
82
+ </body>
83
+ </head>
84
+ </html>
85
+ OUTPUT
86
+ end
87
+
88
+ it "processes unrecognised markup" do
89
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
90
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
91
+ <foreword>
92
+ <p>
93
+ <barry fred="http://example.com">example</barry>
94
+ </p>
95
+ </foreword>
96
+ <sections>
97
+ </iso-standard>
98
+ INPUT
99
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
100
+ <head>
101
+ <title>test</title>
102
+ <body lang="EN-US" link="blue" vlink="#954F72">
103
+ <div class="WordSection1">
104
+ <p>&#160;</p>
105
+ </div>
106
+ <br/>
107
+ <div class="WordSection2">
108
+ <br/>
109
+ <div>
110
+ <h1 class="ForewordTitle">Foreword</h1>
111
+ <p>
112
+ <para><b role="strong">&lt;barry fred="http://example.com"&gt;example&lt;/barry&gt;</b></para>
113
+ </p>
114
+ </div>
115
+ <p>&#160;</p>
116
+ </div>
117
+ <br/>
118
+ <div class="WordSection3">
119
+ <p class="zzSTDTitle1"/>
120
+ </div>
121
+ </body>
122
+ </head>
123
+ </html>
124
+ OUTPUT
125
+ end
126
+
127
+ it "processes AsciiMath and MathML" do
128
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
129
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
130
+ <foreword>
131
+ <p>
132
+ <stem type="AsciiMath">A</stem>
133
+ <stem type="MathML"><m:math><m:row>X</m:row></m:math></stem>
134
+ <stem type="None">Latex?</stem>
135
+ </p>
136
+ </foreword>
137
+ <sections>
138
+ </iso-standard>
139
+ INPUT
140
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
141
+ <head>
142
+ <title>test</title>
143
+ <body lang="EN-US" link="blue" vlink="#954F72">
144
+ <div class="WordSection1">
145
+ <p>&#160;</p>
146
+ </div>
147
+ <br/>
148
+ <div class="WordSection2">
149
+ <br/>
150
+ <div>
151
+ <h1 class="ForewordTitle">Foreword</h1>
152
+ <p>
153
+ <span class="stem">(#(A)#)</span>
154
+ <span class="stem"><m:math>
155
+ <m:row>X</m:row>
156
+ </m:math></span>
157
+ <span class="stem">Latex?</span>
158
+ </p>
159
+ </div>
160
+ <p>&#160;</p>
161
+ </div>
162
+ <br/>
163
+ <div class="WordSection3">
164
+ <p class="zzSTDTitle1"/>
165
+ </div>
166
+ </body>
167
+ </head>
168
+ </html>
169
+ OUTPUT
170
+ end
171
+
172
+ it "overrides AsciiMath delimiters" do
173
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
174
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
175
+ <foreword>
176
+ <p>
177
+ <stem type="AsciiMath">A</stem>
178
+ (#((Hello))#)
179
+ </p>
180
+ </foreword>
181
+ <sections>
182
+ </iso-standard>
183
+ INPUT
184
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
185
+ <head>
186
+ <title>test</title>
187
+ <body lang="EN-US" link="blue" vlink="#954F72">
188
+ <div class="WordSection1">
189
+ <p>&#160;</p>
190
+ </div>
191
+ <br/>
192
+ <div class="WordSection2">
193
+ <br/>
194
+ <div>
195
+ <h1 class="ForewordTitle">Foreword</h1>
196
+ <p>
197
+ <span class="stem">(#(((A)#)))</span>
198
+ (#((Hello))#)
199
+ </p>
200
+ </div>
201
+ <p>&#160;</p>
202
+ </div>
203
+ <br/>
204
+ <div class="WordSection3">
205
+ <p class="zzSTDTitle1"/>
206
+ </div>
207
+ </body>
208
+ </head>
209
+ </html>
210
+ OUTPUT
211
+ end
212
+
213
+ it "processes eref types" do
214
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
215
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
216
+ <foreword>
217
+ <p>
218
+ <eref type="footnote" bibitemid="ISO712" citeas="ISO 712">A</stem>
219
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</stem>
220
+ </p>
221
+ </foreword>
222
+ <references id="_normative_references" obligation="informative"><title>Normative References</title>
223
+ <bibitem id="ISO712" type="standard">
224
+ <title format="text/plain">Cereals and cereal products</title>
225
+ <docidentifier>ISO 712</docidentifier>
226
+ <contributor>
227
+ <role type="publisher"/>
228
+ <organization>
229
+ <abbreviation>ISO</abbreviation>
230
+ </organization>
231
+ </contributor>
232
+ </bibitem>
233
+ </references>
234
+ </iso-standard>
235
+ INPUT
236
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
237
+ <head>
238
+ <title>test</title>
239
+ <body lang="EN-US" link="blue" vlink="#954F72">
240
+ <div class="WordSection1">
241
+ <p>&#160;</p>
242
+ </div>
243
+ <br/>
244
+ <div class="WordSection2">
245
+ <br/>
246
+ <div>
247
+ <h1 class="ForewordTitle">Foreword</h1>
248
+ <p>
249
+ <sup><a href="#ISO712">A</a></sup>
250
+ <a href="#ISO712">A</a>
251
+ </p>
252
+ </div>
253
+ <p>&#160;</p>
254
+ </div>
255
+ <br/>
256
+ <div class="WordSection3">
257
+ <p class="zzSTDTitle1"/>
258
+ <div>
259
+ <h1>2.&#160; Normative References</h1>
260
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
261
+ <p id="ISO712">ISO 712, <i> Cereals and cereal products</i></p>
262
+ </div>
263
+ </div>
264
+ </body>
265
+ </head>
266
+ </html>
267
+ OUTPUT
268
+ end
269
+
270
+ it "processes eref content" do
271
+ expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
272
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
273
+ <foreword>
274
+ <p>
275
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712"/>
276
+ <eref type="inline" bibitemid="ISO712"/>
277
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
278
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref>
279
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality><locality type="table"><referenceFrom>1</referenceFrom></locality></eref>
280
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1</referenceFrom></locality></eref>
281
+ <eref type="inline" bibitemid="ISO712"><locality type="clause"><referenceFrom>1.5</referenceFrom></locality></eref>
282
+ <eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom></locality>A</eref>
283
+ <eref type="inline" bibitemid="ISO712"><locality type="whole"></locality></eref>
284
+ <eref type="inline" bibitemid="ISO712" citeas="ISO 712">A</eref>
285
+ </p>
286
+ </foreword>
287
+ <references id="_normative_references" obligation="informative"><title>Normative References</title>
288
+ <bibitem id="ISO712" type="standard">
289
+ <title format="text/plain">Cereals and cereal products</title>
290
+ <docidentifier>ISO 712</docidentifier>
291
+ <contributor>
292
+ <role type="publisher"/>
293
+ <organization>
294
+ <abbreviation>ISO</abbreviation>
295
+ </organization>
296
+ </contributor>
297
+ </bibitem>
298
+ </references>
299
+ </iso-standard>
300
+ INPUT
301
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
302
+ <head>
303
+ <title>test</title>
304
+ <body lang="EN-US" link="blue" vlink="#954F72">
305
+ <div class="WordSection1">
306
+ <p>&#160;</p>
307
+ </div>
308
+ <br/>
309
+ <div class="WordSection2">
310
+ <br/>
311
+ <div>
312
+ <h1 class="ForewordTitle">Foreword</h1>
313
+ <p>
314
+ <a href="#ISO712">ISO 712</a>
315
+ <a href="#ISO712">ISO 712</a>
316
+ <a href="#ISO712">ISO 712, Table 1</a>
317
+ <a href="#ISO712">ISO 712, Table 1&#8211;1</a>
318
+ <a href="#ISO712">ISO 712, Clause 1, Table 1</a>
319
+ <a href="#ISO712">ISO 712, Clause 1</a>
320
+ <a href="#ISO712">ISO 712, 1.5</a>
321
+ <a href="#ISO712">A</a>
322
+ <a href="#ISO712">ISO 712, </a>
323
+ <a href="#ISO712">A</a>
324
+ </p>
325
+ </div>
326
+ <p>&#160;</p>
327
+ </div>
328
+ <br/>
329
+ <div class="WordSection3">
330
+ <p class="zzSTDTitle1"/>
331
+ <div>
332
+ <h1>2.&#160; Normative References</h1>
333
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
334
+ <p id="ISO712">ISO 712, <i> Cereals and cereal products</i></p>
335
+ </div>
336
+ </div>
337
+ </body>
338
+ </head>
339
+ </html>
340
+ OUTPUT
341
+ end
342
+
343
+
344
+ end
@@ -23,9 +23,9 @@ RSpec.describe IsoDoc do
23
23
  <div class="WordSection1">
24
24
  <p>&#160;</p>
25
25
  </div>
26
- <br clear="all" class="section"/>
26
+ <br/>
27
27
  <div class="WordSection2">
28
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
28
+ <br/>
29
29
  <div>
30
30
  <h1 class="ForewordTitle">Foreword</h1>
31
31
  <ul>
@@ -39,7 +39,7 @@ RSpec.describe IsoDoc do
39
39
  </div>
40
40
  <p>&#160;</p>
41
41
  </div>
42
- <br clear="all" class="section"/>
42
+ <br/>
43
43
  <div class="WordSection3">
44
44
  <p class="zzSTDTitle1"/>
45
45
  </div>
@@ -49,7 +49,7 @@ RSpec.describe IsoDoc do
49
49
  OUTPUT
50
50
  end
51
51
 
52
- it "processes ordered lists" do
52
+ it "processes ordered lists" do
53
53
  expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
54
54
  <iso-standard xmlns="http://riboseinc.com/isoxml">
55
55
  <foreword>
@@ -78,9 +78,9 @@ RSpec.describe IsoDoc do
78
78
  <div class="WordSection1">
79
79
  <p>&#160;</p>
80
80
  </div>
81
- <br clear="all" class="section"/>
81
+ <br/>
82
82
  <div class="WordSection2">
83
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
83
+ <br/>
84
84
  <div>
85
85
  <h1 class="ForewordTitle">Foreword</h1>
86
86
  <ol type="a">
@@ -101,15 +101,15 @@ RSpec.describe IsoDoc do
101
101
  </div>
102
102
  <p>&#160;</p>
103
103
  </div>
104
- <br clear="all" class="section"/>
104
+ <br/>
105
105
  <div class="WordSection3">
106
106
  <p class="zzSTDTitle1"/>
107
107
  </div>
108
108
  </body>
109
109
  </head>
110
110
  </html>
111
- OUTPUT
112
- end
111
+ OUTPUT
112
+ end
113
113
 
114
114
  it "processes Roman Upper ordered lists" do
115
115
  expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
@@ -136,9 +136,9 @@ end
136
136
  <div class="WordSection1">
137
137
  <p>&#160;</p>
138
138
  </div>
139
- <br clear="all" class="section"/>
139
+ <br/>
140
140
  <div class="WordSection2">
141
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
141
+ <br/>
142
142
  <div>
143
143
  <h1 class="ForewordTitle">Foreword</h1>
144
144
  <ol type="a">
@@ -155,7 +155,7 @@ end
155
155
  </div>
156
156
  <p>&#160;</p>
157
157
  </div>
158
- <br clear="all" class="section"/>
158
+ <br/>
159
159
  <div class="WordSection3">
160
160
  <p class="zzSTDTitle1"/>
161
161
  </div>
@@ -165,7 +165,7 @@ end
165
165
  OUTPUT
166
166
  end
167
167
 
168
- it "processes definition lists" do
168
+ it "processes definition lists" do
169
169
  expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
170
170
  <iso-standard xmlns="http://riboseinc.com/isoxml">
171
171
  <foreword>
@@ -189,9 +189,9 @@ end
189
189
  <div class="WordSection1">
190
190
  <p>&#160;</p>
191
191
  </div>
192
- <br clear="all" class="section"/>
192
+ <br/>
193
193
  <div class="WordSection2">
194
- <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
194
+ <br/>
195
195
  <div>
196
196
  <h1 class="ForewordTitle">Foreword</h1>
197
197
  <dl>
@@ -213,15 +213,78 @@ end
213
213
  </div>
214
214
  <p>&#160;</p>
215
215
  </div>
216
- <br clear="all" class="section"/>
216
+ <br/>
217
217
  <div class="WordSection3">
218
218
  <p class="zzSTDTitle1"/>
219
219
  </div>
220
220
  </body>
221
221
  </head>
222
222
  </html>
223
- OUTPUT
224
- end
223
+ OUTPUT
224
+ end
225
+
226
+ it "processes definition lists (Word)" do
227
+ expect(IsoDoc::WordConvert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
228
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
229
+ <foreword>
230
+ <dl id="_732d3f57-4f88-40bf-9ae9-633891edc395">
231
+ <dt>
232
+ W
233
+ </dt>
234
+ <dd>
235
+ <p id="_05d81174-3a41-44af-94d8-c78b8d2e175d">mass fraction of gelatinized kernels, expressed in per cent</p>
236
+ </dd>
237
+ <dt><stem type="AsciiMath">w</stem></dt>
238
+ <dd><p>??</p></dd>
239
+ </dl>
240
+ </foreword>
241
+ </iso-standard>
242
+ INPUT
243
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
244
+ <head>
245
+ <title>test</title>
246
+ <body lang="EN-US" link="blue" vlink="#954F72">
247
+ <div class="WordSection1">
248
+ <p>&#160;</p>
249
+ </div>
250
+ <br clear="all" class="section"/>
251
+ <div class="WordSection2">
252
+ <br clear="all" style="mso-special-character:line-break;page-break-before:always"/>
253
+ <div>
254
+ <h1 class="ForewordTitle">Foreword</h1>
255
+ <table class="dl">
256
+ <tr>
257
+ <td valign="top" align="left">
258
+ <p style="text-align: left;">
259
+ W
260
+ </p>
261
+ </td>
262
+ <td valign="top">
263
+ <p id="_05d81174-3a41-44af-94d8-c78b8d2e175d">mass fraction of gelatinized kernels, expressed in per cent</p>
264
+ </td>
265
+ </tr>
266
+ <tr>
267
+ <td valign="top" align="left">
268
+ <span class="stem">(#(w)#)</span>
269
+ </td>
270
+ <td valign="top">
271
+ <p>??</p>
272
+ </td>
273
+ </tr>
274
+ </table>
275
+ </div>
276
+ <p>&#160;</p>
277
+ </div>
278
+ <br clear="all" class="section"/>
279
+ <div class="WordSection3">
280
+ <p class="zzSTDTitle1"/>
281
+ </div>
282
+ </body>
283
+ </head>
284
+ </html>
285
+ OUTPUT
286
+ end
287
+
225
288
 
226
289
  end
227
290