metanorma-iso 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +142 -10
  3. data/lib/isodoc/iso/base_convert.rb +10 -0
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +170 -252
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +170 -245
  7. data/lib/isodoc/iso/html/isodoc.css +38 -13
  8. data/lib/isodoc/iso/html/isodoc.scss +38 -12
  9. data/lib/isodoc/iso/html/style-human.css +14 -1
  10. data/lib/isodoc/iso/html/style-human.scss +10 -1
  11. data/lib/isodoc/iso/html/style-iso.css +35 -23
  12. data/lib/isodoc/iso/html/style-iso.scss +31 -23
  13. data/lib/isodoc/iso/html/word_iso_intro-dis.html +1 -6
  14. data/lib/isodoc/iso/html/word_iso_titlepage-dis.html +24 -13
  15. data/lib/isodoc/iso/html/word_iso_titlepage-prf.html +58 -0
  16. data/lib/isodoc/iso/html/word_iso_titlepage.html +6 -2
  17. data/lib/isodoc/iso/html_convert.rb +5 -0
  18. data/lib/isodoc/iso/i18n-en.yaml +32 -4
  19. data/lib/isodoc/iso/i18n-fr.yaml +29 -3
  20. data/lib/isodoc/iso/i18n-ru.yaml +32 -4
  21. data/lib/isodoc/iso/i18n-zh-Hans.yaml +32 -3
  22. data/lib/isodoc/iso/i18n.rb +1 -1
  23. data/lib/isodoc/iso/iso.amendment.xsl +332 -187
  24. data/lib/isodoc/iso/iso.international-standard.xsl +332 -187
  25. data/lib/isodoc/iso/metadata.rb +63 -63
  26. data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
  27. data/lib/isodoc/iso/presentation_xml_convert.rb +14 -3
  28. data/lib/isodoc/iso/presentation_xref.rb +8 -2
  29. data/lib/isodoc/iso/sections.rb +1 -1
  30. data/lib/isodoc/iso/word_cleanup.rb +3 -0
  31. data/lib/isodoc/iso/word_convert.rb +6 -3
  32. data/lib/isodoc/iso/word_dis_cleanup.rb +235 -0
  33. data/lib/isodoc/iso/word_dis_convert.rb +47 -108
  34. data/lib/isodoc/iso/xref.rb +34 -6
  35. data/lib/metanorma/iso/base.rb +20 -1
  36. data/lib/metanorma/iso/biblio.rng +32 -34
  37. data/lib/metanorma/iso/boilerplate-fr.xml +3 -0
  38. data/lib/metanorma/iso/boilerplate-ru.xml +3 -0
  39. data/lib/metanorma/iso/boilerplate.xml +3 -0
  40. data/lib/metanorma/iso/cleanup.rb +28 -1
  41. data/lib/metanorma/iso/front.rb +31 -6
  42. data/lib/metanorma/iso/front_id.rb +2 -0
  43. data/lib/metanorma/iso/isodoc.rng +9 -0
  44. data/lib/metanorma/iso/isostandard.rng +30 -12
  45. data/lib/metanorma/iso/macros.rb +29 -0
  46. data/lib/metanorma/iso/version.rb +1 -1
  47. data/spec/isodoc/amd_spec.rb +4 -30
  48. data/spec/isodoc/blocks_spec.rb +499 -2
  49. data/spec/isodoc/i18n_spec.rb +145 -80
  50. data/spec/isodoc/iso_spec.rb +50 -169
  51. data/spec/isodoc/metadata_spec.rb +224 -83
  52. data/spec/isodoc/postproc_spec.rb +41 -5
  53. data/spec/isodoc/section_spec.rb +12 -6
  54. data/spec/isodoc/word_dis_spec.rb +1273 -147
  55. data/spec/isodoc/xref_spec.rb +87 -13
  56. data/spec/metanorma/amd_spec.rb +53 -1
  57. data/spec/metanorma/base_spec.rb +185 -10
  58. data/spec/metanorma/blocks_spec.rb +54 -0
  59. data/spec/metanorma/lists_spec.rb +2 -2
  60. data/spec/metanorma/section_spec.rb +2 -2
  61. data/spec/spec_helper.rb +13 -4
  62. data/spec/vcr_cassettes/withdrawn_iso.yml +27 -27
  63. metadata +7 -8
  64. data/docs/asciiiso-syntax.adoc +0 -307
  65. data/docs/guidance.adoc +0 -487
  66. data/docs/navigation.adoc +0 -23
  67. data/docs/quickstart.adoc +0 -179
  68. data/lib/isodoc/iso/presentation_inline.rb +0 -90
@@ -48,6 +48,52 @@ RSpec.describe IsoDoc do
48
48
  html = File.read("test.doc", encoding: "UTF-8")
49
49
  expect(html).not_to include 'class="AltTerms"'
50
50
  expect(html).to include 'class="AdmittedTerm"'
51
+
52
+ FileUtils.rm_f "test.doc"
53
+ IsoDoc::Iso::WordConvert
54
+ .new({ isowordtemplate: "simple" })
55
+ .convert("test", <<~"INPUT", false)
56
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
57
+ <bibdata>
58
+ <status><stage>50</stage></status>
59
+ </bibdata>
60
+ <sections>
61
+ <terms id="A">
62
+ <term id="B">
63
+ <preferred><expression><name>First</name></expression></preferred>
64
+ <admitted><expression><name>Second</name></expression></admitted>
65
+ </term>
66
+ </terms>
67
+ </sections>
68
+ </iso-standard>
69
+ INPUT
70
+ expect(File.exist?("test.doc")).to be true
71
+ html = File.read("test.doc", encoding: "UTF-8")
72
+ expect(html).to include 'class="AltTerms"'
73
+ expect(html).not_to include 'class="AdmittedTerm"'
74
+
75
+ FileUtils.rm_f "test.doc"
76
+ IsoDoc::Iso::WordConvert
77
+ .new({ isowordtemplate: "dis" })
78
+ .convert("test", <<~"INPUT", false)
79
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
80
+ <bibdata>
81
+ <status><stage>30</stage></status>
82
+ </bibdata>
83
+ <sections>
84
+ <terms id="A">
85
+ <term id="B">
86
+ <preferred><expression><name>First</name></expression></preferred>
87
+ <admitted><expression><name>Second</name></expression></admitted>
88
+ </term>
89
+ </terms>
90
+ </sections>
91
+ </iso-standard>
92
+ INPUT
93
+ expect(File.exist?("test.doc")).to be true
94
+ html = File.read("test.doc", encoding: "UTF-8")
95
+ expect(html).not_to include 'class="AltTerms"'
96
+ expect(html).to include 'class="AdmittedTerm"'
51
97
  end
52
98
 
53
99
  it "deals with span" do
@@ -90,7 +136,7 @@ RSpec.describe IsoDoc do
90
136
  INPUT
91
137
  word = <<~OUTPUT
92
138
  <div class='WordSection3'>
93
- <p class='zzSTDTitle1'/>
139
+ <p class='zzSTDTitle'/>
94
140
  <div id='A'>
95
141
  <h1/>
96
142
  <p>
@@ -122,10 +168,7 @@ RSpec.describe IsoDoc do
122
168
  INPUT
123
169
  word = <<~OUTPUT
124
170
  <div class='WordSection2'>
125
- <div style='mso-element:para-border-div;border:solid windowtext 1.0pt;
126
- border-bottom-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
127
- solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;padding:1.0pt 4.0pt 0cm 4.0pt;
128
- margin-left:5.1pt;margin-right:5.1pt'>
171
+ <div style='mso-element:para-border-div;border:solid windowtext 1.0pt; border-bottom-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt: solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;padding:1.0pt 4.0pt 0cm 4.0pt; margin-left:5.1pt;margin-right:5.1pt'>
129
172
  <div>
130
173
  <a name='boilerplate-copyright-destination' id='boilerplate-copyright-destination'/>
131
174
  </div>
@@ -175,15 +218,10 @@ RSpec.describe IsoDoc do
175
218
  INPUT
176
219
  word = <<~OUTPUT
177
220
  <div class='WordSection2'>
