isodoc 1.6.4 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/.rubocop.yml +1 -1
  4. data/isodoc.gemspec +2 -1
  5. data/lib/isodoc-yaml/i18n-ar.yaml +19 -25
  6. data/lib/isodoc-yaml/i18n-de.yaml +1 -0
  7. data/lib/isodoc-yaml/i18n-en.yaml +2 -0
  8. data/lib/isodoc-yaml/i18n-es.yaml +1 -0
  9. data/lib/isodoc-yaml/i18n-fr.yaml +2 -0
  10. data/lib/isodoc-yaml/i18n-ru.yaml +1 -0
  11. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +2 -0
  12. data/lib/isodoc/convert.rb +4 -2
  13. data/lib/isodoc/function/blocks.rb +6 -5
  14. data/lib/isodoc/function/references.rb +33 -52
  15. data/lib/isodoc/function/section.rb +0 -1
  16. data/lib/isodoc/function/table.rb +21 -22
  17. data/lib/isodoc/function/terms.rb +6 -7
  18. data/lib/isodoc/gem_tasks.rb +8 -9
  19. data/lib/isodoc/html_convert.rb +5 -1
  20. data/lib/isodoc/html_function/comments.rb +12 -12
  21. data/lib/isodoc/html_function/html.rb +2 -2
  22. data/lib/isodoc/html_function/postprocess.rb +195 -185
  23. data/lib/isodoc/html_function/sectionsplit.rb +244 -0
  24. data/lib/isodoc/metadata.rb +22 -20
  25. data/lib/isodoc/metadata_contributor.rb +31 -28
  26. data/lib/isodoc/presentation_function/bibdata.rb +7 -0
  27. data/lib/isodoc/presentation_function/block.rb +7 -4
  28. data/lib/isodoc/presentation_function/inline.rb +7 -12
  29. data/lib/isodoc/presentation_function/section.rb +38 -1
  30. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  31. data/lib/isodoc/version.rb +1 -1
  32. data/lib/isodoc/xref.rb +10 -7
  33. data/lib/isodoc/xref/xref_anchor.rb +45 -44
  34. data/lib/isodoc/xref/xref_counter.rb +113 -103
  35. data/lib/isodoc/xref/xref_gen.rb +39 -11
  36. data/spec/isodoc/blocks_spec.rb +184 -447
  37. data/spec/isodoc/cleanup_spec.rb +40 -42
  38. data/spec/isodoc/i18n_spec.rb +694 -821
  39. data/spec/isodoc/inline_spec.rb +197 -208
  40. data/spec/isodoc/metadata_spec.rb +384 -379
  41. data/spec/isodoc/postproc_spec.rb +121 -30
  42. data/spec/isodoc/presentation_xml_spec.rb +4 -4
  43. data/spec/isodoc/ref_spec.rb +5 -5
  44. data/spec/isodoc/section_spec.rb +216 -199
  45. data/spec/isodoc/sectionsplit_spec.rb +190 -0
  46. data/spec/isodoc/table_spec.rb +41 -42
  47. data/spec/isodoc/terms_spec.rb +1 -1
  48. data/spec/isodoc/xref_spec.rb +684 -1020
  49. metadata +19 -3
@@ -344,6 +344,62 @@ RSpec.describe IsoDoc do
344
344
  expect(word).to match(%r{Anta&#x16D;parolo</h1>})
345
345
  end
346
346
 
347
+ it "cleans up HTML output preface placeholder paragraphs" do
348
+ FileUtils.rm_f "test.doc"
349
+ FileUtils.rm_f "test.html"
350
+ IsoDoc::HtmlConvert.new(
351
+ { bodyfont: "Zapf",
352
+ monospacefont: "Consolas",
353
+ headerfont: "Comic Sans",
354
+ normalfontsize: "30pt",
355
+ monospacefontsize: "29pt",
356
+ smallerfontsize: "28pt",
357
+ footnotefontsize: "27pt",
358
+ htmlstylesheet: "spec/assets/html.scss",
359
+ htmlstylesheet_override: "spec/assets/html_override.css",
360
+ htmlcoverpage: "spec/assets/htmlcover.html",
361
+ htmlintropage: "spec/assets/htmlintro.html",
362
+ scripts: "spec/assets/scripts.html",
363
+ scripts_override: "spec/assets/scripts_override.html",
364
+ i18nyaml: "spec/assets/i18n.yaml",
365
+ ulstyle: "l1",
366
+ olstyle: "l2" },
367
+ ).convert("test", <<~"INPUT", false)
368
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
369
+ <preface><foreword>
370
+ <note>
371
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
372
+ </note>
373
+ </foreword></preface>
374
+ </iso-standard>
375
+ INPUT
376
+ html = Nokogiri::XML(File.read("test.html")).at("//body")
377
+ html.xpath("//script").each(&:remove)
378
+ expect(html.to_xml).to be_equivalent_to <<~OUTPUT
379
+ <body lang="en" xml:lang="en">
380
+ <div class="title-section">
381
+ /* an empty html cover page */
382
+ </div>
383
+ <br/>
384
+ <div class="prefatory-section">
385
+ /* an empty html intro page */
386
+ <ul id="toc-list"/>
387
+ </div>
388
+ <br/>
389
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
390
+ <br/>
391
+ <div>
392
+ <h1 class="ForewordTitle">Anta&#x16D;parolo</h1>
393
+ <div class="Note">
394
+ <p>&#xA0; These results are based on a study carried out on three different types of kernel.</p>
395
+ </div>
396
+ </div>
397
+ <p class="zzSTDTitle1"/>
398
+ </main>
399
+ </body>
400
+ OUTPUT
401
+ end
402
+
347
403
  it "converts definition lists to tables for Word" do
348
404
  FileUtils.rm_f "test.doc"
349
405
  FileUtils.rm_f "test.html"
@@ -1000,14 +1056,15 @@ RSpec.describe IsoDoc do
1000
1056
  it "encodes images in HTML as data URIs" do
1001
1057
  FileUtils.rm_f "test.html"
1002
1058
  FileUtils.rm_rf "test_htmlimages"
1003
- IsoDoc::HtmlConvert.new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true)
1059
+ IsoDoc::HtmlConvert
1060
+ .new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true)
1004
1061
  .convert("test", <<~"INPUT", false)
