metanorma-iso 2.1.0 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/html2doc/lists.rb +145 -10
  3. data/lib/isodoc/iso/base_convert.rb +11 -1
  4. data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -0
  5. data/lib/isodoc/iso/html/isodoc-dis.css +216 -278
  6. data/lib/isodoc/iso/html/isodoc-dis.scss +294 -288
  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 +10 -6
  17. data/lib/isodoc/iso/html/wordstyle-dis.css +12 -62
  18. data/lib/isodoc/iso/html/wordstyle-dis.scss +7 -56
  19. data/lib/isodoc/iso/html_convert.rb +7 -2
  20. data/lib/isodoc/iso/i18n-en.yaml +32 -4
  21. data/lib/isodoc/iso/i18n-fr.yaml +29 -3
  22. data/lib/isodoc/iso/i18n-ru.yaml +32 -4
  23. data/lib/isodoc/iso/i18n-zh-Hans.yaml +32 -3
  24. data/lib/isodoc/iso/i18n.rb +1 -1
  25. data/lib/isodoc/iso/iso.amendment.xsl +1570 -246
  26. data/lib/isodoc/iso/iso.international-standard.xsl +1570 -246
  27. data/lib/isodoc/iso/metadata.rb +67 -67
  28. data/lib/isodoc/iso/presentation_bibdata.rb +74 -0
  29. data/lib/isodoc/iso/presentation_xml_convert.rb +16 -5
  30. data/lib/isodoc/iso/presentation_xref.rb +10 -4
  31. data/lib/isodoc/iso/sections.rb +3 -3
  32. data/lib/isodoc/iso/word_cleanup.rb +3 -0
  33. data/lib/isodoc/iso/word_convert.rb +8 -5
  34. data/lib/isodoc/iso/word_dis_cleanup.rb +235 -0
  35. data/lib/isodoc/iso/word_dis_convert.rb +48 -100
  36. data/lib/isodoc/iso/xref.rb +34 -6
  37. data/lib/metanorma/iso/base.rb +20 -1
  38. data/lib/metanorma/iso/biblio.rng +134 -39
  39. data/lib/metanorma/iso/boilerplate-fr.xml +3 -0
  40. data/lib/metanorma/iso/boilerplate-ru.xml +3 -0
  41. data/lib/metanorma/iso/boilerplate.xml +3 -0
  42. data/lib/metanorma/iso/cleanup.rb +49 -11
  43. data/lib/metanorma/iso/front.rb +38 -6
  44. data/lib/metanorma/iso/front_id.rb +2 -0
  45. data/lib/metanorma/iso/isodoc.rng +16 -0
  46. data/lib/metanorma/iso/isostandard.rng +30 -12
  47. data/lib/metanorma/iso/macros.rb +29 -0
  48. data/lib/metanorma/iso/validate_section.rb +0 -12
  49. data/lib/metanorma/iso/version.rb +1 -1
  50. data/spec/isodoc/amd_spec.rb +20 -46
  51. data/spec/isodoc/blocks_spec.rb +499 -2
  52. data/spec/isodoc/i18n_spec.rb +145 -80
  53. data/spec/isodoc/iso_spec.rb +50 -169
  54. data/spec/isodoc/metadata_spec.rb +240 -99
  55. data/spec/isodoc/postproc_spec.rb +43 -7
  56. data/spec/isodoc/section_spec.rb +9 -9
  57. data/spec/isodoc/word_dis_spec.rb +1332 -146
  58. data/spec/isodoc/xref_spec.rb +87 -13
  59. data/spec/metanorma/amd_spec.rb +39 -23
  60. data/spec/metanorma/base_spec.rb +174 -44
  61. data/spec/metanorma/blocks_spec.rb +54 -0
  62. data/spec/metanorma/lists_spec.rb +2 -2
  63. data/spec/metanorma/section_spec.rb +2 -2
  64. data/spec/metanorma/validate_spec.rb +8 -19
  65. data/spec/spec_helper.rb +17 -7
  66. data/spec/vcr_cassettes/withdrawn_iso.yml +30 -30
  67. metadata +7 -8
  68. data/docs/asciiiso-syntax.adoc +0 -307
  69. data/docs/guidance.adoc +0 -487
  70. data/docs/navigation.adoc +0 -23
  71. data/docs/quickstart.adoc +0 -179
  72. 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,416 @@ 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/>
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
659
+ </p>
660
+ </div>
661
+ </div>
662
+ OUTPUT
663
+ FileUtils.rm_f "test.doc"
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 lists and paragraphs" 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">
684
+ <p id="_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828">ISO and IEC maintain terminological databases for use in
685
+ standardization at the following addresses:</p>
686
+
687
+ <ul id="_6f8dbb84-61d9-f774-264e-b7e249cf44d1">
688
+ <li> <p id="_9f56356a-3a58-64c4-e59e-a23ca3da7e88">ISO Online browsing platform: available at
689
+ <link target="https://www.iso.org/obp"/></p></li>
690
+ <li> <p id="_5dc6886f-a99c-e420-a29d-2aa6ca9f376e">IEC Electropedia: available at
691
+ <link target="https://www.electropedia.org"/>
692
+ </p> </li> </ul>
693
+ </clause>
694
+ </sections>
695
+ </iso-standard>
696
+ INPUT
697
+ word = <<~OUTPUT
698
+ <div class='WordSection3'>
699
+ <p class='zzSTDTitle'/>
700
+ <div>
701
+ <a name='A' id='A'/>
702
+ <h1>1</h1>
442
703
  <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>
704
+ <a name='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828' id='_eb2fd8cd-5cbe-1f1f-7bdb-282868a25828'/>
705
+ ISO and IEC maintain terminological databases for use in standardization
706
+ at the following addresses:
707
+ </p>
708
+ <p class='ListContinue1'>
709
+
710
+ <span style='mso-tab-count:1'> </span>
711
+ ISO Online browsing platform: available at
712
+ <a href='https://www.iso.org/obp'>https://www.iso.org/obp</a>
713
+ </p>
714
+ <p class='ListContinue1'>
715
+
716
+ <span style='mso-tab-count:1'> </span>
717
+ IEC Electropedia: available at
718
+ <a href='https://www.electropedia.org'>https://www.electropedia.org</a>
496
719
  </p>