178
- <div style='mso-element:para-border-div;border:solid windowtext 1.0pt;
179
- border-bottom-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
180
- solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;padding:1.0pt 4.0pt 0cm 4.0pt;
181
- margin-left:5.1pt;margin-right:5.1pt'>
182
221
  <div>
183
222
  <a name='boilerplate-copyright-destination' id='boilerplate-copyright-destination'/>
184
- </div>
185
223
  </div>
186
- <p class='zzContents' style='margin-top:0cm'>
224
+ <p class='zzContents'>
187
225
  <span lang='EN-GB' xml:lang='EN-GB'>Contents</span>
188
226
  </p>
189
227
  <p class='MsoBodyText'>
@@ -236,7 +274,7 @@ RSpec.describe IsoDoc do
236
274
  INPUT
237
275
  word = <<~OUTPUT
238
276
  <div class='WordSection3'>
239
- <p class='zzSTDTitle1'/>
277
+ <p class='zzSTDTitle'/>
240
278
  <div>
241
279
  <h1>Normative References</h1>
242
280
  <p class='MsoBodyText'>
@@ -289,15 +327,10 @@ RSpec.describe IsoDoc do
289
327
  INPUT
290
328
  word = <<~OUTPUT
291
329
  <div class='WordSection2'>
292
- <div style='mso-element:para-border-div;border:solid windowtext 1.0pt;
293
- border-bottom-alt:solid windowtext .5pt;mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:
294
- solid windowtext .5pt;mso-border-right-alt:solid windowtext .5pt;padding:1.0pt 4.0pt 0cm 4.0pt;
295
- margin-left:5.1pt;margin-right:5.1pt'>
296
330
  <div>
297
331
  <a name='boilerplate-copyright-destination' id='boilerplate-copyright-destination'/>
298
332
  </div>
299
- </div>
300
- <p class='zzContents' style='margin-top:0cm'>
333
+ <p class='zzContents'>
301
334
  <span lang='EN-GB' xml:lang='EN-GB'>Contents</span>
302
335
  </p>
303
336
  <p class='MsoBodyText'>
@@ -371,63 +404,63 @@ RSpec.describe IsoDoc do
371
404
  <clause id="A"><p>
372
405
  <ol>
373
406
  <li><p>A</p></li>
374
- <li><p>A</p></li>
375
- <ol>
376
- <li>A</li>
377
- <li>A</li>
407
+ <li><p>B</p></li>
408
+ <li><ol>
409
+ <li>C</li>
410
+ <li>D</li>
378
411
  <li><ol>
379
- <li>A</li>
380
- <li>A</li>
412
+ <li>E</li>
413
+ <li>F</li>
381
414
  <li><ol>
382
- <li>A</li>
383
- <li>A</li>
415
+ <li>G</li>
416
+ <li>H</li>
384
417
  <li><ol>
385
- <li>A</li>
386
- <li>A</li>
418
+ <li>I</li>
419
+ <li>J</li>
387
420
  <li><ol>
388
- <li>A</li>
389
- <li>A</li>
390
- <li>A</li>
421
+ <li>K</li>
422
+ <li>L</li>
423
+ <li>M</li>
391
424
  </ol></li>
392
- <li>A</li>
425
+ <li>N</li>
393
426
  </ol></li>
394
- <li>A</li>
427
+ <li>O</li>
395
428
  </ol></li>
396
- <li>A</li>
429
+ <li>P</li>
397
430
  </ol></li>
398
- <li>A</li>
431
+ <li>Q</li>
399
432
  </ol></li>
400
- <li>A</li>
433
+ <li>R</li>
401
434
  </ol>
402
435
  <ul>
403
436
  <li><p>A</p></li>
404
- <li><p>A</p></li>
405
- <li><ul>
406
- <li>A</li>
407
- <li>A</li>
437
+ <li><p>B</p></li>
438
+ <li><p>B1</p><ul>
439
+ <li>C</li>
440
+ <li>D</li>
408
441
  <li><ul>
409
- <li>A</li>
410
- <li>A</li>
442
+ <li>E</li>
443
+ <li>F</li>
411
444
  <li><ul>
412
- <li>A</li>
413
- <li>A</li>
445
+ <li>G</li>
446
+ <li>H</li>
414
447
  <li><ul>
415
- <li>A</li>
416
- <li>A</li>
448
+ <li>I</li>
449
+ <li>J</li>
417
450
  <li><ul>
418
- <li>A</li>
419
- <li>A</li>
420
- <li>A</li>
451
+ <li>K</li>
452
+ <li>L</li>
453
+ <li>M</li>
421
454
  </ul></li>
422
- <li>A</li>
455
+ <li>N</li>
423
456
  </ul></li>
424
- <li>A</li>
457
+ <li>O</li>
425
458
  </ul></li>
426
- <li>A</li>
459
+ <li>P</li>
427
460
  </ul></li>
428
- <li>A</li>
461
+ <li>Q</li>
429
462
  </ul></li>
430
- <li>A</li>
463
+ <li>R</li>
431
464
  </ul>
432
465
  </p></clause>
433
466
  </sections>
@@ -435,71 +468,356 @@ RSpec.describe IsoDoc do
435
468
  INPUT
436
469
  word = <<~OUTPUT
437
470
  <div class='WordSection3'>
438
- <p class='zzSTDTitle1'/>
471
+ <p class='zzSTDTitle'/>
439
472
  <div>
440
473
  <a name='A' id='A'/>