1005
1062
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1006
1063
  <preface><foreword>
1007
1064
  <figure id="_">
1008
1065
  <name>Split-it-right sample divider</name>
1009
- <image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/>
1010
- <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
1066
+ <image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/>
1067
+ <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
1011
1068
  </figure>
1012
1069
  </foreword></preface>
1013
1070
  </iso-standard>
@@ -1015,7 +1072,8 @@ RSpec.describe IsoDoc do
1015
1072
  html = File.read("test.html")
1016
1073
  .sub(/^.*<main class="main-section">/m, '<main class="main-section">')
1017
1074
  .sub(%r{</main>.*$}m, "</main>")
1018
- expect(xmlpp(html.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
1075
+ expect(xmlpp(html
1076
+ .gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
1019
1077
  .to be_equivalent_to xmlpp(<<~"OUTPUT")
1020
1078
  <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
1021
1079
  <br />
@@ -1034,7 +1092,8 @@ RSpec.describe IsoDoc do
1034
1092
  it "encodes images in HTML as data URIs, using relative file location" do
1035
1093
  FileUtils.rm_f "spec/test.html"
1036
1094
  FileUtils.rm_rf "spec/test_htmlimages"
1037
- IsoDoc::HtmlConvert.new({ htmlstylesheet: "assets/html.scss", datauriimage: true })
1095
+ IsoDoc::HtmlConvert
1096
+ .new({ htmlstylesheet: "assets/html.scss", datauriimage: true })
1038
1097
  .convert("spec/test", <<~"INPUT", false)
1039
1098
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1040
1099
  <preface><foreword>
@@ -1049,7 +1108,8 @@ RSpec.describe IsoDoc do
1049
1108
  html = File.read("spec/test.html")
1050
1109
  .sub(/^.*<main class="main-section">/m, '<main class="main-section">')
1051
1110
  .sub(%r{</main>.*$}m, "</main>")
1052
- expect(xmlpp(html.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
1111
+ expect(xmlpp(html
1112
+ .gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
1053
1113
  .to be_equivalent_to xmlpp(<<~"OUTPUT")
1054
1114
  <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
1055
1115
  <br />
@@ -1273,17 +1333,17 @@ RSpec.describe IsoDoc do
1273
1333
  it "does not lose HTML escapes in postprocessing" do
1274
1334
  FileUtils.rm_f "test.doc"
1275
1335
  FileUtils.rm_f "test.html"
1276
- IsoDoc::HtmlConvert.new(options)
1277
- .convert("test", <<~"INPUT", false)
1278
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1279
- <preface><foreword>
1280
- <sourcecode id="samplecode">
1281
- <name>XML code</name>
1282
- &lt;xml&gt; &amp;
1283
- </sourcecode>
1284
- </foreword></preface>
1285
- </iso-standard>
1286
- INPUT
1336
+ input = <<~INPUT
1337
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1338
+ <preface><foreword>
1339
+ <sourcecode id="samplecode">
1340
+ <name>XML code</name>
1341
+ &lt;xml&gt; &amp;
1342
+ </sourcecode>
1343
+ </foreword></preface>
1344
+ </iso-standard>
1345
+ INPUT
1346
+ IsoDoc::HtmlConvert.new(options).convert("test", input, false)
1287
1347
  html = File.read("test.html")
1288
1348
  .sub(/^.*<main class="main-section">/m, '<main class="main-section">')
1289
1349
  .sub(%r{</main>.*$}m, "</main>")
@@ -1299,22 +1359,10 @@ RSpec.describe IsoDoc do
1299
1359
  <p class="zzSTDTitle1"></p>
1300
1360
  </main>
1301
1361
  OUTPUT
1302
- end
1303
1362
 
1304
- it "does not lose HTML escapes in postprocessing (Word)" do
1305
1363
  FileUtils.rm_f "test.doc"
1306
1364
  FileUtils.rm_f "test.html"
1307
- IsoDoc::WordConvert.new(options)
1308
- .convert("test", <<~"INPUT", false)
1309
- <iso-standard xmlns="http://riboseinc.com/isoxml">
1310
- <preface><foreword>
1311
- <sourcecode id="samplecode">
1312
- <name>XML code</name>
1313
- &lt;xml&gt; &amp;
1314
- </sourcecode>
1315
- </foreword></preface>
1316
- </iso-standard>
1317
- INPUT
1365
+ IsoDoc::WordConvert.new(options).convert("test", input, false)
1318
1366
  word = File.read("test.doc")
1319
1367
  .sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
1320
1368
  .sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
@@ -2247,4 +2295,47 @@ RSpec.describe IsoDoc do
2247
2295
  .sub(%r{(<script/>\s+)+}m, "<script/>")
2248
2296
  expect(xmlpp(html)).to be_equivalent_to xmlpp(output)
2249
2297
  end
2298
+
2299
+ it "cleans up lists (HTML)" do
2300
+ input = <<~INPUT
2301
+ <html xmlns:epub="http://www.idpf.org/2007/ops">
2302
+ <head/>
2303
+ <body>
2304
+ <div class="main-section">
2305
+ <ul>
2306
+ <div>N1</div>
2307
+ <li>A</li>
2308
+ <li>B</li>
2309
+ <div>N2</div>
2310
+ <li>C</li>
2311
+ <div>N3</div>
2312
+ </div>
2313
+ </body>
2314
+ </html>
2315
+ INPUT
2316
+ output = <<~OUTPUT
2317
+ <main class='main-section'>
2318
+ <button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
2319
+ <ul>
2320
+ <li>
2321
+ A
2322
+ <div>N1</div>
2323
+ </li>
2324
+ <li>
2325
+ B
2326
+ <div>N2</div>
2327
+ </li>
2328
+ <li>
2329
+ C
2330
+ <div>N3</div>
2331
+ </li>
2332
+ </ul>
2333
+ </main>
2334
+ OUTPUT
2335
+ expect(xmlpp(IsoDoc::HtmlConvert
2336
+ .new(htmlstylesheet: "spec/assets/html.scss", filename: "test")
2337
+ .html_cleanup(Nokogiri::XML(input)).to_xml)
2338
+ .sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
2339
+ .to be_equivalent_to xmlpp(output)
2340
+ end
2250
2341
  end
@@ -40,7 +40,7 @@ RSpec.describe IsoDoc do
40
40
  <title language='en'>test</title>
41
41
  </bibdata>
42
42
  <preface>
43
- <p>
43
+ <p displayorder="1">
44
44
  64,212,149,677,264,515
45
45
  642,121,496,772,645.15 30,000
46
46
  <stem type='MathML'>
@@ -256,7 +256,7 @@ RSpec.describe IsoDoc do
256
256
  </bibdata>
257
257
 
258
258
  <preface>
259
- <p>
259
+ <p displayorder="1">
260
260
  30,000
261
261
  <stem type='MathML'>
262
262
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -405,7 +405,7 @@ RSpec.describe IsoDoc do
405
405
  <language current='true'>fr</language>
406
406
  </bibdata>
407
407
  <preface>
408
- <p>
408
+ <p displayorder="1">
409
409
  30&#x202F;000
410
410
  <stem type='MathML'>
411
411
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -521,7 +521,7 @@ RSpec.describe IsoDoc do
521
521
  </bibdata>
522
522
 
523
523
  <preface>
524
- <p>
524
+ <p displayorder="1">
525
525
  30'000
526
526
  <stem type='MathML'>
527
527
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
@@ -125,7 +125,7 @@ RSpec.describe IsoDoc do
125
125
  <language current="true">en</language>
126
126
  </bibdata>
127
127
  <preface>
128
- <foreword>
128
+ <foreword displayorder="1">
129
129
  <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
130
130
  <eref bibitemid='ISO712'>[110]</eref>
131
131
  <eref bibitemid='ISBN'>[1]</eref>
@@ -139,7 +139,7 @@ RSpec.describe IsoDoc do
139
139
  </foreword>
140
140
  </preface>
141
141
  <bibliography>
142
- <references id='_normative_references' obligation='informative' normative='true'>
142
+ <references id='_normative_references' obligation='informative' normative='true' displayorder="2">
143
143
  <title depth='1'>1.<tab/>Normative References</title>
144
144
  <p>
145
145
  The following documents are referred to in the text in such a way that
@@ -219,7 +219,7 @@ RSpec.describe IsoDoc do
219
219
  <docidentifier type='metanorma'>[5]</docidentifier>
220
220
  </bibitem>
221
221
  </references>
222
- <references id='_bibliography' obligation='informative' normative='false'>
222
+ <references id='_bibliography' obligation='informative' normative='false' displayorder="3">
223
223
  <title depth="1">Bibliography</title>
224
224
  <bibitem id='ISBN' type='ISBN'>
225
225
  <title format='text/plain'>Chemicals for analytical laboratory use</title>
@@ -278,7 +278,7 @@ RSpec.describe IsoDoc do
278
278
  </bibitem>
279
279
  <bibitem id='ref11'>
280
280
  <title>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</title>
281
- <docidentifier type='IETF'>RFC 10</docidentifier>
281
+ <docidentifier type='IETF'>IETF RFC 10</docidentifier>
282
282
  </bibitem>
283
283
  <bibitem id='ref12'>
284
284
  <formattedref format='application/x-isodoc+xml'>
@@ -287,7 +287,7 @@ RSpec.describe IsoDoc do
287
287
  .
288
288
  </formattedref>
289
289
  <docidentifier type='metanorma'>[Citn]</docidentifier>
290
- <docidentifier type='IETF'>RFC 20</docidentifier>
290
+ <docidentifier type='IETF'>IETF RFC 20</docidentifier>
291
291
  </bibitem>
292
292
  </references>
293
293
  </bibliography>
@@ -129,30 +129,32 @@ RSpec.describe IsoDoc do
129
129
  end
130
130
 
131
131
  it "processes document with no content" do
132
- expect(xmlpp(IsoDoc::HtmlConvert.new({})
133
- .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
134
- <iso-standard xmlns="http://riboseinc.com/isoxml">
135
- <preface/>
136
- <sections/>
137
- </iso-standard>
132
+ input = <<~INPUT
133
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
134
+ <preface/>
135
+ <sections/>
136
+ </iso-standard>
138
137
  INPUT
139
- <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
140
- <head/>
141
- <body lang="en">
142
- <div class="title-section">
143
- <p>&#160;</p>
144
- </div>
145
- <br/>
146
- <div class="prefatory-section">
147
- <p>&#160;</p>
148
- </div>
149
- <br/>
150
- <div class="main-section">
151
- <p class="zzSTDTitle1"/>
152
- </div>
153
- </body>
154
- </html>
138
+ output = <<~OUTPUT
139
+ <html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
140
+ <head/>
141
+ <body lang="en">
142
+ <div class="title-section">
143
+ <p>&#160;</p>
144
+ </div>
145
+ <br/>
146
+ <div class="prefatory-section">
147
+ <p>&#160;</p>
148
+ </div>
149
+ <br/>
150
+ <div class="main-section">
151
+ <p class="zzSTDTitle1"/>
152
+ </div>
153
+ </body>
154
+ </html>
155
155
  OUTPUT
156
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
157
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
156
158
  end
157
159
 
158
160
  it "processes section names" do
@@ -261,50 +263,50 @@ RSpec.describe IsoDoc do
261
263
  INPUT
262
264
 
263
265
  presxml = <<~"PRESXML"
264
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
266
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
265
267
  <boilerplate>
266
268
  <copyright-statement>
267
269
  <clause>
268
- <title depth="1">Copyright</title>
270
+ <title depth='1'>Copyright</title>
269
271
  </clause>
270
272
  </copyright-statement>
271
273
  <license-statement>
272
274
  <clause>
273
- <title depth="1">License</title>
275
+ <title depth='1'>License</title>
274
276
  </clause>
275
277
  </license-statement>
276
278
  <legal-statement>
277
279
  <clause>
278
- <title depth="1">Legal</title>
280
+ <title depth='1'>Legal</title>
279
281
  </clause>
280
282
  </legal-statement>
281
283
  <feedback-statement>
282
284
  <clause>
283
- <title depth="1">Feedback</title>
285
+ <title depth='1'>Feedback</title>
284
286
  </clause>
285
287
  </feedback-statement>
286
288
  </boilerplate>
287
289
  <preface>
288
- <abstract obligation='informative'>
290
+ <abstract obligation='informative' displayorder='1'>
289
291
  <title>Abstract</title>
290
292
  </abstract>
291
- <foreword obligation='informative'>
293
+ <foreword obligation='informative' displayorder='2'>
292
294
  <title>Foreword</title>
293
295
  <p id='A'>This is a preamble</p>
294
296
  </foreword>
295
- <introduction id='B' obligation='informative'>
297
+ <introduction id='B' obligation='informative' displayorder='3'>
296
298
  <title>Introduction</title>
297
299
  <clause id='C' inline-header='false' obligation='informative'>
298
300
  <title depth='2'>Introduction Subsection</title>
299
301
  </clause>
300
302
  </introduction>
301
- <clause id='B1'>
303
+ <clause id='B1' displayorder='4'>
302
304
  <title depth='1'>Dedication</title>
303
305
  </clause>
304
- <clause id='B2'>
306
+ <clause id='B2' displayorder='5'>
305
307
  <title depth='1'>Note to reader</title>
306
308
  </clause>
307
- <acknowledgements obligation='informative'>
309
+ <acknowledgements obligation='informative' displayorder='6'>
308
310
  <title>Acknowledgements</title>
309
311
  </acknowledgements>
310
312
  </preface>
@@ -316,11 +318,11 @@ RSpec.describe IsoDoc do
316
318
  <admonition id='NN2' type='warning'>
317
319
  <p>Initial admonition</p>
318
320
  </admonition>
319
- <clause id='D' obligation='normative' type='scope'>
321
+ <clause id='D' obligation='normative' type='scope' displayorder='7'>
320
322
  <title depth='1'>1.<tab/>Scope</title>
321
323
  <p id='E'>Text</p>
322
324
  </clause>
323
- <clause id='H' obligation='normative'>
325
+ <clause id='H' obligation='normative' displayorder='9'>
324
326
  <title depth='1'>3.<tab/>Terms, Definitions, Symbols and Abbreviated Terms</title>
325
327
  <terms id='I' obligation='normative'>
326
328
  <title depth='2'>3.1.<tab/>Normal Terms</title>
@@ -330,21 +332,21 @@ RSpec.describe IsoDoc do
330
332
  </term>
331
333
  </terms>
332
334
  <definitions id='K'>
333
- <title depth='2'>3.2.<tab/>Definitions</title>
335
+ <title depth='2'>3.2.<tab/>Definitions</title>
334
336
  <dl>
335
337
  <dt>Symbol</dt>
336
338
  <dd>Definition</dd>
337
339
  </dl>
338
340
  </definitions>
339
341
  </clause>
340
- <definitions id='L'>
341
- <title depth='1'>4.<tab/>Symbols and abbreviated terms</title>
342
+ <definitions id='L' displayorder='10'>
343
+ <title depth='1'>4.<tab/>Symbols and abbreviated terms</title>
342
344
  <dl>
343
345
  <dt>Symbol</dt>
344
346
  <dd>Definition</dd>
345
347
  </dl>
346
348
  </definitions>
347
- <clause id='M' inline-header='false' obligation='normative'>
349
+ <clause id='M' inline-header='false' obligation='normative' displayorder='11'>
348
350
  <title depth='1'>5.<tab/>Clause 4</title>
349
351
  <clause id='N' inline-header='false' obligation='normative'>
350
352
  <title depth='2'>5.1.<tab/>Introduction</title>
@@ -357,8 +359,14 @@ RSpec.describe IsoDoc do
357
359
  </clause>
358
360
  </clause>
359
361
  </sections>
360
- <annex id='P' inline-header='false' obligation='normative'>
361
- <title> <strong>Annex A</strong><br/>(normative)<br/><br/><strong>Annex</strong>
362
+ <annex id='P' inline-header='false' obligation='normative' displayorder='12'>
363
+ <title>
364
+ <strong>Annex A</strong>
365
+ <br/>
366
+ (normative)
367
+ <br/>
368
+ <br/>
369
+ <strong>Annex</strong>
362
370
  </title>
363
371
  <clause id='Q' inline-header='false' obligation='normative'>
364
372
  <title depth='2'>A.1.<tab/>Annex A.1</title>
@@ -370,17 +378,21 @@ RSpec.describe IsoDoc do
370
378
  </references>
371
379
  </clause>
372
380
  </annex>
373
- <annex id='P1' inline-header='false' obligation='normative'>
374
- <title><strong>Annex B</strong><br/>(normative)</title>
381
+ <annex id='P1' inline-header='false' obligation='normative' displayorder='13'>
382
+ <title>
383
+ <strong>Annex B</strong>
384
+ <br/>
385
+ (normative)
386
+ </title>
375
387
  </annex>
376
388
  <bibliography>
377
- <references id='R' obligation='informative' normative='true'>
378
- <title depth='1'>2.<tab/>Normative References</title>
389
+ <references id='R' obligation='informative' normative='true' displayorder='8'>
390
+ <title depth='1'>2.<tab/>Normative References</title>
379
391
  </references>
380
- <clause id='S' obligation='informative'>
392
+ <clause id='S' obligation='informative' displayorder='14'>
381
393
  <title depth='1'>Bibliography</title>
382
394
  <references id='T' obligation='informative' normative='false'>
383
- <title depth="2">Bibliography Subsection</title>
395
+ <title depth='2'>Bibliography Subsection</title>
384
396
  </references>
385
397
  </clause>
386
398
  </bibliography>
@@ -691,96 +703,95 @@ RSpec.describe IsoDoc do
691
703
  end
692
704
 
693
705
  it "processes section names suppressing section numbering" do
694
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true })
695
- .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
696
- <iso-standard xmlns="http://riboseinc.com/isoxml">
697
- <preface>
698
- <foreword obligation="informative">
699
- <title>Foreword</title>
700
- <p id="A">This is a preamble</p>
701
- </foreword>
702
- <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
703
- <title>Introduction Subsection</title>
704
- </clause>
705
- </introduction></preface><sections>
706
- <clause id="D" obligation="normative" type="scope">
707
- <title>Scope</title>
708
- <p id="E">Text</p>
709
- </clause>
706
+ input = <<~INPUT
707
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
708
+ <preface>
709
+ <foreword obligation="informative">
710
+ <title>Foreword</title>
711
+ <p id="A">This is a preamble</p>
712
+ </foreword>
713
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause id="C" inline-header="false" obligation="informative">
714
+ <title>Introduction Subsection</title>
715
+ </clause>
716
+ </introduction></preface><sections>
717
+ <clause id="D" obligation="normative" type="scope">
718
+ <title>Scope</title>
719
+ <p id="E">Text</p>
720
+ </clause>
710
721
 
711
- <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
712
- <title>Normal Terms</title>
713
- <term id="J">
714
- <preferred>Term2</preferred>
715
- </term>
716
- </terms>
717
- <definitions id="K">
718
- <dl>
719
- <dt>Symbol</dt>
720
- <dd>Definition</dd>
721
- </dl>
722
- </definitions>
723
- </clause>
724
- <definitions id="L">
725
- <dl>
726
- <dt>Symbol</dt>
727
- <dd>Definition</dd>
728
- </dl>
729
- </definitions>
730
- <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
731
- <title>Introduction</title>
732
- </clause>
733
- <clause id="O" inline-header="false" obligation="normative">
734
- <title>Clause 4.2</title>
735
- </clause>
736
- <clause id="O1" inline-header="false" obligation="normative">
737
- </clause>
738
- </clause>
722
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
723
+ <title>Normal Terms</title>
724
+ <term id="J">
725
+ <preferred>Term2</preferred>
726
+ </term>
727
+ </terms>
728
+ <definitions id="K">
729
+ <dl>
730
+ <dt>Symbol</dt>
731
+ <dd>Definition</dd>
732
+ </dl>
733
+ </definitions>
734
+ </clause>
735
+ <definitions id="L">
736
+ <dl>
737
+ <dt>Symbol</dt>
738
+ <dd>Definition</dd>
739
+ </dl>
740
+ </definitions>
741
+ <clause id="M" inline-header="false" obligation="normative"><title>Clause 4</title><clause id="N" inline-header="false" obligation="normative">
742
+ <title>Introduction</title>
743
+ </clause>
744
+ <clause id="O" inline-header="false" obligation="normative">
745
+ <title>Clause 4.2</title>
746
+ </clause>
747
+ <clause id="O1" inline-header="false" obligation="normative">
748
+ </clause>
749
+ </clause>
739
750
 
740
- </sections><annex id="P" inline-header="false" obligation="normative">
741
- <title>Annex</title>
742
- <clause id="Q" inline-header="false" obligation="normative">
743
- <title>Annex A.1</title>
744
- <clause id="Q1" inline-header="false" obligation="normative">
745
- <title>Annex A.1a</title>
746
- </clause>
747
- </clause>
748
- </annex><bibliography><references id="R" obligation="informative" normative="true">
749
- <title>Normative References</title>
750
- </references><clause id="S" obligation="informative">
751
- <title>Bibliography</title>
752
- <references id="T" obligation="informative" normative="false">
753
- <title>Bibliography Subsection</title>
754
- </references>
755
- </clause>
756
- </bibliography>
757
- </iso-standard>
751
+ </sections><annex id="P" inline-header="false" obligation="normative">
752
+ <title>Annex</title>
753
+ <clause id="Q" inline-header="false" obligation="normative">
754
+ <title>Annex A.1</title>
755
+ <clause id="Q1" inline-header="false" obligation="normative">
756
+ <title>Annex A.1a</title>
757
+ </clause>
758
+ </clause>
759
+ </annex><bibliography><references id="R" obligation="informative" normative="true">
760
+ <title>Normative References</title>
761
+ </references><clause id="S" obligation="informative">
762
+ <title>Bibliography</title>
763
+ <references id="T" obligation="informative" normative="false">
764
+ <title>Bibliography Subsection</title>
765
+ </references>
766
+ </clause>
767
+ </bibliography>
768
+ </iso-standard>
758
769
  INPUT
759
- <?xml version='1.0'?>
760
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
770
+ output = <<~OUTPUT
771
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
761
772
  <preface>
762
- <foreword obligation='informative'>
773
+ <foreword obligation='informative' displayorder='1'>
763
774
  <title>Foreword</title>
764
775
  <p id='A'>This is a preamble</p>
765
776
  </foreword>
766
- <introduction id='B' obligation='informative'>
777
+ <introduction id='B' obligation='informative' displayorder='2'>
767
778
  <title>Introduction</title>
768
779
  <clause id='C' inline-header='false' obligation='informative'>
769
- <title depth="2">Introduction Subsection</title>
780
+ <title depth='2'>Introduction Subsection</title>
770
781
  </clause>
771
782
  </introduction>
772
783
  </preface>
773
784
  <sections>
774
- <clause id='D' obligation='normative' type="scope">
775
- <title depth="1">Scope</title>
785
+ <clause id='D' obligation='normative' type='scope' displayorder='3'>
786
+ <title depth='1'>Scope</title>
776
787
  <p id='E'>Text</p>
777
788
  </clause>
778
- <clause id='H' obligation='normative'>
779
- <title depth="1">Terms, Definitions, Symbols and Abbreviated Terms</title>
789
+ <clause id='H' obligation='normative' displayorder='5'>
790
+ <title depth='1'>Terms, Definitions, Symbols and Abbreviated Terms</title>
780
791
  <terms id='I' obligation='normative'>
781
- <title depth="2">Normal Terms</title>
792
+ <title depth='2'>Normal Terms</title>
782
793
  <term id='J'>
783
- <name>3.1.1.</name>
794
+ <name>3.1.1.</name>
784
795
  <preferred>Term2</preferred>
785
796
  </term>
786
797
  </terms>
@@ -791,24 +802,24 @@ RSpec.describe IsoDoc do
791
802
  </dl>
792
803
  </definitions>
793
804
  </clause>
794
- <definitions id='L'>
805
+ <definitions id='L' displayorder='6'>
795
806
  <dl>
796
807
  <dt>Symbol</dt>
797
808
  <dd>Definition</dd>
798
809
  </dl>
799
810
  </definitions>
800
- <clause id='M' inline-header='false' obligation='normative'>
801
- <title depth="1">Clause 4</title>
811
+ <clause id='M' inline-header='false' obligation='normative' displayorder='7'>
812
+ <title depth='1'>Clause 4</title>
802
813
  <clause id='N' inline-header='false' obligation='normative'>
803
- <title depth="2">Introduction</title>
814
+ <title depth='2'>Introduction</title>
804
815
  </clause>
805
816
  <clause id='O' inline-header='false' obligation='normative'>
806
- <title depth="2">Clause 4.2</title>
817
+ <title depth='2'>Clause 4.2</title>
807
818
  </clause>
808
819
  <clause id='O1' inline-header='false' obligation='normative'> </clause>
809
820
  </clause>
810
821
  </sections>
811
- <annex id='P' inline-header='false' obligation='normative'>
822
+ <annex id='P' inline-header='false' obligation='normative' displayorder='8'>
812
823
  <title>
813
824
  <strong>Annex A</strong>
814
825
  <br/>
@@ -818,51 +829,55 @@ RSpec.describe IsoDoc do
818
829
  <strong>Annex</strong>
819
830
  </title>
820
831
  <clause id='Q' inline-header='false' obligation='normative'>
821
- <title depth="2">Annex A.1</title>
832
+ <title depth='2'>Annex A.1</title>
822
833
  <clause id='Q1' inline-header='false' obligation='normative'>
823
- <title depth="3">Annex A.1a</title>
834
+ <title depth='3'>Annex A.1a</title>
824
835
  </clause>
825
836
  </clause>
826
837
  </annex>
827
838
  <bibliography>
828
- <references id='R' obligation='informative' normative='true'>
829
- <title depth="1">Normative References</title>
839
+ <references id='R' obligation='informative' normative='true' displayorder='4'>
840
+ <title depth='1'>Normative References</title>
830
841
  </references>
831
- <clause id='S' obligation='informative'>
832
- <title depth="1">Bibliography</title>
842
+ <clause id='S' obligation='informative' displayorder='9'>
843
+ <title depth='1'>Bibliography</title>
833
844
  <references id='T' obligation='informative' normative='false'>
834
- <title depth="2">Bibliography Subsection</title>
845
+ <title depth='2'>Bibliography Subsection</title>
835
846
  </references>
836
847
  </clause>
837
848
  </bibliography>
838
849
  </iso-standard>
839
850
  OUTPUT
851
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true })
852
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
840
853
  end
841
854
 
842
855
  it "processes section titles without ID" do
843
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true })
844
- .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
845
- <iso-standard xmlns="http://riboseinc.com/isoxml">
846
- <preface>
847
- <introduction id="B" obligation="informative"><title>Introduction</title><clause obligation="informative">
848
- <title>Introduction Subsection</title>
849
- </clause>
850
- </introduction>
851
- </preface>
852
- </iso-standard>
856
+ input = <<~INPUT
857
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
858
+ <preface>
859
+ <introduction id="B" obligation="informative"><title>Introduction</title><clause obligation="informative">
860
+ <title>Introduction Subsection</title>
861
+ </clause>
862
+ </introduction>
863
+ </preface>
864
+ </iso-standard>
853
865
  INPUT
854
- <?xml version='1.0'?>
855
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
856
- <preface>
857
- <introduction id='B' obligation='informative'>
858
- <title>Introduction</title>
859
- <clause obligation='informative'>
860
- <title depth="1">Introduction Subsection</title>
861
- </clause>
862
- </introduction>
863
- </preface>
864
- </iso-standard>
866
+ output = <<~OUTPUT
867
+ <?xml version='1.0'?>
868
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
869
+ <preface>
870
+ <introduction id='B' obligation='informative' displayorder="1">
871
+ <title>Introduction</title>
872
+ <clause obligation='informative'>
873
+ <title depth="1">Introduction Subsection</title>
874
+ </clause>
875
+ </introduction>
876
+ </preface>
877
+ </iso-standard>
865
878
  OUTPUT
879
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true })
880
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
866
881
  end
867
882
 
868
883
  it "processes simple terms & definitions" do
@@ -881,7 +896,7 @@ RSpec.describe IsoDoc do
881
896
  presxml = <<~"OUTPUT"
882
897
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
883
898
  <sections>
884
- <terms id='H' obligation='normative'>
899
+ <terms id='H' obligation='normative' displayorder="1">
885
900
  <title depth='1'>1.<tab/>Terms, Definitions, Symbols and Abbreviated Terms</title>
886
901
  <term id='J'>
887
902
  <name>1.1.</name>
@@ -928,7 +943,7 @@ RSpec.describe IsoDoc do
928
943
  presxml = <<~"PRESXML"
929
944
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
930
945
  <sections>
931
- <clause id='M' inline-header='false' obligation='normative'>
946
+ <clause id='M' inline-header='false' obligation='normative' displayorder="1">
932
947
  <title depth='1'>1.<tab/>Clause 4</title>
933
948
  <clause id='N' inline-header='false' obligation='normative'>
934
949
  <title depth='2'>1.1.<tab/>Introduction</title>
@@ -983,7 +998,7 @@ RSpec.describe IsoDoc do
983
998
  <?xml version='1.0'?>
984
999
  <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
985
1000
  <sections>
986
- <clause id='M' inline-header='false' obligation='normative'>
1001
+ <clause id='M' inline-header='false' obligation='normative' displayorder="1">
987
1002
  <title depth="1">Clause 4</title>
988
1003
  <clause id='N' inline-header='false' obligation='normative'>
989
1004
  <title depth="2">Introduction</title>
@@ -998,48 +1013,50 @@ RSpec.describe IsoDoc do
998
1013
  end
999
1014
 
1000
1015
  it "processes sections without titles" do
1001
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1002
- .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1003
- <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1004
- <preface>
1005
- <introduction id="M" inline-header="false" obligation="normative"><clause id="N" inline-header="false" obligation="normative">
1006
- <title>Intro</title>
1007
- </clause>
1008
- <clause id="O" inline-header="true" obligation="normative">
1009
- </clause></clause>
1010
- </preface>
1011
- <sections>
1012
- <clause id="M1" inline-header="false" obligation="normative"><clause id="N1" inline-header="false" obligation="normative">
1013
- </clause>
1014
- <clause id="O1" inline-header="true" obligation="normative">
1015
- </clause></clause>
1016
- </sections>
1016
+ input = <<~INPUT
1017
+ <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1018
+ <preface>
1019
+ <introduction id="M" inline-header="false" obligation="normative"><clause id="N" inline-header="false" obligation="normative">
1020
+ <title>Intro</title>
1021
+ </clause>
1022
+ <clause id="O" inline-header="true" obligation="normative">
1023
+ </clause></clause>
1024
+ </preface>
1025
+ <sections>
1026
+ <clause id="M1" inline-header="false" obligation="normative"><clause id="N1" inline-header="false" obligation="normative">
1027
+ </clause>
1028
+ <clause id="O1" inline-header="true" obligation="normative">
1029
+ </clause></clause>
1030
+ </sections>
1017
1031
 
1018
- </iso-standard>
1019
- INPUT
1020
- <?xml version='1.0'?>
1021
- <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1022
- <preface>
1023
- <introduction id='M' inline-header='false' obligation='normative'>
1024
- <clause id='N' inline-header='false' obligation='normative'>
1025
- <title depth="2">Intro</title>
1026
- </clause>
1027
- <clause id='O' inline-header='true' obligation='normative'> </clause>
1028
- </introduction>
1029
- </preface>
1030
- <sections>
1031
- <clause id='M1' inline-header='false' obligation='normative'>
1032
- <title>1.</title>
1033
- <clause id='N1' inline-header='false' obligation='normative'>
1034
- <title>1.1.</title>
1035
- </clause>
1036
- <clause id='O1' inline-header='true' obligation='normative'>
1037
- <title>1.2.</title>
1038
- </clause>
1032
+ </iso-standard>
1033
+ INPUT
1034
+ output = <<~OUTPUT
1035
+ <?xml version='1.0'?>
1036
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type="presentation">
1037
+ <preface>
1038
+ <introduction id='M' inline-header='false' obligation='normative' displayorder="1">
1039
+ <clause id='N' inline-header='false' obligation='normative'>
1040
+ <title depth="2">Intro</title>
1039
1041
  </clause>
1040
- </sections>
1041
- </iso-standard>
1042
- OUTPUT
1042
+ <clause id='O' inline-header='true' obligation='normative'> </clause>
1043
+ </introduction>
1044
+ </preface>
1045
+ <sections>
1046
+ <clause id='M1' inline-header='false' obligation='normative' displayorder="2">
1047
+ <title>1.</title>
1048
+ <clause id='N1' inline-header='false' obligation='normative'>
1049
+ <title>1.1.</title>
1050
+ </clause>
1051
+ <clause id='O1' inline-header='true' obligation='normative'>
1052
+ <title>1.2.</title>
1053
+ </clause>
1054
+ </clause>
1055
+ </sections>
1056
+ </iso-standard>
1057
+ OUTPUT
1058
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1059
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1043
1060
  end
1044
1061
 
1045
1062
  it "processes clauses containing normative references" do
@@ -1070,7 +1087,7 @@ RSpec.describe IsoDoc do
1070
1087
  presxml = <<~OUTPUT
1071
1088
  <iso-standard xmlns="http://riboseinc.com/isoxml" type="presentation">
1072
1089
  <bibliography>
1073
- <clause id="D" obligation="informative">
1090
+ <clause id="D" obligation="informative" displayorder="2">
1074
1091
  <title depth="1">Bibliography</title>
1075
1092
  <references id="E" obligation="informative" normative="false">
1076
1093
  <title depth="2">Bibliography Subsection 1</title>
@@ -1079,7 +1096,7 @@ RSpec.describe IsoDoc do
1079
1096
  <title depth="2">Bibliography Subsection 2</title>
1080
1097
  </references>
1081
1098
  </clause>
1082
- <clause id="A" obligation="informative"><title depth="1">1.<tab/>First References</title>
1099
+ <clause id="A" obligation="informative" displayorder="1"><title depth="1">1.<tab/>First References</title>
1083
1100
  <references id="B" obligation="informative" normative="true">
1084
1101
  <title depth="2">1.1.<tab/>Normative References 1</title>
1085
1102
  </references>