497
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
498
720
  </div>
499
721
  </div>
500
722
  OUTPUT
501
723
  FileUtils.rm_f "test.doc"
502
- IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
724
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
725
+ .convert("test", input, true)
726
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
727
+ expect(File.exist?("test.doc")).to be true
728
+ output = File.read("test.doc", encoding: "UTF-8")
729
+ .sub(/^.*<html/m, "<html")
730
+ .sub(/<\/html>.*$/m, "</html>")
731
+ expect(xmlpp(Nokogiri::XML(output)
732
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml))
733
+ .to be_equivalent_to xmlpp(word)
734
+ end
735
+
736
+ it "deals with ordered list start" do
737
+ input = <<~INPUT
738
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
739
+ <bibdata>
740
+ <status><stage>50</stage></status>
741
+ </bibdata>
742
+ <sections>
743
+ <clause id="A"><p>
744
+ <ol start="3">
745
+ <li><p>A</p></li>
746
+ <li><p>B</p></li>
747
+ <li><ol start="3">
748
+ <li>C</li>
749
+ <li>D</li>
750
+ <li><ol start="3">
751
+ <li>E</li>
752
+ <li>F</li>
753
+ <li><ol start="3">
754
+ <li>G</li>
755
+ <li>H</li>
756
+ <li><ol start="3">
757
+ <li>I</li>
758
+ <li>J</li>
759
+ <li><ol start="3">
760
+ <li>K</li>
761
+ <li>L</li>
762
+ <li>M</li>
763
+ </ol></li>
764
+ <li>N</li>
765
+ </ol></li>
766
+ <li>O</li>
767
+ </ol></li>
768
+ <li>P</li>
769
+ </ol></li>
770
+ <li>Q</li>
771
+ </ol></li>
772
+ <li>R</li>
773
+ </ol>
774
+ </clause>
775
+ </sections>
776
+ </iso-standard>
777
+ INPUT
778
+ word = <<~OUTPUT
779
+ <div class='WordSection3'>
780
+ <p class='zzSTDTitle'/>
781
+ <div>
782
+ <a name='A' id='A'/>
783
+ <h1>1</h1>
784
+ <p class='ListNumber1'>
785
+ c)
786
+ <span style='mso-tab-count:1'> </span>
787
+ A
788
+ </p>
789
+ <p class='ListNumber1'>
790
+ d)
791
+ <span style='mso-tab-count:1'> </span>
792
+ B
793
+ </p>
794
+ <p class='MsoListNumber2'>
795
+ 3)
796
+ <span style='mso-tab-count:1'> </span>
797
+ C
798
+ </p>
799
+ <p class='MsoListNumber2'>
800
+ 4)
801
+ <span style='mso-tab-count:1'> </span>
802
+ D
803
+ </p>
804
+ <p class='MsoListNumber3'>
805
+ iii)
806
+ <span style='mso-tab-count:1'> </span>
807
+ E
808
+ </p>
809
+ <p class='MsoListNumber3'>
810
+ iv)
811
+ <span style='mso-tab-count:1'> </span>
812
+ F
813
+ </p>
814
+ <p class='MsoListNumber4'>
815
+ C)
816
+ <span style='mso-tab-count:1'> </span>
817
+ G
818
+ </p>
819
+ <p class='MsoListNumber4'>
820
+ D)
821
+ <span style='mso-tab-count:1'> </span>
822
+ H
823
+ </p>
824
+ <p class='MsoListNumber5'>
825
+ III)
826
+ <span style='mso-tab-count:1'> </span>
827
+ I
828
+ </p>
829
+ <p class='MsoListNumber5'>
830
+ IV)
831
+ <span style='mso-tab-count:1'> </span>
832
+ J
833
+ </p>
834
+ <p class='MsoListNumber5'>
835
+ c)
836
+ <span style='mso-tab-count:1'> </span>
837
+ K
838
+ </p>
839
+ <p class='MsoListNumber5'>
840
+ d)
841
+ <span style='mso-tab-count:1'> </span>
842
+ L
843
+ </p>
844
+ <p class='MsoListNumber5'>
845
+ e)
846
+ <span style='mso-tab-count:1'> </span>
847
+ M
848
+ </p>
849
+ <p class='MsoListNumber5'>
850
+ V)
851
+ <span style='mso-tab-count:1'> </span>
852
+ N
853
+ </p>
854
+ <p class='MsoListNumber4'>
855
+ E)
856
+ <span style='mso-tab-count:1'> </span>
857
+ O
858
+ </p>
859
+ <p class='MsoListNumber3'>
860
+ v)
861
+ <span style='mso-tab-count:1'> </span>
862
+ P
863
+ </p>
864
+ <p class='MsoListNumber2'>
865
+ 5)
866
+ <span style='mso-tab-count:1'> </span>
867
+ Q
868
+ </p>
869
+ <p class='ListNumber1'>
870
+ e)
871
+ <span style='mso-tab-count:1'> </span>
872
+ R
873
+ </p>
874
+ </div>
875
+ </div>
876
+ OUTPUT
877
+ FileUtils.rm_f "test.doc"
878
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
879
+ .convert("test", input, true)
880
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
503
881
  expect(File.exist?("test.doc")).to be true
504
882
  output = File.read("test.doc", encoding: "UTF-8")
505
883
  .sub(/^.*<html/m, "<html")
@@ -541,7 +919,7 @@ RSpec.describe IsoDoc do
541
919
  INPUT
542
920
  word = <<~WORD
543
921
  <div class='WordSection3'>