441
- <h1/>
442
- <p class='MsoBodyText'>
443
- <p style='mso-list:l2 level1 lfo2;' class='ListNumber1'>A</p>
444
- <p style='mso-list:l2 level1 lfo2;' class='ListNumber1'>A</p>
445
- <p style='mso-list:l2 level1 lfo3;' class='ListNumber1'>A</p>
446
- <p style='mso-list:l2 level1 lfo3;' class='ListNumber1'>A</p>
447
- <p style='mso-list:l2 level1 lfo3;' class='ListNumber1'>
448
- <p style='mso-list:l2 level2 lfo3;' class='MsoListNumber2'>A</p>
449
- <p style='mso-list:l2 level2 lfo3;' class='MsoListNumber2'>A</p>
450
- <p style='mso-list:l2 level2 lfo3;' class='MsoListNumber2'>
451
- <p style='mso-list:l2 level3 lfo3;' class='MsoListNumber3'>A</p>
452
- <p style='mso-list:l2 level3 lfo3;' class='MsoListNumber3'>A</p>
453
- <p style='mso-list:l2 level3 lfo3;' class='MsoListNumber3'>
454
- <p style='mso-list:l2 level4 lfo3;' class='MsoListNumber4'>A</p>
455
- <p style='mso-list:l2 level4 lfo3;' class='MsoListNumber4'>A</p>
456
- <p style='mso-list:l2 level4 lfo3;' class='MsoListNumber4'>
457
- <p style='mso-list:l2 level5 lfo3;' class='MsoListNumber5'>A</p>
458
- <p style='mso-list:l2 level5 lfo3;' class='MsoListNumber5'>A</p>
459
- <p style='mso-list:l2 level5 lfo3;' class='MsoListNumber5'>A</p>
460
- </p>
461
- <p style='mso-list:l2 level4 lfo3;' class='MsoListNumber4'>A</p>
462
- </p>
463
- <p style='mso-list:l2 level3 lfo3;' class='MsoListNumber3'>A</p>
464
- </p>
465
- <p style='mso-list:l2 level2 lfo3;' class='MsoListNumber2'>A</p>
466
- </p>
467
- <p style='mso-list:l2 level1 lfo3;' class='ListNumber1'>A</p>
468
- <li class='MsoNormal'>A</li>
469
- </p>
470
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
471
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
472
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>
473
- <p style='mso-list:l3 level2 lfo1;' class='MsoListContinue2'>A</p>
474
- <p style='mso-list:l3 level2 lfo1;' class='MsoListContinue2'>A</p>
475
- <p style='mso-list:l3 level2 lfo1;' class='MsoListContinue2'>
476
- <p style='mso-list:l3 level3 lfo1;' class='MsoListContinue3'>A</p>
477
- <p style='mso-list:l3 level3 lfo1;' class='MsoListContinue3'>A</p>
478
- <p style='mso-list:l3 level3 lfo1;' class='MsoListContinue3'>
479
- <p style='mso-list:l3 level4 lfo1;' class='MsoListContinue4'>A</p>
480
- <p style='mso-list:l3 level4 lfo1;' class='MsoListContinue4'>A</p>
481
- <p style='mso-list:l3 level4 lfo1;' class='MsoListContinue4'>
482
- <p style='mso-list:l3 level5 lfo1;' class='MsoListContinue5'>A</p>
483
- <p style='mso-list:l3 level5 lfo1;' class='MsoListContinue5'>A</p>
484
- <p style='mso-list:l3 level5 lfo1;' class='MsoListContinue5'>
485
- <p style='mso-list:l3 level6 lfo1;' class='MsoListContinue5'>A</p>
486
- <p style='mso-list:l3 level6 lfo1;' class='MsoListContinue5'>A</p>
487
- <p style='mso-list:l3 level6 lfo1;' class='MsoListContinue5'>A</p>
488
- </p>
489
- <p style='mso-list:l3 level5 lfo1;' class='MsoListContinue5'>A</p>
490
- </p>
491
- <p style='mso-list:l3 level4 lfo1;' class='MsoListContinue4'>A</p>
492
- </p>
493
- <p style='mso-list:l3 level3 lfo1;' class='MsoListContinue3'>A</p>
494
- </p>
495
- <p style='mso-list:l3 level2 lfo1;' class='MsoListContinue2'>A</p>
474
+ <h1>1</h1>
475
+ <p class='ListNumber1'>
476
+ a)
477
+ <span style='mso-tab-count:1'> </span>
478
+ A
479
+ </p>
480
+ <p class='ListNumber1'>
481
+ b)
482
+ <span style='mso-tab-count:1'> </span>
483
+ B
484
+ </p>
485
+ <p class='MsoListNumber2'>
486
+ 1)
487
+ <span style='mso-tab-count:1'> </span>
488
+ C
489
+ </p>
490
+ <p class='MsoListNumber2'>
491
+ 2)
492
+ <span style='mso-tab-count:1'> </span>
493
+ D
494
+ </p>
495
+ <p class='MsoListNumber3'>
496
+ i)
497
+ <span style='mso-tab-count:1'> </span>
498
+ E
499
+ </p>
500
+ <p class='MsoListNumber3'>
501
+ ii)
502
+ <span style='mso-tab-count:1'> </span>
503
+ F
504
+ </p>
505
+ <p class='MsoListNumber4'>
506
+ A)
507
+ <span style='mso-tab-count:1'> </span>
508
+ G
509
+ </p>
510
+ <p class='MsoListNumber4'>
511
+ B)
512
+ <span style='mso-tab-count:1'> </span>
513
+ H
514
+ </p>
515
+ <p class='MsoListNumber5'>
516
+ I)
517
+ <span style='mso-tab-count:1'> </span>
518
+ I
519
+ </p>
520
+ <p class='MsoListNumber5'>
521
+ II)
522
+ <span style='mso-tab-count:1'> </span>
523
+ J
524
+ </p>
525
+ <p class='MsoListNumber5'>
526
+ a)
527
+ <span style='mso-tab-count:1'> </span>
528
+ K
529
+ </p>
530
+ <p class='MsoListNumber5'>
531
+ b)
532
+ <span style='mso-tab-count:1'> </span>
533
+ L
534
+ </p>
535
+ <p class='MsoListNumber5'>
536
+ c)
537
+ <span style='mso-tab-count:1'> </span>
538
+ M
539
+ </p>
540
+ <p class='MsoListNumber5'>
541
+ III)
542
+ <span style='mso-tab-count:1'> </span>
543
+ N
544
+ </p>
545
+ <p class='MsoListNumber4'>
546
+ C)
547
+ <span style='mso-tab-count:1'> </span>
548
+ O
549
+ </p>
550
+ <p class='MsoListNumber3'>
551
+ iii)
552
+ <span style='mso-tab-count:1'> </span>
553
+ P
554
+ </p>
555
+ <p class='MsoListNumber2'>
556
+ 3)
557
+ <span style='mso-tab-count:1'> </span>
558
+ Q
559
+ </p>
560
+ <p class='ListNumber1'>
561
+ c)
562
+ <span style='mso-tab-count:1'> </span>
563
+ R
564
+ </p>
565
+ <p class='ListContinue1'>
566
+
567
+ <span style='mso-tab-count:1'> </span>
568
+ A
569
+ </p>
570
+ <p class='ListContinue1'>
571
+
572
+ <span style='mso-tab-count:1'> </span>
573
+ B
574
+ </p>
575
+ <p class='ListContinue1'>
576
+
577
+ <span style='mso-tab-count:1'> </span>
578
+ B1
579
+ </p>
580
+ <p class='MsoListContinue2'>
581
+
582
+ <span style='mso-tab-count:1'> </span>
583
+ C
584
+ </p>
585
+ <p class='MsoListContinue2'>
586
+
587
+ <span style='mso-tab-count:1'> </span>
588
+ D
589
+ </p>
590
+ <p class='MsoListContinue3'>
591
+
592
+ <span style='mso-tab-count:1'> </span>
593
+ E
594
+ </p>
595
+ <p class='MsoListContinue3'>
596
+
597
+ <span style='mso-tab-count:1'> </span>
598
+ F
599
+ </p>
600
+ <p class='MsoListContinue4'>
601
+
602
+ <span style='mso-tab-count:1'> </span>
603
+ G
604
+ </p>
605
+ <p class='MsoListContinue4'>
606
+
607
+ <span style='mso-tab-count:1'> </span>
608
+ H
609
+ </p>
610
+ <p class='MsoListContinue5'>
611
+
612
+ <span style='mso-tab-count:1'> </span>
613
+ I
614
+ </p>
615
+ <p class='MsoListContinue5'>
616
+
617
+ <span style='mso-tab-count:1'> </span>
618
+ J
619
+ </p>
620
+ <p class='MsoListContinue5'>
621
+
622
+ <span style='mso-tab-count:1'> </span>
623
+ K
624
+ </p>
625
+ <p class='MsoListContinue5'>
626
+
627
+ <span style='mso-tab-count:1'> </span>
628
+ L
629
+ </p>
630
+ <p class='MsoListContinue5'>
631
+
632
+ <span style='mso-tab-count:1'> </span>
633
+ M
634
+ </p>
635
+ <p class='MsoListContinue5'>
636
+
637
+ <span style='mso-tab-count:1'> </span>
638
+ N
639
+ </p>
640
+ <p class='MsoListContinue4'>
641
+
642
+ <span style='mso-tab-count:1'> </span>
643
+ O
644
+ </p>
645
+ <p class='MsoListContinue3'>
646
+
647
+ <span style='mso-tab-count:1'> </span>
648
+ P
649
+ </p>
650
+ <p class='MsoListContinue2'>
651
+
652
+ <span style='mso-tab-count:1'> </span>
653
+ Q
654
+ </p>
655
+ <p class='ListContinue1'>
656
+
657
+ <span style='mso-tab-count:1'> </span>
658
+ R
496
659
  </p>
497
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
498
660
  </div>
499
661
  </div>
500
662
  OUTPUT
501
663
  FileUtils.rm_f "test.doc"
502
- IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
664
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
665
+ .convert("test", input, true)
666
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
667
+ expect(File.exist?("test.doc")).to be true
668
+ output = File.read("test.doc", encoding: "UTF-8")
669
+ .sub(/^.*<html/m, "<html")
670
+ .sub(/<\/html>.*$/m, "</html>")
671
+ expect(xmlpp(Nokogiri::XML(output)
672
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml))
673
+ .to be_equivalent_to xmlpp(word)
674
+ end
675
+
676
+ it "deals with ordered list start" do
677
+ input = <<~INPUT
678
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
679
+ <bibdata>
680
+ <status><stage>50</stage></status>
681
+ </bibdata>
682
+ <sections>
683
+ <clause id="A"><p>
684
+ <ol start="3">
685
+ <li><p>A</p></li>
686
+ <li><p>B</p></li>
687
+ <li><ol start="3">
688
+ <li>C</li>
689
+ <li>D</li>
690
+ <li><ol start="3">
691
+ <li>E</li>
692
+ <li>F</li>
693
+ <li><ol start="3">
694
+ <li>G</li>
695
+ <li>H</li>
696
+ <li><ol start="3">
697
+ <li>I</li>
698
+ <li>J</li>
699
+ <li><ol start="3">
700
+ <li>K</li>
701
+ <li>L</li>
702
+ <li>M</li>
703
+ </ol></li>
704
+ <li>N</li>
705
+ </ol></li>
706
+ <li>O</li>
707
+ </ol></li>
708
+ <li>P</li>
709
+ </ol></li>
710
+ <li>Q</li>
711
+ </ol></li>
712
+ <li>R</li>
713
+ </ol>
714
+ </clause>
715
+ </sections>
716
+ </iso-standard>
717
+ INPUT
718
+ word = <<~OUTPUT
719
+ <div class='WordSection3'>
720
+ <p class='zzSTDTitle'/>
721
+ <div>
722
+ <a name='A' id='A'/>
723
+ <h1>1</h1>
724
+ <p class='ListNumber1'>
725
+ c)
726
+ <span style='mso-tab-count:1'> </span>
727
+ A
728
+ </p>
729
+ <p class='ListNumber1'>
730
+ d)
731
+ <span style='mso-tab-count:1'> </span>
732
+ B
733
+ </p>
734
+ <p class='MsoListNumber2'>
735
+ 3)
736
+ <span style='mso-tab-count:1'> </span>
737
+ C
738
+ </p>
739
+ <p class='MsoListNumber2'>
740
+ 4)
741
+ <span style='mso-tab-count:1'> </span>
742
+ D
743
+ </p>
744
+ <p class='MsoListNumber3'>
745
+ iii)
746
+ <span style='mso-tab-count:1'> </span>
747
+ E
748
+ </p>
749
+ <p class='MsoListNumber3'>
750
+ iv)
751
+ <span style='mso-tab-count:1'> </span>
752
+ F
753
+ </p>
754
+ <p class='MsoListNumber4'>
755
+ C)
756
+ <span style='mso-tab-count:1'> </span>
757
+ G
758
+ </p>
759
+ <p class='MsoListNumber4'>
760
+ D)
761
+ <span style='mso-tab-count:1'> </span>
762
+ H
763
+ </p>
764
+ <p class='MsoListNumber5'>
765
+ III)
766
+ <span style='mso-tab-count:1'> </span>
767
+ I
768
+ </p>
769
+ <p class='MsoListNumber5'>
770
+ IV)
771
+ <span style='mso-tab-count:1'> </span>
772
+ J
773
+ </p>
774
+ <p class='MsoListNumber5'>
775
+ c)
776
+ <span style='mso-tab-count:1'> </span>
777
+ K
778
+ </p>
779
+ <p class='MsoListNumber5'>
780
+ d)
781
+ <span style='mso-tab-count:1'> </span>
782
+ L
783
+ </p>
784
+ <p class='MsoListNumber5'>
785
+ e)
786
+ <span style='mso-tab-count:1'> </span>
787
+ M
788
+ </p>
789
+ <p class='MsoListNumber5'>
790
+ V)
791
+ <span style='mso-tab-count:1'> </span>
792
+ N
793
+ </p>
794
+ <p class='MsoListNumber4'>
795
+ E)
796
+ <span style='mso-tab-count:1'> </span>
797
+ O
798
+ </p>
799
+ <p class='MsoListNumber3'>
800
+ v)
801
+ <span style='mso-tab-count:1'> </span>
802
+ P
803
+ </p>
804
+ <p class='MsoListNumber2'>
805
+ 5)
806
+ <span style='mso-tab-count:1'> </span>
807
+ Q
808
+ </p>
809
+ <p class='ListNumber1'>
810
+ e)
811
+ <span style='mso-tab-count:1'> </span>
812
+ R
813
+ </p>
814
+ </div>
815
+ </div>
816
+ OUTPUT
817
+ FileUtils.rm_f "test.doc"
818
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
819
+ .convert("test", input, true)
820
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
503
821
  expect(File.exist?("test.doc")).to be true
504
822
  output = File.read("test.doc", encoding: "UTF-8")
505
823
  .sub(/^.*<html/m, "<html")
@@ -541,7 +859,7 @@ RSpec.describe IsoDoc do
541
859
  INPUT
542
860
  word = <<~WORD
543
861
  <div class='WordSection3'>
544
- <p class='zzSTDTitle1'/>
862
+ <p class='zzSTDTitle'/>
545
863
  <div>
546
864
  <a name='A' id='A'/>
547
865
  <h1/>
@@ -606,7 +924,7 @@ RSpec.describe IsoDoc do
606
924
  <figure id="B">
607
925
  <name>Table1</name>
608
926
  <image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto"/>
609
- <note id="C"><p>Note</p></note>
927
+ <note id="C"><name>FIGURENOTE</name><p>Note</p></note>
610
928
  <example id="D"><p>Example</p></example>
611
929
  </figure>
612
930
  </clause>
@@ -615,7 +933,7 @@ RSpec.describe IsoDoc do
615
933
  INPUT
616
934
  word = <<~WORD
617
935
  <div class='WordSection3'>
618
- <p class='zzSTDTitle1'/>
936
+ <p class='zzSTDTitle'/>
619
937
  <div>
620
938
  <a name='A' id='A'/>
621
939
  <h1/>
@@ -627,12 +945,12 @@ RSpec.describe IsoDoc do
627
945
  <div class='Figurenote'>
628
946
  <a name='C' id='C'/>
629
947
  <p class='Figurenote'>
630
- <span class='note_label'/>
948
+ FIGURENOTE
631
949
  <span style='mso-tab-count:1'>  </span>
632
950
  Note
633
951
  </p>
634
952
  </div>
635
- <div class='Example' style='page-break-after:avoid;'>
953
+ <div style='page-break-after:avoid;'>
636
954
  <a name='D' id='D'/>
637
955
  <p class='Example'>
638
956
  <span style='mso-tab-count:1'>  </span>
@@ -664,13 +982,12 @@ RSpec.describe IsoDoc do
664
982
  <sections>
665
983
  <clause id="A">
666
984
  <example id="B">
985
+ <name>EXAMPLE</name>
667
986
  <p>First example</p>
668
987
  </example>
669
988
  <example id="C">
670
989
  <p>Second example</p>
671
- <ul>
672
- <li>A</li>
673
- </ul>
990
+ <sourcecode>Code</sourcecode>
674
991
  <p>Continuation</p>
675
992
  </example>
676
993
  </clause>
@@ -679,24 +996,25 @@ RSpec.describe IsoDoc do
679
996
  INPUT
680
997
  word = <<~WORD
681
998
  <div class='WordSection3'>
682
- <p class='zzSTDTitle1'/>
999
+ <p class='zzSTDTitle'/>
683
1000
  <div>
684
1001
  <a name='A' id='A'/>
685
1002
  <h1/>
686
- <div class='Example'>
1003
+ <div>
687
1004
  <a name='B' id='B'/>
688
1005
  <p class='Example'>
1006
+ EXAMPLE
689
1007
  <span style='mso-tab-count:1'>  </span>
690
1008
  First example
691
1009
  </p>
692
1010
  </div>
693
- <div class='Example'>
1011
+ <div>
694
1012
  <a name='C' id='C'/>
695
1013
  <p class='Example'>
696
1014
  <span style='mso-tab-count:1'>  </span>
697
1015
  Second example
698
1016
  </p>
699
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
1017
+ <p class='Code-' style='margin-bottom:12pt;'>Code</p>
700
1018
  <p class='Examplecontinued'>Continuation</p>
701
1019
  </div>
702
1020
  </div>
@@ -713,39 +1031,52 @@ RSpec.describe IsoDoc do
713
1031
  .to be_equivalent_to xmlpp(word)
714
1032
  end
715
1033
 