544
- <p class='zzSTDTitle1'/>
922
+ <p class='zzSTDTitle'/>
545
923
  <div>
546
924
  <a name='A' id='A'/>
547
925
  <h1/>
@@ -606,7 +984,7 @@ RSpec.describe IsoDoc do
606
984
  <figure id="B">
607
985
  <name>Table1</name>
608
986
  <image src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7" height="20" width="auto"/>
609
- <note id="C"><p>Note</p></note>
987
+ <note id="C"><name>FIGURENOTE</name><p>Note</p></note>
610
988
  <example id="D"><p>Example</p></example>
611
989
  </figure>
612
990
  </clause>
@@ -615,7 +993,7 @@ RSpec.describe IsoDoc do
615
993
  INPUT
616
994
  word = <<~WORD
617
995
  <div class='WordSection3'>
618
- <p class='zzSTDTitle1'/>
996
+ <p class='zzSTDTitle'/>
619
997
  <div>
620
998
  <a name='A' id='A'/>
621
999
  <h1/>
@@ -627,12 +1005,12 @@ RSpec.describe IsoDoc do
627
1005
  <div class='Figurenote'>
628
1006
  <a name='C' id='C'/>
629
1007
  <p class='Figurenote'>
630
- <span class='note_label'/>
1008
+ FIGURENOTE
631
1009
  <span style='mso-tab-count:1'>  </span>
632
1010
  Note
633
1011
  </p>
634
1012
  </div>
635
- <div class='Example' style='page-break-after:avoid;'>
1013
+ <div style='page-break-after:avoid;'>
636
1014
  <a name='D' id='D'/>
637
1015
  <p class='Example'>
638
1016
  <span style='mso-tab-count:1'>  </span>
@@ -664,13 +1042,12 @@ RSpec.describe IsoDoc do
664
1042
  <sections>
665
1043
  <clause id="A">
666
1044
  <example id="B">
1045
+ <name>EXAMPLE</name>
667
1046
  <p>First example</p>
668
1047
  </example>
669
1048
  <example id="C">
670
1049
  <p>Second example</p>
671
- <ul>
672
- <li>A</li>
673
- </ul>
1050
+ <sourcecode>Code</sourcecode>
674
1051
  <p>Continuation</p>
675
1052
  </example>
676
1053
  </clause>
@@ -679,24 +1056,25 @@ RSpec.describe IsoDoc do
679
1056
  INPUT
680
1057
  word = <<~WORD
681
1058
  <div class='WordSection3'>
682
- <p class='zzSTDTitle1'/>
1059
+ <p class='zzSTDTitle'/>
683
1060
  <div>
684
1061
  <a name='A' id='A'/>
685
1062
  <h1/>
686
- <div class='Example'>
1063
+ <div>
687
1064
  <a name='B' id='B'/>
688
1065
  <p class='Example'>
1066
+ EXAMPLE
689
1067
  <span style='mso-tab-count:1'>  </span>
690
1068
  First example
691
1069
  </p>
692
1070
  </div>
693
- <div class='Example'>
1071
+ <div>
694
1072
  <a name='C' id='C'/>
695
1073
  <p class='Example'>
696
1074
  <span style='mso-tab-count:1'>  </span>
697
1075
  Second example
698
1076
  </p>
699
- <p style='mso-list:l3 level1 lfo1;' class='ListContinue1'>A</p>
1077
+ <p class='Code-' style='margin-bottom:12pt;'>Code</p>
700
1078
  <p class='Examplecontinued'>Continuation</p>
701
1079
  </div>
702
1080
  </div>
@@ -713,39 +1091,52 @@ RSpec.describe IsoDoc do
713
1091
  .to be_equivalent_to xmlpp(word)
714
1092
  end
715
1093
 
716
- it "deals with annexes" do
1094
+ it "deals with notes" do
717
1095
  input = <<~INPUT
718
1096
  <iso-standard xmlns="http://riboseinc.com/isoxml">
719
1097
  <bibdata>
720
1098
  <status><stage>50</stage></status>
721
1099
  </bibdata>
722
- <annex id="A"><title>Annex</title>
723
- <clause id="B"><title>Subannex</title>
724
- <clause id="C"><title>Subsubannex</title>
725
- </clause>
1100
+ <sections>
1101
+ <clause id="A">
1102
+ <note id="B">
1103
+ <name>NOTE</name>
1104
+ <p>First example</p>
1105
+ </note>
1106
+ <note id="C">
1107
+ <p>Second example</p>
1108
+ <sourcecode>Code</sourcecode>
1109
+ <p>Continuation</p>
1110
+ </note>
726
1111
  </clause>
727
- </annex>
1112
+ </sections>
728
1113
  </iso-standard>
729
1114
  INPUT
730
1115
  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>
1116
+ <div class='WordSection3'>
1117
+ <p class='zzSTDTitle'/>
1118
+ <div>
1119
+ <a name='A' id='A'/>
1120
+ <h1/>
1121
+ <div>
1122
+ <a name='B' id='B'/>
1123
+ <p class='Note'>
1124
+ NOTE
1125
+ <span style='mso-tab-count:1'>  </span>
1126
+ First example
1127
+ </p>
1128
+ </div>
1129
+ <div>
1130
+ <a name='C' id='C'/>
1131
+ <p class='Note'>
1132
+ <span style='mso-tab-count:1'>  </span>
1133
+ Second example
1134
+ </p>
1135
+ <p class='Code-'>Code</p>
1136
+ <p class='Notecontinued'>Continuation</p>
747
1137
  </div>
748
- </div>
1138
+ </div>
1139
+ </div>
749
1140
  WORD
750
1141
  FileUtils.rm_f "test.doc"
751
1142
  IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
@@ -757,4 +1148,799 @@ RSpec.describe IsoDoc do
757
1148
  .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
758
1149
  .to be_equivalent_to xmlpp(word)
759
1150
  end