716
- it "deals with annexes" do
1034
+ it "deals with notes" do
717
1035
  input = <<~INPUT
718
1036
  <iso-standard xmlns="http://riboseinc.com/isoxml">
719
1037
  <bibdata>
720
1038
  <status><stage>50</stage></status>
721
1039
  </bibdata>
722
- <annex id="A"><title>Annex</title>
723
- <clause id="B"><title>Subannex</title>
724
- <clause id="C"><title>Subsubannex</title>
725
- </clause>
1040
+ <sections>
1041
+ <clause id="A">
1042
+ <note id="B">
1043
+ <name>NOTE</name>
1044
+ <p>First example</p>
1045
+ </note>
1046
+ <note id="C">
1047
+ <p>Second example</p>
1048
+ <sourcecode>Code</sourcecode>
1049
+ <p>Continuation</p>
1050
+ </note>
726
1051
  </clause>
727
- </annex>
1052
+ </sections>
728
1053
  </iso-standard>
729
1054
  INPUT
730
1055
  word = <<~WORD
731
- <div class='WordSection3'>
732
- <p class='zzSTDTitle1'/>
733
- <p class='MsoBodyText'>
734
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
735
- </p>
736
- <div class='Section3'>
737
- <a name='A' id='A'/>
738
- <p class='ANNEX'>Annex</p>
739
- <div>
740
- <a name='B' id='B'/>
741
- <p class='a2'>Subannex</p>
742
- <div>
743
- <a name='C' id='C'/>
744
- <p class='a3'>Subsubannex</p>
745
- </div>
746
- </div>
1056
+ <div class='WordSection3'>
1057
+ <p class='zzSTDTitle'/>
1058
+ <div>
1059
+ <a name='A' id='A'/>
1060
+ <h1/>
1061
+ <div>
1062
+ <a name='B' id='B'/>
1063
+ <p class='Note'>
1064
+ NOTE
1065
+ <span style='mso-tab-count:1'>  </span>
1066
+ First example
1067
+ </p>
1068
+ </div>
1069
+ <div>
1070
+ <a name='C' id='C'/>
1071
+ <p class='Note'>
1072
+ <span style='mso-tab-count:1'>  </span>
1073
+ Second example
1074
+ </p>
1075
+ <p class='Code-'>Code</p>
1076
+ <p class='Notecontinued'>Continuation</p>
747
1077
  </div>
748
- </div>
1078
+ </div>
1079
+ </div>
749
1080
  WORD
750
1081
  FileUtils.rm_f "test.doc"
751
1082
  IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
@@ -757,4 +1088,799 @@ RSpec.describe IsoDoc do
757
1088
  .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
758
1089
  .to be_equivalent_to xmlpp(word)
759
1090
  end