1151
+
1152
+ it "deals with unordered lists embedded within notes and examples" do
1153
+ input = <<~INPUT
1154
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1155
+ <bibdata>
1156
+ <status><stage>50</stage></status>
1157
+ </bibdata>
1158
+ <sections>
1159
+ <clause id="A">
1160
+ <note id="B">
1161
+ <ul>
1162
+ <li><p>A</p></li>
1163
+ <li><p>B</p></li>
1164
+ <li><ul>
1165
+ <li>C</li>
1166
+ <li>D</li>
1167
+ <li><ul>
1168
+ <li>E</li>
1169
+ <li>F</li>
1170
+ <li><ul>
1171
+ <li>G</li>
1172
+ <li>H</li>
1173
+ <li><ul>
1174
+ <li>I</li>
1175
+ <li>J</li>
1176
+ <li><ul>
1177
+ <li>K</li>
1178
+ <li>L</li>
1179
+ <li>M</li>
1180
+ </ul></li>
1181
+ <li>N</li>
1182
+ </ul></li>
1183
+ <li>O</li>
1184
+ </ul></li>
1185
+ <li>P</li>
1186
+ </ul></li>
1187
+ <li>Q</li>
1188
+ </ul></li>
1189
+ <li>R</li>
1190
+ </ul>
1191
+ </note>
1192
+ </clause>
1193
+ </sections>
1194
+ </iso-standard>
1195
+ INPUT
1196
+ word = <<~WORD
1197
+ <div class='WordSection3'>
1198
+ <p class='zzSTDTitle'/>
1199
+ <div>
1200
+ <a name='A' id='A'/>
1201
+ <h1>1</h1>
1202
+ <div>
1203
+ <a name='B' id='B'/>
1204
+ <p class='Note'>
1205
+ NOTE
1206
+ <span style='mso-tab-count:1'>  </span>
1207
+ </p>
1208
+ <p class='ListContinue2-'>
1209
+
1210
+ <span style='mso-tab-count:1'> </span>
1211
+ A
1212
+ </p>
1213
+ <p class='ListContinue2-'>
1214
+
1215
+ <span style='mso-tab-count:1'> </span>
1216
+ B
1217
+ </p>
1218
+ <p class='ListContinue3-'>
1219
+
1220
+ <span style='mso-tab-count:1'> </span>
1221
+ C
1222
+ </p>
1223
+ <p class='ListContinue3-'>
1224
+
1225
+ <span style='mso-tab-count:1'> </span>
1226
+ D
1227
+ </p>
1228
+ <p class='ListContinue4-'>
1229
+
1230
+ <span style='mso-tab-count:1'> </span>
1231
+ E
1232
+ </p>
1233
+ <p class='ListContinue4-'>
1234
+
1235
+ <span style='mso-tab-count:1'> </span>
1236
+ F
1237
+ </p>
1238
+ <p class='ListContinue5-'>
1239
+
1240
+ <span style='mso-tab-count:1'> </span>
1241
+ G
1242
+ </p>
1243
+ <p class='ListContinue5-'>
1244
+
1245
+ <span style='mso-tab-count:1'> </span>
1246
+ H
1247
+ </p>
1248
+ <p class='ListContinue5-'>
1249
+
1250
+ <span style='mso-tab-count:1'> </span>
1251
+ I
1252
+ </p>
1253
+ <p class='ListContinue5-'>
1254
+
1255
+ <span style='mso-tab-count:1'> </span>
1256
+ J
1257
+ </p>
1258
+ <p class='ListContinue5-'>
1259
+
1260
+ <span style='mso-tab-count:1'> </span>
1261
+ K
1262
+ </p>
1263
+ <p class='ListContinue5-'>
1264
+
1265
+ <span style='mso-tab-count:1'> </span>
1266
+ L
1267
+ </p>
1268
+ <p class='ListContinue5-'>
1269
+
1270
+ <span style='mso-tab-count:1'> </span>
1271
+ M
1272
+ </p>
1273
+ <p class='ListContinue5-'>
1274
+
1275
+ <span style='mso-tab-count:1'> </span>
1276
+ N
1277
+ </p>
1278
+ <p class='ListContinue5-'>
1279
+
1280
+ <span style='mso-tab-count:1'> </span>
1281
+ O
1282
+ </p>
1283
+ <p class='ListContinue4-'>
1284
+
1285
+ <span style='mso-tab-count:1'> </span>
1286
+ P
1287
+ </p>
1288
+ <p class='ListContinue3-'>
1289
+
1290
+ <span style='mso-tab-count:1'> </span>
1291
+ Q
1292
+ </p>
1293
+ <p class='ListContinue2-'>
1294
+
1295
+ <span style='mso-tab-count:1'> </span>
1296
+ R
1297
+ </p>
1298
+ </div>
1299
+ </div>
1300
+ </div>
1301
+ WORD
1302
+ FileUtils.rm_f "test.doc"
1303
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1304
+ .convert("test", input, true)
1305
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1306
+ expect(File.exist?("test.doc")).to be true
1307
+ output = File.read("test.doc", encoding: "UTF-8")
1308
+ .sub(/^.*<html/m, "<html")
1309
+ .sub(/<\/html>.*$/m, "</html>")
1310
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1311
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1312
+ .to be_equivalent_to xmlpp(word)
1313
+ end
1314
+
1315
+ it "deals with ordered lists embedded within notes and examples" do
1316
+ input = <<~INPUT
1317
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1318
+ <bibdata>
1319
+ <status><stage>50</stage></status>
1320
+ </bibdata>
1321
+ <sections>
1322
+ <clause id="A">
1323
+ <example id="B">
1324
+ <ol>
1325
+ <li><p>A</p></li>
1326
+ <li><p>B</p></li>
1327
+ <li><ol>
1328
+ <li>C</li>
1329
+ <li>D</li>
1330
+ <li><ol>
1331
+ <li>E</li>
1332
+ <li>F</li>
1333
+ <li><ol>
1334
+ <li>G</li>
1335
+ <li>H</li>
1336
+ <li><ol>
1337
+ <li>I</li>
1338
+ <li>J</li>
1339
+ <li><ol>
1340
+ <li>K</li>
1341
+ <li>L</li>
1342
+ <li>M</li>
1343
+ </ol></li>
1344
+ <li>N</li>
1345
+ </ol></li>
1346
+ <li>O</li>
1347
+ </ol></li>
1348
+ <li>P</li>
1349
+ </ol></li>
1350
+ <li>Q</li>
1351
+ </ol></li>
1352
+ <li>R</li>
1353
+ </ol>
1354
+ </example>
1355
+ </clause>
1356
+ </sections>
1357
+ </iso-standard>
1358
+ INPUT
1359
+ word = <<~WORD
1360
+ <div class='WordSection3'>
1361
+ <p class='zzSTDTitle'/>
1362
+ <div>
1363
+ <a name='A' id='A'/>
1364
+ <h1>1</h1>
1365
+ <div>
1366
+ <a name='B' id='B'/>
1367
+ <p class='Example'>
1368
+ EXAMPLE
1369
+ <span style='mso-tab-count:1'>  </span>
1370
+ </p>
1371
+ <p class='ListNumber2-'>
1372
+ a)
1373
+ <span style='mso-tab-count:1'> </span>
1374
+ A
1375
+ </p>
1376
+ <p class='ListNumber2-'>
1377
+ b)
1378
+ <span style='mso-tab-count:1'> </span>
1379
+ B
1380
+ </p>
1381
+ <p class='ListNumber3-'>
1382
+ 1)
1383
+ <span style='mso-tab-count:1'> </span>
1384
+ C
1385
+ </p>
1386
+ <p class='ListNumber3-'>
1387
+ 2)
1388
+ <span style='mso-tab-count:1'> </span>
1389
+ D
1390
+ </p>
1391
+ <p class='ListNumber4-'>
1392
+ i)
1393
+ <span style='mso-tab-count:1'> </span>
1394
+ E
1395
+ </p>
1396
+ <p class='ListNumber4-'>
1397
+ ii)
1398
+ <span style='mso-tab-count:1'> </span>
1399
+ F
1400
+ </p>
1401
+ <p class='ListNumber5-'>
1402
+ A)
1403
+ <span style='mso-tab-count:1'> </span>
1404
+ G
1405
+ </p>
1406
+ <p class='ListNumber5-'>
1407
+ B)
1408
+ <span style='mso-tab-count:1'> </span>
1409
+ H
1410
+ </p>
1411
+ <p class='ListNumber5-'>
1412
+ I)
1413
+ <span style='mso-tab-count:1'> </span>
1414
+ I
1415
+ </p>
1416
+ <p class='ListNumber5-'>
1417
+ II)
1418
+ <span style='mso-tab-count:1'> </span>
1419
+ J
1420
+ </p>
1421
+ <p class='ListNumber5-'>
1422
+ a)
1423
+ <span style='mso-tab-count:1'> </span>
1424
+ K
1425
+ </p>
1426
+ <p class='ListNumber5-'>
1427
+ b)
1428
+ <span style='mso-tab-count:1'> </span>
1429
+ L
1430
+ </p>
1431
+ <p class='ListNumber5-'>
1432
+ c)
1433
+ <span style='mso-tab-count:1'> </span>
1434
+ M
1435
+ </p>
1436
+ <p class='ListNumber5-'>
1437
+ III)
1438
+ <span style='mso-tab-count:1'> </span>
1439
+ N
1440
+ </p>
1441
+ <p class='ListNumber5-'>
1442
+ C)
1443
+ <span style='mso-tab-count:1'> </span>
1444
+ O
1445
+ </p>
1446
+ <p class='ListNumber4-'>
1447
+ iii)
1448
+ <span style='mso-tab-count:1'> </span>
1449
+ P
1450
+ </p>
1451
+ <p class='ListNumber3-'>
1452
+ 3)
1453
+ <span style='mso-tab-count:1'> </span>
1454
+ Q
1455
+ </p>
1456
+ <p class='ListNumber2-'>
1457
+ c)
1458
+ <span style='mso-tab-count:1'> </span>
1459
+ R
1460
+ </p>
1461
+ </div>
1462
+ </div>
1463
+ </div>
1464
+ WORD
1465
+ FileUtils.rm_f "test.doc"
1466
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1467
+ .convert("test", input, true)
1468
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1469
+ expect(File.exist?("test.doc")).to be true
1470
+ output = File.read("test.doc", encoding: "UTF-8")
1471
+ .sub(/^.*<html/m, "<html")
1472
+ .sub(/<\/html>.*$/m, "</html>")
1473
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1474
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1475
+ .to be_equivalent_to xmlpp(word)
1476
+ end
1477
+
1478
+ it "ignores intervening ul in numbering ol" do
1479
+ input = <<~INPUT
1480
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1481
+ <bibdata>
1482
+ <status><stage>50</stage></status>
1483
+ </bibdata>
1484
+ <sections>
1485
+ <clause id="A">
1486
+ <ul>
1487
+ <li>A</li>
1488
+ <li>
1489
+ <ol>
1490
+ <li>List</li>
1491
+ <li>
1492
+ <ul>
1493
+ <li>B</li>
1494
+ <li>
1495
+ <ol>
1496
+ <li>List 2</li>
1497
+ </ol>
1498
+ </li>
1499
+ </ul>
1500
+ </li>
1501
+ </ol>
1502
+ </li>
1503
+ </ul>
1504
+ </clause></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>1</h1>
1513
+ <p class='ListContinue1'>
1514
+
1515
+ <span style='mso-tab-count:1'> </span>
1516
+ A
1517
+ </p>
1518
+ <p class='MsoListNumber2'>
1519
+ a)
1520
+ <span style='mso-tab-count:1'> </span>
1521
+ List
1522
+ </p>
1523
+ <p class='MsoListContinue3'>
1524
+
1525
+ <span style='mso-tab-count:1'> </span>
1526
+ B
1527
+ </p>
1528
+ <p class='MsoListNumber4'>
1529
+ 1)
1530
+ <span style='mso-tab-count:1'> </span>
1531
+ List 2
1532
+ </p>
1533
+ </div>
1534
+ </div>
1535
+ WORD
1536
+ FileUtils.rm_f "test.doc"
1537
+ presxml = IsoDoc::Iso::PresentationXMLConvert.new({})
1538
+ .convert("test", input, true)
1539
+ IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, false)
1540
+ expect(File.exist?("test.doc")).to be true
1541
+ output = File.read("test.doc", encoding: "UTF-8")
1542
+ .sub(/^.*<html/m, "<html")
1543
+ .sub(/<\/html>.*$/m, "</html>")
1544
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1545
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1546
+ .to be_equivalent_to xmlpp(word)
1547
+ end
1548
+
1549
+ it "deals with definition lists embedded within notes and examples" do
1550
+ input = <<~INPUT
1551
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1552
+ <bibdata>
1553
+ <status><stage>50</stage></status>
1554
+ </bibdata>
1555
+ <sections>
1556
+ <clause id="A">
1557
+ <example id="B">
1558
+ <name>EXAMPLE</name>
1559
+ <dl>
1560
+ <dt>A</dt><dd>B</dd>
1561
+ </dl>
1562
+ </example>
1563
+ </clause>
1564
+ </sections>
1565
+ </iso-standard>
1566
+ INPUT
1567
+ word = <<~WORD
1568
+ <div class='WordSection3'>
1569
+ <p class='zzSTDTitle'/>
1570
+ <div>
1571
+ <a name='A' id='A'/>
1572
+ <h1/>
1573
+ <div>
1574
+ <a name='B' id='B'/>
1575
+ <p class='Example'>
1576
+ EXAMPLE
1577
+ <span style='mso-tab-count:1'>  </span>
1578
+ </p>
1579
+ <table class='dl' style='margin-left: 1cm;'>
1580
+ <tr>
1581
+ <td valign='top' align='left'>
1582
+ <p align='left' style='margin-left:0pt;text-align:left;' class='Tablebody'>A</p>
1583
+ </td>
1584
+ <td valign='top'>
1585
+ <div class='Tablebody'>B</div>
1586
+ </td>
1587
+ </tr>
1588
+ </table>
1589
+ </div>
1590
+ </div>
1591
+ </div>
1592
+ WORD
1593
+ FileUtils.rm_f "test.doc"
1594
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1595
+ expect(File.exist?("test.doc")).to be true
1596
+ output = File.read("test.doc", encoding: "UTF-8")
1597
+ .sub(/^.*<html/m, "<html")
1598
+ .sub(/<\/html>.*$/m, "</html>")
1599
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1600
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1601
+ .to be_equivalent_to xmlpp(word)
1602
+ end
1603
+
1604
+ it "deals with annexes" do
1605
+ input = <<~INPUT
1606
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1607
+ <bibdata>
1608
+ <status><stage>50</stage></status>
1609
+ </bibdata>
1610
+ <annex id="A"><title>Annex</title>
1611
+ <clause id="B"><title>Subannex</title>
1612
+ <clause id="C"><title>Subsubannex</title>
1613
+ </clause>
1614
+ </clause>
1615
+ </annex>
1616
+ </iso-standard>
1617
+ INPUT
1618
+ word = <<~WORD
1619
+ <div class='WordSection3'>
1620
+ <p class='zzSTDTitle'/>
1621
+ <p class='MsoBodyText'>
1622
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
1623
+ </p>
1624
+ <div class='Section3'>
1625
+ <a name='A' id='A'/>
1626
+ <p class='ANNEX'>Annex</p>
1627
+ <div>
1628
+ <a name='B' id='B'/>
1629
+ <p class='a2'>Subannex</p>
1630
+ <div>
1631
+ <a name='C' id='C'/>
1632
+ <p class='a3'>Subsubannex</p>
1633
+ </div>
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 blockquotes" do
1650
+ input = <<~INPUT
1651
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1652
+ <bibdata>
1653
+ <status><stage>50</stage></status>
1654
+ </bibdata>
1655
+ <sections>
1656
+ <clause id="A">
1657
+ <quote>
1658
+ <p>Normal clause</p>
1659
+ <note><p>Note clause</p></note>
1660
+ <example>
1661
+ <p>Example start</p>
1662
+ <sourcecode>X</sourcecode>
1663
+ <p>Example continued</p>
1664
+ </example>
1665
+ <sourcecode>X</sourcecode>
1666
+ </quote>
1667
+ </clause>
1668
+ </sections>
1669
+ </iso-standard>
1670
+ INPUT
1671
+ word = <<~WORD
1672
+ <div class='WordSection3'>
1673
+ <p class='zzSTDTitle'/>
1674
+ <div>
1675
+ <a name='A' id='A'/>
1676
+ <h1/>
1677
+ <div>
1678
+ <p class='BodyTextindent1'>Normal clause</p>
1679
+ <div>
1680
+ <p class='Noteindent'>
1681
+ <span style='mso-tab-count:1'>  </span>
1682
+ Note clause
1683
+ </p>
1684
+ </div>
1685
+ <div id=''>
1686
+ <p class='Exampleindent'>
1687
+ <span style='mso-tab-count:1'>  </span>
1688
+ Example start
1689
+ </p>
1690
+ <p class='Code--'>X</p>
1691
+ <p class='Exampleindentcontinued'>Example continued</p>
1692
+ </div>
1693
+ <p class='Code-'>X</p>
1694
+ </div>
1695
+ </div>
1696
+ </div>
1697
+ WORD
1698
+ FileUtils.rm_f "test.doc"
1699
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1700
+ expect(File.exist?("test.doc")).to be true
1701
+ output = File.read("test.doc", encoding: "UTF-8")
1702
+ .sub(/^.*<html/m, "<html")
1703
+ .sub(/<\/html>.*$/m, "</html>")
1704
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1705
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1706
+ .to be_equivalent_to xmlpp(word)
1707
+ end
1708
+
1709
+ it "deals with title" do
1710
+ input = <<~INPUT
1711
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1712
+ <bibdata>
1713
+ <title language="en" format="text/plain" type="title-intro">Date and time</title>
1714
+ <title language="en" format="text/plain" type="title-main">Representations for information interchange</title>
1715
+ <title language="en" format="text/plain" type="title-part">Basic rules</title>
1716
+ <status><stage>50</stage></status>
1717
+ <ext><doctype>international-standard</doctype>
1718
+ <structuredidentifier><project-number part="1" origyr="2022-03-10">8601</project-number></structuredidentifier>
1719
+ </ext>
1720
+ </bibdata>
1721
+ <sections>
1722
+ <clause id="A"><title>First clause</title>
1723
+ </clause>
1724
+ </sections>
1725
+ </iso-standard>
1726
+ INPUT
1727
+ word = <<~WORD
1728
+ <div class='WordSection3'>
1729
+ <p class='zzSTDTitle'>
1730
+ Date and time — Representations for information interchange —
1731
+ <span style='font-weight:normal'>Part 1</span>
1732
+ Basic rules
1733
+ </p>
1734
+ <div>
1735
+ <a name='A' id='A'/>
1736
+ <h1>First clause</h1>
1737
+ </div>
1738
+ </div>
1739
+ WORD
1740
+ title = <<~WORD
1741
+ <div class='WordSection1'>
1742
+ <p class='zzCover' style='font-weight:normal;'>
1743
+ <span lang='EN-GB' xml:lang='EN-GB'>Reference number of project: </span>
1744
+ </p>
1745
+ <p class='zzCover' style='font-weight:normal;'>
1746
+ <span lang='EN-GB' xml:lang='EN-GB'>Committee identification: /</span>
1747
+ </p>
1748
+ <p class='zzCover'>
1749
+ <span lang='EN-GB' xml:lang='EN-GB'>
1750
+ <b>
1751
+ Date and time — Representations for information interchange
1752
+ — Part 1: Basic rules
1753
+ </b>
1754
+ </span>
1755
+ </p>
1756
+ <p class='zzCover' style='font-weight:normal;'>
1757
+ <i/>
1758
+ </p>
1759
+ </div>
1760
+ WORD
1761
+ FileUtils.rm_f "test.doc"
1762
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1763
+ expect(File.exist?("test.doc")).to be true
1764
+ output = File.read("test.doc", encoding: "UTF-8")
1765
+ .sub(/^.*<html/m, "<html")
1766
+ .sub(/<\/html>.*$/m, "</html>")
1767
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1768
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1769
+ .to be_equivalent_to xmlpp(word)
1770
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1771
+ .at("//xmlns:div[@class = 'WordSection1']").to_xml)))
1772
+ .to be_equivalent_to xmlpp(title)
1773
+ end
1774
+
1775
+ it "deals with amendments" do
1776
+ input = <<~INPUT
1777
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1778
+ <bibdata>
1779
+ <title language="en" format="text/plain" type="title-intro">Date and time</title>
1780
+ <title language="en" format="text/plain" type="title-main">Representations for information interchange</title>
1781
+ <title language="en" format="text/plain" type="title-part">Basic rules</title>
1782
+ <title language="en" format="text/plain" type="title-amd">Technical corrections</title>
1783
+ <status><stage>50</stage></status>
1784
+ <ext><doctype>amendment</doctype>
1785
+ <structuredidentifier><project-number part="1" amendment="1" origyr="2022-03-10">8601</project-number>
1786
+ </structuredidentifier>
1787
+ </ext>
1788
+ </bibdata>
1789
+ <preface>
1790
+ <foreword id="F"><title>Foreword</title></foreword>
1791
+ </preface>
1792
+ <sections>
1793
+ <clause id="A"><title>First clause</title>
1794
+ </clause>
1795
+ </sections>
1796
+ </iso-standard>
1797
+ INPUT
1798
+ word = <<~WORD
1799
+ <div class='WordSection3'>
1800
+ <p class='zzSTDTitle'>
1801
+ Date and time — Representations for information interchange —
1802
+ <span style='font-weight:normal'>Part 1</span>
1803
+ Basic rules
1804
+ <span style='font-weight:normal'> AMENDMENT 1: Technical corrections</span>
1805
+ </p>
1806
+ <div>
1807
+ <a name='A' id='A'/>
1808
+ <p style='font-style:italic;page-break-after:avoid;' class='MsoBodyText'>First clause</p>
1809
+ </div>
1810
+ </div>
1811
+ WORD
1812
+ FileUtils.rm_f "test.doc"
1813
+ IsoDoc::Iso::WordConvert.new({}).convert("test", input, false)
1814
+ expect(File.exist?("test.doc")).to be true
1815
+ output = File.read("test.doc", encoding: "UTF-8")
1816
+ .sub(/^.*<html/m, "<html")
1817
+ .sub(/<\/html>.*$/m, "</html>")
1818
+ expect(strip_guid(xmlpp(Nokogiri::XML(output)
1819
+ .at("//xmlns:div[@class = 'WordSection3']").to_xml)))
1820
+ .to be_equivalent_to xmlpp(word)
1821
+ end
1822
+
1823
+ it "deals with copyright boilerplate" do
1824
+ presxml = <<~OUTPUT
1825
+ <iso-standard type="presentation" xmlns="http://riboseinc.com/isoxml">
1826
+ <bibdata type="standard">
1827
+ <status>
1828
+ <stage language="">50</stage>
1829
+ </status>
1830
+ </bibdata>
1831
+ <boilerplate>
1832
+ <copyright-statement>
1833
+ <clause><title>COPYRIGHT PROTECTED DOCUMENT</title>
1834
+ <p id="boilerplate-year">© ISO 2019, Published in Switzerland
1835
+ </p>
1836
+ <p id="boilerplate-message">I am the Walrus.
1837
+ </p>
1838
+ <p id="boilerplate-name">ISO copyright office</p>
1839
+ <p align="left" id="boilerplate-address">ISO copyright office
1840
+ <br/>
1841
+ Ch. de Blandonnet 8 ?~@? CP 401
1842
+ <br/>
1843
+ CH-1214 Vernier, Geneva, Switzerland
1844
+ <br/>
1845
+ Tel. + 41 22 749 01 11
1846
+ <br/>
1847
+ Fax + 41 22 749 09 47
1848
+ <br/>
1849
+ copyright@iso.org
1850
+ <br/>
1851
+ www.iso.org</p>
1852
+ </clause>
1853
+ </copyright-statement>
1854
+ <license-statement>
1855
+ <clause>
1856
+ <title depth="1">Warning for Stuff</title>
1857
+ <p>This document is not an ISO International Standard. It is distributed for review and
1858
+ comment. It is subject to change without notice and may not be referred to as
1859
+ an International Standard.</p>
1860
+ <p>Recipients
1861
+ of this draft are invited to submit, with their comments, notification of any
1862
+ relevant patent rights of which they are aware and to provide supporting
1863
+ documentation.</p>
1864
+ </clause>
1865
+ </license-statement>
1866
+ </boilerplate>
1867
+ </iso-standard>
1868
+ OUTPUT
1869
+
1870
+ FileUtils.rm_f "test.doc"
1871
+ IsoDoc::Iso::WordConvert.new(wordstylesheet: "spec/assets/word.css")
1872
+ .convert("test", presxml, false)
1873
+ word = File.read("test.doc", encoding: "UTF-8")
1874
+ expect(xmlpp(word
1875
+ .sub(%r{^.*<div class="boilerplate-copyright">}m,
1876
+ '<div class="boilerplate-copyright">')
1877
+ .sub(%r{</div>.*$}m, "</div></div>")))
1878
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
1879
+ <div class='boilerplate-copyright'>
1880
+ <div>
1881
+ <p class='zzCopyright'>
1882
+ <a name='boilerplate-year' id='boilerplate-year'/>
1883
+ © ISO 2019, Published in Switzerland
1884
+ </p>
1885
+ <p class='zzCopyright'>
1886
+ <a name='boilerplate-message' id='boilerplate-message'/>
1887
+ I am the Walrus.
1888
+ </p>
1889
+ <p class='zzCopyright'>
1890
+ <a name='boilerplate-name' id='boilerplate-name'/>
1891
+ ISO copyright office
1892
+ </p>
1893
+ <p style='text-align:left;' align='left' class='zzCopyright'>
1894
+ <a name='boilerplate-address' id='boilerplate-address'/>
1895
+ ISO copyright office
1896
+ </p>
1897
+ <p class='zzCopyright'> Ch. de Blandonnet 8 ?~@? CP 401 </p>
1898
+ <p class='zzCopyright'> CH-1214 Vernier, Geneva, Switzerland </p>
1899
+ <p class='zzCopyright'> Tel. + 41 22 749 01 11 </p>
1900
+ <p class='zzCopyright'> Fax + 41 22 749 09 47 </p>
1901
+ <p class='zzCopyright'> copyright@iso.org </p>
1902
+ <p class='zzCopyright'> www.iso.org</p>
1903
+ </div>
1904
+ </div>
1905
+ OUTPUT
1906
+
1907
+ FileUtils.rm_f "test.doc"
1908
+ IsoDoc::Iso::WordConvert.new(wordstylesheet: "spec/assets/word.css")
1909
+ .convert("test",
1910
+ presxml.sub(%r{<stage language="">50</stage>},
1911
+ "<stage>60</stage><substage>00</substage>"), false)
1912
+ word = File.read("test.doc", encoding: "UTF-8")
1913
+ expect(xmlpp(word
1914
+ .sub(%r{^.*<div class="boilerplate-copyright">}m,
1915
+ '<div class="boilerplate-copyright">')
1916
+ .sub(%r{</div>.*$}m, "</div></div>")))
1917
+ .to be_equivalent_to xmlpp(<<~"OUTPUT")
1918
+ <div class='boilerplate-copyright'>
1919
+ <div>
1920
+ <p class='zzCopyright'>
1921
+ <a name='boilerplate-year' id='boilerplate-year'/>
1922
+ © ISO 2019, Published in Switzerland
1923
+ </p>
1924
+ <p class='zzCopyright'>
1925
+ <a name='boilerplate-message' id='boilerplate-message'/>
1926
+ I am the Walrus.
1927
+ </p>
1928
+ <p class='zzCopyright'>
1929
+ <a name='boilerplate-name' id='boilerplate-name'/>
1930
+ ISO copyright office
1931
+ </p>
1932
+ <p style='text-indent:20.15pt;' align='left' class='zzCopyright'>
1933
+ <a name='boilerplate-address' id='boilerplate-address'/>
1934
+ ISO copyright office
1935
+ </p>
1936
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Ch. de Blandonnet 8 ?~@? CP 401 </p>
1937
+ <p class='zzCopyright' style='text-indent:20.15pt;'> CH-1214 Vernier, Geneva, Switzerland </p>
1938
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Tel. + 41 22 749 01 11 </p>
1939
+ <p class='zzCopyright' style='text-indent:20.15pt;'> Fax + 41 22 749 09 47 </p>
1940
+ <p class='zzCopyright' style='text-indent:20.15pt;'> copyright@iso.org </p>
1941
+ <p class='zzCopyright' style='text-indent:20.15pt;'> www.iso.org</p>
1942
+ </div>
1943
+ </div>
1944
+ OUTPUT
1945
+ end
760
1946
  end