1091
+
1092
+ it "deals with unordered lists embedded within notes and examples" do
1093
+ input = <<~INPUT
1094
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1095
+ <bibdata>
1096
+ <status><stage>50</stage></status>
1097
+ </bibdata>
1098
+ <sections>
1099
+ <clause id="A">
1100
+ <note id="B">
1101
+ <ul>
1102
+ <li><p>A</p></li>
1103
+ <li><p>B</p></li>
1104
+ <li><ul>
1105
+ <li>C</li>
1106
+ <li>D</li>
1107
+ <li><ul>
1108
+ <li>E</li>
1109
+ <li>F</li>
1110
+ <li><ul>
1111
+ <li>G</li>
1112
+ <li>H</li>
1113
+ <li><ul>
1114
+ <li>I</li>
1115
+ <li>J</li>
1116
+ <li><ul>
1117
+ <li>K</li>
1118
+ <li>L</li>
1119
+ <li>M</li>
1120
+ </ul></li>
1121
+ <li>N</li>
1122
+ </ul></li>
1123
+ <li>O</li>
1124
+ </ul></li>
1125
+ <li>P</li>
1126
+ </ul></li>
1127
+ <li>Q</li>
1128
+ </ul></li>
1129
+ <li>R</li>
1130
+ </ul>
1131
+ </note>
1132
+ </clause>
1133
+ </sections>
1134
+ </iso-standard>
1135
+ INPUT
1136
+ word = <<~WORD
1137
+ <div class='WordSection3'>
1138
+ <p class='zzSTDTitle'/>
1139
+ <div>
1140
+ <a name='A' id='A'/>
1141
+ <h1>1</h1>
1142
+ <div>
1143
+ <a name='B' id='B'/>
1144
+ <p class='Note'>
1145
+ NOTE
1146
+ <span style='mso-tab-count:1'>  </span>
1147
+ </p>
1148
+ <p class='ListContinue2-'>
1149
+
1150
+ <span style='mso-tab-count:1'> </span>
1151
+ A
1152
+ </p>
1153
+ <p class='ListContinue2-'>
1154
+
1155
+ <span style='mso-tab-count:1'> </span>
1156
+ B
1157
+ </p>
1158
+ <p class='ListContinue3-'>
1159
+
1160
+ <span style='mso-tab-count:1'> </span>
1161
+ C
1162
+ </p>
1163
+ <p class='ListContinue3-'>
1164
+
1165
+ <span style='mso-tab-count:1'> </span>
1166
+ D
1167
+ </p>
1168
+ <p class='ListContinue4-'>
1169
+
1170
+ <span style='mso-tab-count:1'> </span>
1171
+ E
1172
+ </p>
1173
+ <p class='ListContinue4-'>
1174
+
1175
+ <span style='mso-tab-count:1'> </span>
1176
+ F
1177
+ </p>
1178
+ <p class='ListContinue5-'>
1179
+
1180
+ <span style='mso-tab-count:1'> </span>
1181
+ G
1182
+ </p>
1183
+ <p class='ListContinue5-'>
1184
+
1185
+ <span style='mso-tab-count:1'> </span>
1186
+ H
1187
+ </p>
1188
+ <p class='ListContinue5-'>
1189
+
1190
+ <span style='mso-tab-count:1'> </span>
1191
+ I
1192
+ </p>
1193
+ <p class='ListContinue5-'>
1194
+
1195
+ <span style='mso-tab-count:1'> </span>
1196
+ J
1197
+ </p>
1198
+ <p class='ListContinue5-'>
1199
+
1200
+ <span style='mso-tab-count:1'> </span>
1201
+ K
1202
+ </p>
1203
+ <p class='ListContinue5-'>
1204
+
1205
+ <span style='mso-tab-count:1'> </span>
1206
+ L
1207
+ </p>
1208
+ <p class='ListContinue5-'>
1209
+
1210
+ <span style='mso-tab-count:1'> </span>
1211
+ M
1212
+ </p>
1213
+ <p class='ListContinue5-'>
1214
+
1215
+ <span style='mso-tab-count:1'> </span>
1216
+ N
1217
+ </p>
1218
+ <p class='ListContinue5-'>
1219
+
1220
+ <span style='mso-tab-count:1'> </span>
1221
+ O
1222
+ </p>
1223
+ <p class='ListContinue4-'>
1224
+
1225
+ <span style='mso-tab-count:1'> </span>
1226
+ P
1227
+ </p>
1228
+ <p class='ListContinue3-'>
1229
+
1230
+ <span style='mso-tab-count:1'> </span>
1231
+ Q
1232
+ </p>
1233
+ <p class='ListContinue2-'>
1234
+
1235
+ <span style='mso-tab-count:1'> </span>
1236
+ R
1237
+ </p>
1238
+ </div>
1239
+ </div>
1240
+ </div>
1241
+ WORD
1242
+ FileUtils.rm_f "test.doc"
1243
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1244
+ .convert("test", input, true)
1245
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1246
+ expect(File.exist?("test.doc")).to be true
1247
+ output = File.read("test.doc", encoding: "UTF-8")
1248
+ .sub(/^.*<html/m, "<html")
1249
+ .sub(/<\/html>.*$/m, "</html>")
1250
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1251
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1252
+ .to be_equivalent_to xmlpp(word)
1253
+ end
1254
+
1255
+ it "deals with ordered lists embedded within notes and examples" do
1256
+ input = <<~INPUT
1257
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1258
+ <bibdata>
1259
+ <status><stage>50</stage></status>
1260
+ </bibdata>
1261
+ <sections>
1262
+ <clause id="A">
1263
+ <example id="B">
1264
+ <ol>
1265
+ <li><p>A</p></li>
1266
+ <li><p>B</p></li>
1267
+ <li><ol>
1268
+ <li>C</li>
1269
+ <li>D</li>
1270
+ <li><ol>
1271
+ <li>E</li>
1272
+ <li>F</li>
1273
+ <li><ol>
1274
+ <li>G</li>
1275
+ <li>H</li>
1276
+ <li><ol>
1277
+ <li>I</li>
1278
+ <li>J</li>
1279
+ <li><ol>
1280
+ <li>K</li>
1281
+ <li>L</li>
1282
+ <li>M</li>
1283
+ </ol></li>
1284
+ <li>N</li>
1285
+ </ol></li>
1286
+ <li>O</li>
1287
+ </ol></li>
1288
+ <li>P</li>
1289
+ </ol></li>
1290
+ <li>Q</li>
1291
+ </ol></li>
1292
+ <li>R</li>
1293
+ </ol>
1294
+ </example>
1295
+ </clause>
1296
+ </sections>
1297
+ </iso-standard>
1298
+ INPUT
1299
+ word = <<~WORD
1300
+ <div class='WordSection3'>
1301
+ <p class='zzSTDTitle'/>
1302
+ <div>
1303
+ <a name='A' id='A'/>
1304
+ <h1>1</h1>
1305
+ <div>
1306
+ <a name='B' id='B'/>
1307
+ <p class='Example'>
1308
+ EXAMPLE
1309
+ <span style='mso-tab-count:1'>  </span>
1310
+ </p>
1311
+ <p class='ListNumber2-'>
1312
+ a)
1313
+ <span style='mso-tab-count:1'> </span>
1314
+ A
1315
+ </p>
1316
+ <p class='ListNumber2-'>
1317
+ b)
1318
+ <span style='mso-tab-count:1'> </span>
1319
+ B
1320
+ </p>
1321
+ <p class='ListNumber3-'>
1322
+ 1)
1323
+ <span style='mso-tab-count:1'> </span>
1324
+ C
1325
+ </p>
1326
+ <p class='ListNumber3-'>
1327
+ 2)
1328
+ <span style='mso-tab-count:1'> </span>
1329
+ D
1330
+ </p>
1331
+ <p class='ListNumber4-'>
1332
+ i)
1333
+ <span style='mso-tab-count:1'> </span>
1334
+ E
1335
+ </p>
1336
+ <p class='ListNumber4-'>
1337
+ ii)
1338
+ <span style='mso-tab-count:1'> </span>
1339
+ F
1340
+ </p>
1341
+ <p class='ListNumber5-'>
1342
+ A)
1343
+ <span style='mso-tab-count:1'> </span>
1344
+ G
1345
+ </p>
1346
+ <p class='ListNumber5-'>
1347
+ B)
1348
+ <span style='mso-tab-count:1'> </span>
1349
+ H
1350
+ </p>
1351
+ <p class='ListNumber5-'>
1352
+ I)
1353
+ <span style='mso-tab-count:1'> </span>
1354
+ I
1355
+ </p>
1356
+ <p class='ListNumber5-'>
1357
+ II)
1358
+ <span style='mso-tab-count:1'> </span>
1359
+ J
1360
+ </p>
1361
+ <p class='ListNumber5-'>
1362
+ a)
1363
+ <span style='mso-tab-count:1'> </span>
1364
+ K
1365
+ </p>
1366
+ <p class='ListNumber5-'>
1367
+ b)
1368
+ <span style='mso-tab-count:1'> </span>
1369
+ L
1370
+ </p>
1371
+ <p class='ListNumber5-'>
1372
+ c)
1373
+ <span style='mso-tab-count:1'> </span>
1374
+ M
1375
+ </p>
1376
+ <p class='ListNumber5-'>
1377
+ III)
1378
+ <span style='mso-tab-count:1'> </span>
1379
+ N
1380
+ </p>
1381
+ <p class='ListNumber5-'>
1382
+ C)
1383
+ <span style='mso-tab-count:1'> </span>
1384
+ O
1385
+ </p>
1386
+ <p class='ListNumber4-'>
1387
+ iii)
1388
+ <span style='mso-tab-count:1'> </span>
1389
+ P
1390
+ </p>
1391
+ <p class='ListNumber3-'>
1392
+ 3)
1393
+ <span style='mso-tab-count:1'> </span>
1394
+ Q
1395
+ </p>
1396
+ <p class='ListNumber2-'>
1397
+ c)
1398
+ <span style='mso-tab-count:1'> </span>
1399
+ R
1400
+ </p>
1401
+ </div>
1402
+ </div>
1403
+ </div>
1404
+ WORD
1405
+ FileUtils.rm_f "test.doc"
1406
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1407
+ .convert("test", input, true)
1408
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1409
+ expect(File.exist?("test.doc")).to be true
1410
+ output = File.read("test.doc", encoding: "UTF-8")
1411
+ .sub(/^.*<html/m, "<html")
1412
+ .sub(/<\/html>.*$/m, "</html>")
1413
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1414
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1415
+ .to be_equivalent_to xmlpp(word)
1416
+ end
1417
+
1418
+ it "ignores intervening ul in numbering ol" do
1419
+ input = <<~INPUT
1420
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1421
+ <bibdata>
1422
+ <status><stage>50</stage></status>
1423
+ </bibdata>
1424
+ <sections>
1425
+ <clause id="A">
1426
+ <ul>
1427
+ <li>A</li>
1428
+ <li>
1429
+ <ol>
1430
+ <li>List</li>
1431
+ <li>
1432
+ <ul>
1433
+ <li>B</li>
1434
+ <li>
1435
+ <ol>
1436
+ <li>List 2</li>
1437
+ </ol>
1438
+ </li>
1439
+ </ul>
1440
+ </li>
1441
+ </ol>
1442
+ </li>
1443
+ </ul>
1444
+ </clause></sections>
1445
+ </iso-standard>
1446
+ INPUT
1447
+ word = <<~WORD
1448
+ <div class='WordSection3'>
1449
+ <p class='zzSTDTitle'/>
1450
+ <div>
1451
+ <a name='A' id='A'/>
1452
+ <h1>1</h1>
1453
+ <p class='ListContinue1'>
1454
+
1455
+ <span style='mso-tab-count:1'> </span>
1456
+ A
1457
+ </p>
1458
+ <p class='MsoListNumber2'>
1459
+ a)
1460
+ <span style='mso-tab-count:1'> </span>
1461
+ List
1462
+ </p>
1463
+ <p class='MsoListContinue3'>
1464
+
1465
+ <span style='mso-tab-count:1'> </span>
1466
+ B
1467
+ </p>
1468
+ <p class='MsoListNumber4'>
1469
+ 1)
1470
+ <span style='mso-tab-count:1'> </span>
1471
+ List 2
1472
+ </p>
1473
+ </div>
1474
+ </div>
1475
+ WORD
1476
+ FileUtils.rm_f "test.doc"
1477
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1478
+ .convert("test", input, true)
1479
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1480
+ expect(File.exist?("test.doc")).to be true
1481
+ output = File.read("test.doc", encoding: "UTF-8")
1482
+ .sub(/^.*<html/m, "<html")
1483
+ .sub(/<\/html>.*$/m, "</html>")
1484
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1485
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1486
+ .to be_equivalent_to xmlpp(word)
1487
+ end
1488
+
1489
+ it "deals with definition lists embedded within notes and examples" do
1490
+ input = <<~INPUT
1491
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1492
+ <bibdata>
1493
+ <status><stage>50</stage></status>
1494
+ </bibdata>
1495
+ <sections>
1496
+ <clause id="A">
1497
+ <example id="B">
1498
+ <name>EXAMPLE</name>
1499
+ <dl>
1500
+ <dt>A</dt><dd>B</dd>
1501
+ </dl>
1502
+ </example>
1503
+ </clause>
1504
+ </sections>
1505
+ </iso-standard>
1506
+ INPUT
1507
+ word = <<~WORD
1508
+ <div class='WordSection3'>
1509
+ <p class='zzSTDTitle'/>
1510
+ <div>
1511
+ <a name='A' id='A'/>
1512
+ <h1/>
1513
+ <div>
1514
+ <a name='B' id='B'/>
1515
+ <p class='Example'>
1516
+ EXAMPLE
1517
+ <span style='mso-tab-count:1'>  </span>
1518
+ </p>
1519
+ <table class='dl' style='margin-left: 1cm;'>
1520
+ <tr>
1521
+ <td valign='top' align='left'>
1522
+ <p align='left' style='margin-left:0pt;text-align:left;' class='Tablebody'>A</p>
1523
+ </td>
1524
+ <td valign='top'>
1525
+ <div class='Tablebody'>B</div>
1526
+ </td>
1527
+ </tr>
1528
+ </table>
1529
+ </div>
1530
+ </div>
1531
+ </div>
1532
+ WORD
1533
+ FileUtils.rm_f "test.doc"
1534
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1535
+ expect(File.exist?("test.doc")).to be true
1536
+ output = File.read("test.doc", encoding: "UTF-8")
1537
+ .sub(/^.*<html/m, "<html")
1538
+ .sub(/<\/html>.*$/m, "</html>")
1539
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1540
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1541
+ .to be_equivalent_to xmlpp(word)
1542
+ end
1543
+
1544
+ it "deals with annexes" do
1545
+ input = <<~INPUT
1546
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1547
+ <bibdata>
1548
+ <status><stage>50</stage></status>
1549
+ </bibdata>
1550
+ <annex id="A"><title>Annex</title>
1551
+ <clause id="B"><title>Subannex</title>
1552
+ <clause id="C"><title>Subsubannex</title>
1553
+ </clause>
1554
+ </clause>
1555
+ </annex>
1556
+ </iso-standard>
1557
+ INPUT
1558
+ word = <<~WORD
1559
+ <div class='WordSection3'>
1560
+ <p class='zzSTDTitle'/>
1561
+ <p class='MsoBodyText'>
1562
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
1563
+ </p>
1564
+ <div class='Section3'>
1565
+ <a name='A' id='A'/>
1566
+ <p class='ANNEX'>Annex</p>
1567
+ <div>
1568
+ <a name='B' id='B'/>
1569
+ <p class='a2'>Subannex</p>
1570
+ <div>
1571
+ <a name='C' id='C'/>
1572
+ <p class='a3'>Subsubannex</p>
1573
+ </div>
1574
+ </div>
1575
+ </div>
1576
+ </div>
1577
+ WORD
1578
+ FileUtils.rm_f "test.doc"
1579
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1580
+ expect(File.exist?("test.doc")).to be true
1581
+ output = File.read("test.doc", encoding: "UTF-8")
1582
+ .sub(/^.*<html/m, "<html")
1583
+ .sub(/<\/html>.*$/m, "</html>")
1584
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1585
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1586
+ .to be_equivalent_to xmlpp(word)
1587
+ end
1588
+
1589
+ it "deals with blockquotes" do
1590
+ input = <<~INPUT
1591
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1592
+ <bibdata>
1593
+ <status><stage>50</stage></status>
1594
+ </bibdata>
1595
+ <sections>
1596
+ <clause id="A">
1597
+ <quote>
1598
+ <p>Normal clause</p>
1599
+ <note><p>Note clause</p></note>
1600
+ <example>
1601
+ <p>Example start</p>
1602
+ <sourcecode>X</sourcecode>
1603
+ <p>Example continued</p>
1604
+ </example>
1605
+ <sourcecode>X</sourcecode>
1606
+ </quote>
1607
+ </clause>
1608
+ </sections>
1609
+ </iso-standard>
1610
+ INPUT
1611
+ word = <<~WORD
1612
+ <div class='WordSection3'>
1613
+ <p class='zzSTDTitle'/>
1614
+ <div>
1615
+ <a name='A' id='A'/>
1616
+ <h1/>
1617
+ <div>
1618
+ <p class='BodyTextindent1'>Normal clause</p>
1619
+ <div>
1620
+ <p class='Noteindent'>
1621
+ <span style='mso-tab-count:1'>  </span>
1622
+ Note clause
1623
+ </p>
1624
+ </div>
1625
+ <div id=''>
1626
+ <p class='Exampleindent'>
1627
+ <span style='mso-tab-count:1'>  </span>
1628
+ Example start
1629
+ </p>
1630
+ <p class='Code--'>X</p>
1631
+ <p class='Exampleindentcontinued'>Example continued</p>
1632
+ </div>
1633
+ <p class='Code-'>X</p>
1634
+ </div>
1635
+ </div>
1636
+ </div>
1637
+ WORD
1638
+ FileUtils.rm_f "test.doc"
1639
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1640
+ expect(File.exist?("test.doc")).to be true
1641
+ output = File.read("test.doc", encoding: "UTF-8")
1642
+ .sub(/^.*<html/m, "<html")
1643
+ .sub(/<\/html>.*$/m, "</html>")
1644
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1645
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1646
+ .to be_equivalent_to xmlpp(word)
1647
+ end
1648
+
1649
+ it "deals with title" do
1650
+ input = <<~INPUT
1651
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1652
+ <bibdata>
1653
+ <title language="en" format="text/plain" type="title-intro">Date and time</title>
1654
+ <title language="en" format="text/plain" type="title-main">Representations for information interchange</title>
1655
+ <title language="en" format="text/plain" type="title-part">Basic rules</title>
1656
+ <status><stage>50</stage></status>
1657
+ <ext><doctype>international-standard</doctype>
1658
+ <structuredidentifier><project-number part="1" origyr="2022-03-10">8601</project-number></structuredidentifier>
1659
+ </ext>
1660
+ </bibdata>
1661
+ <sections>
1662
+ <clause id="A"><title>First clause</title>
1663
+ </clause>
1664
+ </sections>
1665
+ </iso-standard>
1666
+ INPUT
1667
+ word = <<~WORD
1668
+ <div class='WordSection3'>
1669
+ <p class='zzSTDTitle'>
1670
+ Date and time — Representations for information interchange —
1671
+ <span style='font-weight:normal'>Part 1</span>
1672
+ Basic rules
1673
+ </p>
1674
+ <div>
1675
+ <a name='A' id='A'/>
1676
+ <h1>First clause</h1>
1677
+ </div>
1678
+ </div>
1679
+ WORD
1680
+ title = <<~WORD
1681
+ <div class='WordSection1'>
1682
+ <p class='zzCover' style='font-weight:normal;'>
1683
+ <span lang='EN-GB' xml:lang='EN-GB'>Reference number of project: </span>
1684
+ </p>
1685
+ <p class='zzCover' style='font-weight:normal;'>
1686
+ <span lang='EN-GB' xml:lang='EN-GB'>Committee identification: /</span>
1687
+ </p>
1688
+ <p class='zzCover'>
1689
+ <span lang='EN-GB' xml:lang='EN-GB'>
1690
+ <b>
1691
+ Date and time — Representations for information interchange
1692
+ — Part 1: Basic rules
1693
+ </b>
1694
+ </span>
1695
+ </p>
1696
+ <p class='zzCover' style='font-weight:normal;'>
1697
+ <i/>
1698
+ </p>
1699
+ </div>
1700
+ WORD
1701
+ FileUtils.rm_f "test.doc"
1702
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1703
+ expect(File.exist?("test.doc")).to be true
1704
+ output = File.read("test.doc", encoding: "UTF-8")
1705
+ .sub(/^.*<html/m, "<html")
1706
+ .sub(/<\/html>.*$/m, "</html>")
1707
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1708
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1709
+ .to be_equivalent_to xmlpp(word)
1710
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1711
+ .at("//xmlns:div[@class = 'WordSection1']").to_xml)))
1712
+ .to be_equivalent_to xmlpp(title)
1713
+ end
1714
+
1715
+ it "deals with amendments" do
1716
+ input = <<~INPUT
1717
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1718
+ <bibdata>
1719
+ <title language="en" format="text/plain" type="title-intro">Date and time</title>
1720
+ <title language="en" format="text/plain" type="title-main">Representations for information interchange</title>
1721
+ <title language="en" format="text/plain" type="title-part">Basic rules</title>
1722
+ <title language="en" format="text/plain" type="title-amd">Technical corrections</title>
1723
+ <status><stage>50</stage></status>
1724
+ <ext><doctype>amendment</doctype>
1725
+ <structuredidentifier><project-number part="1" amendment="1" origyr="2022-03-10">8601</project-number>
1726
+ </structuredidentifier>
1727
+ </ext>
1728
+ </bibdata>
1729
+ <preface>
1730
+ <foreword id="F"><title>Foreword</title></foreword>
1731
+ </preface>
1732
+ <sections>
1733
+ <clause id="A"><title>First clause</title>
1734
+ </clause>
1735
+ </sections>
1736
+ </iso-standard>
1737
+ INPUT
1738
+ word = <<~WORD
1739
+ <div class='WordSection3'>
1740
+ <p class='zzSTDTitle'>
1741
+ Date and time — Representations for information interchange —
1742
+ <span style='font-weight:normal'>Part 1</span>
1743
+ Basic rules
1744
+ <span style='font-weight:normal'> AMENDMENT 1: Technical corrections</span>
1745
+ </p>
1746
+ <div>
1747
+ <a name='A' id='A'/>
1748
+ <p style='font-style:italic;page-break-after:avoid;' class='MsoBodyText'>First clause</p>
1749
+ </div>
1750
+ </div>
1751
+ WORD
1752
+ FileUtils.rm_f "test.doc"
1753
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1754
+ expect(File.exist?("test.doc")).to be true
1755
+ output = File.read("test.doc", encoding: "UTF-8")
1756
+ .sub(/^.*<html/m, "<html")
1757
+ .sub(/<\/html>.*$/m, "</html>")
1758
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1759
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1760
+ .to be_equivalent_to xmlpp(word)
1761
+ end
1762
+
1763
+ it "deals with copyright boilerplate" do
1764
+ presxml = <<~OUTPUT
1765
+ <iso-standard type="presentation" xmlns="http://riboseinc.com/isoxml">
1766
+ <bibdata type="standard">
1767
+ <status>
1768
+ <stage language="">50</stage>
1769
+ </status>
1770
+ </bibdata>
1771
+ <boilerplate>
1772
+ <copyright-statement>
1773
+ <clause><title>COPYRIGHT PROTECTED DOCUMENT</title>
1774
+ <p id="boilerplate-year">© ISO 2019, Published in Switzerland
1775
+ </p>
1776
+ <p id="boilerplate-message">I am the Walrus.
1777
+ </p>
1778
+ <p id="boilerplate-name">ISO copyright office</p>
1779
+ <p align="left" id="boilerplate-address">ISO copyright office
1780
+ <br/>
1781
+ Ch. de Blandonnet 8 ?~@? CP 401
1782
+ <br/>
1783
+ CH-1214 Vernier, Geneva, Switzerland
1784
+ <br/>
1785
+ Tel. + 41 22 749 01 11
1786
+ <br/>
1787
+ Fax + 41 22 749 09 47
1788
+ <br/>
1789
+ copyright@iso.org
1790
+ <br/>
1791
+ www.iso.org</p>
1792
+ </clause>
1793
+ </copyright-statement>
1794
+ <license-statement>
1795
+ <clause>
1796
+ <title depth="1">Warning for Stuff</title>
1797
+ <p>This document is not an ISO International Standard. It is distributed for review and
1798
+ comment. It is subject to change without notice and may not be referred to as
1799
+ an International Standard.</p>
1800
+ <p>Recipients
1801
+ of this draft are invited to submit, with their comments, notification of any
1802
+ relevant patent rights of which they are aware and to provide supporting
1803
+ documentation.</p>
1804
+ </clause>
1805
+ </license-statement>
1806
+ </boilerplate>
1807
+ </iso-standard>
1808
+ OUTPUT
1809
+
1810
+ FileUtils.rm_f "test.doc"
1811
+ IsoDoc::Iso::WordConvert.new(wordstylesheet: "spec/assets/word.css")
1812
+ .convert("test", presxml, false)
1813
+ word = File.read("test.doc", encoding: "UTF-8")
1814
+ expect(xmlpp(word
1815
+ .sub(%r{^.*<div class="boilerplate-copyright">}m,
1816
+ '<div class="boilerplate-copyright">')
1817
+ .sub(%r{</div>.*$}m, "</div></div>")))
1818
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
1819
+ <div class='boilerplate-copyright'>
1820
+ <div>
1821
+ <p class='zzCopyright'>
1822
+ <a name='boilerplate-year' id='boilerplate-year'/>
1823
+ © ISO 2019, Published in Switzerland
1824
+ </p>
1825
+ <p class='zzCopyright'>
1826
+ <a name='boilerplate-message' id='boilerplate-message'/>
1827
+ I am the Walrus.
1828
+ </p>
1829
+ <p class='zzCopyright'>
1830
+ <a name='boilerplate-name' id='boilerplate-name'/>
1831
+ ISO copyright office
1832
+ </p>
1833
+ <p style='text-align:left;' align='left' class='zzCopyright'>
1834
+ <a name='boilerplate-address' id='boilerplate-address'/>
1835
+ ISO copyright office
1836
+ </p>
1837
+ <p class='zzCopyright'> Ch. de Blandonnet 8 ?~@? CP 401 </p>
1838
+ <p class='zzCopyright'> CH-1214 Vernier, Geneva, Switzerland </p>
1839
+ <p class='zzCopyright'> Tel. + 41 22 749 01 11 </p>
1840
+ <p class='zzCopyright'> Fax + 41 22 749 09 47 </p>
1841
+ <p class='zzCopyright'> copyright@iso.org </p>
1842
+ <p class='zzCopyright'> www.iso.org</p>
1843
+ </div>
1844
+ </div>
1845
+ OUTPUT
1846
+
1847
+ FileUtils.rm_f "test.doc"
1848
+ IsoDoc::Iso::WordConvert.new(wordstylesheet: "spec/assets/word.css")
1849
+ .convert("test",
1850
+ presxml.sub(%r{<stage language="">50</stage>},
1851
+ "<stage>60</stage><substage>00</substage>"), false)
1852
+ word = File.read("test.doc", encoding: "UTF-8")
1853
+ expect(xmlpp(word
1854
+ .sub(%r{^.*<div class="boilerplate-copyright">}m,
1855
+ '<div class="boilerplate-copyright">')
1856
+ .sub(%r{</div>.*$}m, "</div></div>")))
1857
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
1858
+ <div class='boilerplate-copyright'>
1859
+ <div>
1860
+ <p class='zzCopyright'>
1861
+ <a name='boilerplate-year' id='boilerplate-year'/>
1862
+ © ISO 2019, Published in Switzerland
1863
+ </p>
1864
+ <p class='zzCopyright'>
1865
+ <a name='boilerplate-message' id='boilerplate-message'/>
1866
+ I am the Walrus.
1867
+ </p>
1868
+ <p class='zzCopyright'>
1869
+ <a name='boilerplate-name' id='boilerplate-name'/>
1870
+ ISO copyright office
1871
+ </p>
1872
+ <p style='text-indent:20.15pt;' align='left' class='zzCopyright'>
1873
+ <a name='boilerplate-address' id='boilerplate-address'/>
1874
+ ISO copyright office
1875
+ </p>
1876
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Ch. de Blandonnet 8 ?~@? CP 401 </p>
1877
+ <p class='zzCopyright' style='text-indent:20.15pt;'> CH-1214 Vernier, Geneva, Switzerland </p>
1878
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Tel. + 41 22 749 01 11 </p>
1879
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Fax + 41 22 749 09 47 </p>
1880
+ <p class='zzCopyright' style='text-indent:20.15pt;'> copyright@iso.org </p>
1881
+ <p class='zzCopyright' style='text-indent:20.15pt;'> www.iso.org</p>
1882
+ </div>
1883
+ </div>
1884
+ OUTPUT
1885
+ end
760
1886
  end