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
@@ -82,6 +82,11 @@ RSpec.describe IsoDoc::Iso::Metadata do
82
82
  <workgroup number="3">Rice Group</workgroup>
83
83
  <secretariat>GB</secretariat>
84
84
  </editorialgroup>
85
+ <approvalgroup>
86
+ <technical-committee number="34a">Food products A</technical-committee>
87
+ <subcommittee number="4a">Cereals and pulses A</subcommittee>
88
+ <workgroup number="3a">Rice Group A</workgroup>
89
+ </approvalgroup>
85
90
  <structuredidentifier>
86
91
  <project-number part="1">ISO/PreCD3 17301</project-number>
87
92
  </structuredidentifier>
@@ -94,9 +99,7 @@ RSpec.describe IsoDoc::Iso::Metadata do
94
99
  {:accesseddate=>"2012",
95
100
  :activateddate=>"2013",
96
101
  :agency=>"ISO",
97
- :circulateddate=>"XXX",
98
- :confirmeddate=>"XXX",
99
- :copieddate=>"XXX",
102
+ :approvalgroup=>["TC 34a", "SC 4a", "WG 3a"],
100
103
  :createddate=>"2010&#x2013;2011",
101
104
  :docnumber=>"ISO/PreCD3 17301-1",
102
105
  :docnumber_lang=>"ISO/PreCD3 17301-1 (E)",
@@ -120,14 +123,11 @@ RSpec.describe IsoDoc::Iso::Metadata do
120
123
  :edition=>"2",
121
124
  :editorialgroup=>["TC 34", "SC 4", "WG 3"],
122
125
  :horizontal=>"true",
123
- :implementeddate=>"XXX",
124
- :issueddate=>"XXX",
125
126
  :keywords=>["kw2", "kw1"],
126
127
  :lang=>"en",
127
128
  :obsoleteddate=>"2014",
128
129
  :publisheddate=>"2011",
129
130
  :publisher=>"International Organization for Standardization",
130
- :receiveddate=>"XXX",
131
131
  :revdate=>"2016-05-01",
132
132
  :revdate_monthyear=>"May 2016",
133
133
  :sc=>"SC 4",
@@ -137,14 +137,10 @@ RSpec.describe IsoDoc::Iso::Metadata do
137
137
  :stage_int=>30,
138
138
  :stageabbr=>"CD",
139
139
  :statusabbr=>"PreCD3",
140
+ :substage_int=>"92",
140
141
  :tc=>"TC 34",
141
142
  :tc_docnumber=>["17301", "17302"],
142
- :transmitteddate=>"XXX",
143
- :unchangeddate=>"XXX",
144
143
  :unpublished=>true,
145
- :updateddate=>"XXX",
146
- :vote_endeddate=>"XXX",
147
- :vote_starteddate=>"XXX",
148
144
  :wg=>"WG 3"}
149
145
  OUTPUT
150
146
  expect(metadata(c.info(Nokogiri::XML(input),
@@ -159,16 +155,9 @@ RSpec.describe IsoDoc::Iso::Metadata do
159
155
  input = <<~INPUT
160
156
  <iso-standard xmlns="http://riboseinc.com/isoxml">
161
157
  <bibdata type="standard">
162
- <title>
163
158
  <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
164
159
  <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
165
160
  <title type="title-part" language="en" format="text/plain">Rice</title>
166
- </title>
167
- <title>
168
- <title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
169
- <title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
170
- <title type="title-part" language="fr" format="text/plain">Riz</title>
171
- </title>
172
161
  <docidentifier type="ISO">ISO/IEC/CD 17301-1-3</docidentifier>
173
162
  <docidentifier type="iso-with-lang">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
174
163
  <docidentifier type="iso-reference">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
@@ -218,6 +207,11 @@ RSpec.describe IsoDoc::Iso::Metadata do
218
207
  <subcommittee number="4" type="DEF">Cereals and pulses</subcommittee>
219
208
  <workgroup number="3" type="GHI">Rice Group</workgroup>
220
209
  </editorialgroup>
210
+ <approvalgroup>
211
+ <technical-committee number="34" type="ABC">Food products</technical-committee>
212
+ <subcommittee number="4" type="DEF">Cereals and pulses</subcommittee>
213
+ <workgroup number="3" type="GHI">Rice Group</workgroup>
214
+ </approvalgroup>
221
215
  <ics><code>1.2.3</code></ics>
222
216
  <ics><code>1.2.3</code></ics>
223
217
  <structuredidentifier>
@@ -229,19 +223,11 @@ RSpec.describe IsoDoc::Iso::Metadata do
229
223
  </iso-standard>
230
224
  INPUT
231
225
  output = <<~OUTPUT
232
- {:accesseddate=>"XXX",
233
- :agency=>"ISO/IEC",
234
- :circulateddate=>"XXX",
235
- :confirmeddate=>"XXX",
236
- :copieddate=>"XXX",
237
- :createddate=>"XXX",
226
+ {:agency=>"ISO/IEC",
227
+ :approvalgroup=>["ABC 34", "DEF 4", "GHI 3"],
238
228
  :docnumber=>"ISO/IEC/CD 17301-1-3",
239
229
  :docnumber_lang=>"ISO/IEC/CD 17301-1-3 (E)",
240
230
  :docnumber_reference=>"ISO/IEC/CD 17301-1-3 (E)",
241
- :docsubtitle=>"C&#xe9;r&#xe9;ales et l&#xe9;gumineuses&#xa0;&#x2014; Sp&#xe9;cification et m&#xe9;thodes d&#x27;essai&#xa0;&#x2014; Partie&#xa0;1&#x2013;3: Riz",
242
- :docsubtitleintro=>"C&#xe9;r&#xe9;ales et l&#xe9;gumineuses",
243
- :docsubtitlemain=>"Sp&#xe9;cification et m&#xe9;thodes d&#x27;essai",
244
- :docsubtitlepart=>"Riz",
245
231
  :docsubtitlepartlabel=>"Partie&#xa0;1&#x2013;3",
246
232
  :doctitle=>"Cereals and pulses&#xa0;&#x2014; Specifications and test methods&#xa0;&#x2014; Part&#xa0;1&#x2013;3: Rice",
247
233
  :doctitleintro=>"Cereals and pulses",
@@ -253,29 +239,19 @@ RSpec.describe IsoDoc::Iso::Metadata do
253
239
  :docyear=>"2016",
254
240
  :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
255
241
  :ics=>"1.2.3, 1.2.3",
256
- :implementeddate=>"XXX",
257
- :issueddate=>"XXX",
258
242
  :lang=>"en",
259
- :obsoleteddate=>"XXX",
260
243
  :obsoletes=>"IEC 8121",
261
244
  :obsoletes_part=>"3.1",
262
- :publisheddate=>"XXX",
263
245
  :publisher=>"International Organization for Standardization and International Electrotechnical Commission",
264
- :receiveddate=>"XXX",
265
246
  :sc=>"DEF 4",
266
247
  :script=>"Latn",
267
- :secretariat=>"XXX",
268
248
  :stage=>"60",
269
249
  :stage_int=>60,
270
250
  :statusabbr=>"IS",
251
+ :substage_int=>"92",
271
252
  :tc=>"ABC 34",
272
253
  :tc_docnumber=>["17301"],
273
- :transmitteddate=>"XXX",
274
- :unchangeddate=>"XXX",
275
254
  :unpublished=>false,
276
- :updateddate=>"XXX",
277
- :vote_endeddate=>"XXX",
278
- :vote_starteddate=>"XXX",
279
255
  :wg=>"GHI 3"}
280
256
  OUTPUT
281
257
  expect(metadata(c.info(Nokogiri::XML(input),
@@ -294,16 +270,12 @@ RSpec.describe IsoDoc::Iso::Metadata do
294
270
  input = <<~INPUT
295
271
  <iso-standard xmlns="http://riboseinc.com/isoxml">
296
272
  <bibdata type="standard">
297
- <title>
298
273
  <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
299
274
  <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
300
275
  <title type="title-part" language="en" format="text/plain">Rice</title>
301
- </title>
302
- <title>
303
276
  <title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
304
277
  <title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
305
278
  <title type="title-part" language="fr" format="text/plain">Riz</title>
306
- </title>
307
279
  <docidentifier type="ISO">ISO/IEC/CD 17301-1-3</docidentifier>
308
280
  <docidentifier type="iso-with-lang">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
309
281
  <docidentifier type="iso-reference">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
@@ -365,12 +337,7 @@ RSpec.describe IsoDoc::Iso::Metadata do
365
337
  </iso-standard>
366
338
  INPUT
367
339
  output = <<~OUTPUT
368
- {:accesseddate=>"XXX",
369
- :agency=>"ISO/IEC",
370
- :circulateddate=>"XXX",
371
- :confirmeddate=>"XXX",
372
- :copieddate=>"XXX",
373
- :createddate=>"XXX",
340
+ {:agency=>"ISO/IEC",
374
341
  :docnumber=>"ISO/IEC/CD 17301-1-3",
375
342
  :docnumber_lang=>"ISO/IEC/CD 17301-1-3 (E)",
376
343
  :docnumber_reference=>"ISO/IEC/CD 17301-1-3 (E)",
@@ -389,29 +356,19 @@ RSpec.describe IsoDoc::Iso::Metadata do
389
356
  :docyear=>"2016",
390
357
  :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
391
358
  :ics=>"1.2.3, 1.2.3",
392
- :implementeddate=>"XXX",
393
- :issueddate=>"XXX",
394
359
  :lang=>"fr",
395
- :obsoleteddate=>"XXX",
396
360
  :obsoletes=>"IEC 8121",
397
361
  :obsoletes_part=>"3.1",
398
- :publisheddate=>"XXX",
399
362
  :publisher=>"International Organization for Standardization et International Electrotechnical Commission",
400
- :receiveddate=>"XXX",
401
363
  :sc=>"DEF 4",
402
364
  :script=>"Latn",
403
- :secretariat=>"XXX",
404
365
  :stage=>"60",
405
366
  :stage_int=>60,
406
367
  :statusabbr=>"IS",
368
+ :substage_int=>"92",
407
369
  :tc=>"ABC 34",
408
370
  :tc_docnumber=>["17301"],
409
- :transmitteddate=>"XXX",
410
- :unchangeddate=>"XXX",
411
371
  :unpublished=>false,
412
- :updateddate=>"XXX",
413
- :vote_endeddate=>"XXX",
414
- :vote_starteddate=>"XXX",
415
372
  :wg=>"GHI 3"}
416
373
  OUTPUT
417
374
  expect(metadata(c.info(Nokogiri::XML(input),
@@ -430,21 +387,15 @@ RSpec.describe IsoDoc::Iso::Metadata do
430
387
  input = <<~INPUT
431
388
  <iso-standard xmlns="http://riboseinc.com/isoxml">
432
389
  <bibdata type="standard">
433
- <title>
434
390
  <title type="title-intro" language="en" format="text/plain">Cereals and pulses</title>
435
391
  <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
436
392
  <title type="title-part" language="en" format="text/plain">Rice</title>
437
- </title>
438
- <title>
439
393
  <title type="title-intro" language="fr" format="text/plain">Céréales et légumineuses</title>
440
394
  <title type="title-main" language="fr" format="text/plain">Spécification et méthodes d'essai</title>
441
395
  <title type="title-part" language="fr" format="text/plain">Riz</title>
442
- </title>
443
- <title>
444
396
  <title type="title-intro" language="ru" format="text/plain">Зерновые и бобовые</title>
445
397
  <title type="title-main" language="ru" format="text/plain">Технические характеристики и методы испытаний</title>
446
398
  <title type="title-part" language="ru" format="text/plain">Рис</title>
447
- </title>
448
399
  <docidentifier type="ISO">ISO/IEC/CD 17301-1-3</docidentifier>
449
400
  <docidentifier type="iso-with-lang">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
450
401
  <docidentifier type="iso-reference">ISO/IEC/CD 17301-1-3 (E)</docidentifier>
@@ -506,12 +457,7 @@ RSpec.describe IsoDoc::Iso::Metadata do
506
457
  </iso-standard>
507
458
  INPUT
508
459
  output = <<~OUTPUT
509
- {:accesseddate=>"XXX",
510
- :agency=>"ISO/IEC",
511
- :circulateddate=>"XXX",
512
- :confirmeddate=>"XXX",
513
- :copieddate=>"XXX",
514
- :createddate=>"XXX",
460
+ {:agency=>"ISO/IEC",
515
461
  :docnumber=>"ISO/IEC/CD 17301-1-3",
516
462
  :docnumber_lang=>"ISO/IEC/CD 17301-1-3 (E)",
517
463
  :docnumber_reference=>"ISO/IEC/CD 17301-1-3 (E)",
@@ -530,32 +476,227 @@ RSpec.describe IsoDoc::Iso::Metadata do
530
476
  :docyear=>"2016",
531
477
  :editorialgroup=>["ABC 34", "DEF 4", "GHI 3"],
532
478
  :ics=>"1.2.3, 1.2.3",
533
- :implementeddate=>"XXX",
534
- :issueddate=>"XXX",
535
479
  :lang=>"ru",
536
- :obsoleteddate=>"XXX",
537
480
  :obsoletes=>"IEC 8121",
538
481
  :obsoletes_part=>"3.1",
539
- :publisheddate=>"XXX",
540
482
  :publisher=>"International Organization for Standardization &#x438; International Electrotechnical Commission",
541
- :receiveddate=>"XXX",
542
483
  :sc=>"DEF 4",
543
484
  :script=>"Latn",
544
- :secretariat=>"XXX",
545
485
  :stage=>"60",
546
486
  :stage_int=>60,
547
487
  :statusabbr=>"IS",
488
+ :substage_int=>"92",
548
489
  :tc=>"ABC 34",
549
490
  :tc_docnumber=>["17301"],
550
- :transmitteddate=>"XXX",
551
- :unchangeddate=>"XXX",
552
491
  :unpublished=>false,
553
- :updateddate=>"XXX",
554
- :vote_endeddate=>"XXX",
555
- :vote_starteddate=>"XXX",
556
492
  :wg=>"GHI 3"}
557
493
  OUTPUT
558
494
  expect(metadata(c.info(Nokogiri::XML(input),
559
495
  nil))).to be_equivalent_to output
560
496
  end
497
+
498
+ it "warns of missing Secretariat" do
499
+ input = <<~INPUT
500
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
501
+ <bibdata type="standard">
502
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
503
+ <status><stage abbreviation="CD">30</stage></status>
504
+ <date type="published">2000</date>
505
+ <ext>
506
+ <editorialgroup>
507
+ </editorialgroup>
508
+ </ext>
509
+ </bibdata>
510
+ <sections>
511
+ <clause>
512
+ <title>Clause 1</title>
513
+ </clause>
514
+ </sections>
515
+ </iso-standard>
516
+ INPUT
517
+ output = <<~OUTPUT
518
+ <sections>
519
+ <clause displayorder="1">
520
+ <title depth="1">
521
+ <review date="#{Date.today}" reviewer="Metanorma" id="_">
522
+ <p>
523
+ <strong>
524
+ Metadata warnings:
525
+ <strong/>
526
+ <p>Secretariat is missing.</p>
527
+ </strong>
528
+ </p>
529
+ </review>
530
+ Clause 1
531
+ </title>
532
+ </clause>
533
+ </sections>
534
+ OUTPUT
535
+ expect(xmlpp(strip_guid(Nokogiri::XML(
536
+ IsoDoc::Iso::PresentationXMLConvert.new({})
537
+ .convert("test", input, true),
538
+ )
539
+ .at("//xmlns:sections").to_xml)))
540
+ .to be_equivalent_to xmlpp(output)
541
+ end
542
+
543
+ it "warns of missing publication date" do
544
+ input = <<~INPUT
545
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
546
+ <bibdata type="standard">
547
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
548
+ <status><stage abbreviation="CD">30</stage></status>
549
+ <ext>
550
+ <editorialgroup>
551
+ </editorialgroup>
552
+ <secretariat>BSI</secretariat>
553
+ </ext>
554
+ </bibdata>
555
+ <sections>
556
+ <clause>
557
+ <title>Clause 1</title>
558
+ </clause>
559
+ </sections>
560
+ </iso-standard>
561
+ INPUT
562
+ output = <<~OUTPUT
563
+ <sections>
564
+ <clause displayorder="1">
565
+ <title depth="1">
566
+ <review date="#{Date.today}" reviewer="Metanorma" id="_">
567
+ <p>
568
+ <strong>
569
+ Metadata warnings:
570
+ <strong/>
571
+ <p>Document date is missing.</p>
572
+ </strong>
573
+ </p>
574
+ </review>
575
+ Clause 1
576
+ </title>
577
+ </clause>
578
+ </sections>
579
+ OUTPUT
580
+ expect(strip_guid(xmlpp(Nokogiri::XML(
581
+ IsoDoc::Iso::PresentationXMLConvert.new({})
582
+ .convert("test", input, true),
583
+ )
584
+ .at("//xmlns:sections")
585
+ .at("//xmlns:sections").to_xml)))
586
+ .to be_equivalent_to xmlpp(output)
587
+ end
588
+
589
+ it "warns of missing editorial groups" do
590
+ input = <<~INPUT
591
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
592
+ <bibdata type="standard">
593
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
594
+ <status><stage abbreviation="CD">30</stage></status>
595
+ <date type="published">2000</date>
596
+ <ext>
597
+ <secretariat>BSI</secretariat>
598
+ </ext>
599
+ </bibdata>
600
+ <sections>
601
+ <clause>
602
+ <title>Clause 1</title>
603
+ </clause>
604
+ </sections>
605
+ </iso-standard>
606
+ INPUT
607
+ output = <<~OUTPUT
608
+ <sections>
609
+ <clause displayorder="1">
610
+ <title depth="1">
611
+ <review date="#{Date.today}" reviewer="Metanorma" id="_">
612
+ <p>
613
+ <strong>
614
+ Metadata warnings:
615
+ <strong/>
616
+ <p>Editorial groups are missing.</p>
617
+ </strong>
618
+ </p>
619
+ </review>
620
+ Clause 1
621
+ </title>
622
+ </clause>
623
+ </sections>
624
+ OUTPUT
625
+ expect(strip_guid(xmlpp(Nokogiri::XML(
626
+ IsoDoc::Iso::PresentationXMLConvert.new({})
627
+ .convert("test", input, true),
628
+ )
629
+ .at("//xmlns:sections")
630
+ .at("//xmlns:sections").to_xml)))
631
+ .to be_equivalent_to xmlpp(output)
632
+ end
633
+
634
+ it "does not warn of missing metadata in compliant document" do
635
+ input = <<~INPUT
636
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
637
+ <bibdata type="standard">
638
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
639
+ <status><stage abbreviation="CD">30</stage></status>
640
+ <date type="published">2000</date>
641
+ <ext>
642
+ <editorialgroup>
643
+ </editorialgroup>
644
+ <secretariat>BSI</secretariat>
645
+ </ext>
646
+ </bibdata>
647
+ <sections>
648
+ <clause>
649
+ <title>Clause 1</title>
650
+ </clause>
651
+ </sections>
652
+ </iso-standard>
653
+ INPUT
654
+ output = <<~OUTPUT
655
+ <sections>
656
+ <clause displayorder='1'>
657
+ <title depth='1'>Clause 1</title>
658
+ </clause>
659
+ </sections>
660
+ OUTPUT
661
+ expect(strip_guid(xmlpp(Nokogiri::XML(
662
+ IsoDoc::Iso::PresentationXMLConvert.new({})
663
+ .convert("test", input, true),
664
+ )
665
+ .at("//xmlns:sections").to_xml)))
666
+ .to be_equivalent_to xmlpp(output)
667
+ end
668
+
669
+ it "does not warn of missing metadata in published document" do
670
+ input = <<~INPUT
671
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
672
+ <bibdata type="standard">
673
+ <title type="title-main" language="en" format="text/plain">Specifications and test methods</title>
674
+ <status><stage abbreviation="CD">90</stage></status>
675
+ <ext>
676
+ <editorialgroup>
677
+ </editorialgroup>
678
+ <secretariat>BSI</secretariat>
679
+ </ext>
680
+ </bibdata>
681
+ <sections>
682
+ <clause>
683
+ <title>Clause 1</title>
684
+ </clause>
685
+ </sections>
686
+ </iso-standard>
687
+ INPUT
688
+ output = <<~OUTPUT
689
+ <sections>
690
+ <clause displayorder='1'>
691
+ <title depth='1'>Clause 1</title>
692
+ </clause>
693
+ </sections>
694
+ OUTPUT
695
+ expect(strip_guid(xmlpp(Nokogiri::XML(
696
+ IsoDoc::Iso::PresentationXMLConvert.new({})
697
+ .convert("test", input, true),
698
+ )
699
+ .at("//xmlns:sections").to_xml)))
700
+ .to be_equivalent_to xmlpp(output)
701
+ end
561
702
  end
@@ -30,11 +30,9 @@ RSpec.describe IsoDoc do
30
30
  .convert("test", <<~"INPUT", false)
31
31
  <iso-standard xmlns="http://riboseinc.com/isoxml">
32
32
  <bibdata>
33
- <title>
34
33
  <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
35
34
  <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
36
35
  <title format="text/plain" language="en" type="title-part">Rice</title>
37
- </title>
38
36
  </bibdata>
39
37
  <preface>
40
38
  <foreword>
@@ -59,11 +57,9 @@ RSpec.describe IsoDoc do
59
57
  .convert("test", <<~"INPUT", false)
60
58
  <iso-standard xmlns="http://riboseinc.com/isoxml">
61
59
  <bibdata>
62
- <title>
63
60
  <title format="text/plain" language="en" type="title-intro">Cereals and pulses</title>
64
61
  <title format="text/plain" language="en" type="title-main">Specifications and test methods</title>
65
62
  <title format="text/plain" language="en" type="title-part">Rice</title>
66
- </title>
67
63
  </bibdata>
68
64
  <preface>
69
65
  <foreword>
@@ -381,7 +377,7 @@ RSpec.describe IsoDoc do
381
377
  word = File.read("test.doc", encoding: "UTF-8")
382
378
  .sub(/^.*An empty word intro page\./m, "")
383
379
  .sub(%r{</div>.*$}m, "</div>")
384
- .gsub(/<o:p>&#xA0;<\/o:p>/, "")
380
+ .gsub(/<o:p>&#xA0;<\/o:p>/, "")
385
381
 
386
382
  expect(xmlpp("<div>#{word.gsub(/_Toc\d\d+/, '_Toc')}"))
387
383
  .to be_equivalent_to xmlpp(<<~'OUTPUT')
@@ -848,6 +844,46 @@ RSpec.describe IsoDoc do
848
844
  OUTPUT
849
845
  end
850
846
 
847
+ it "processes editorial notes (Word)" do
848
+ IsoDoc::Iso::WordConvert
849
+ .new(WORD_HTML_CSS.dup)
850
+ .convert("test", <<~"INPUT", false)
851
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
852
+ <annex id="P" inline-header="false" obligation="normative">
853
+ <admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="editorial">
854
+ <p id='_e94663cc-2473-4ccc-9a72-983a74d989f2'>
855
+ Only use paddy or parboiled rice for the
856
+ determination of husked rice yield.
857
+ </p>
858
+ <p id="_e94663cc-2473-4ccc-9a72-983a74d989f3">Para 2.</p>
859
+ </admonition>
860
+ </annex>
861
+ </iso-standard>
862
+ INPUT
863
+ word = File.read("test.doc", encoding: "UTF-8")
864
+ .sub(/^.*<div class="WordSection3">/m, '<div class="WordSection3">')
865
+ .sub(%r{<br[^>]*>\s*<div class="colophon".*$}m, "")
866
+ expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")
867
+ <div class='WordSection3'>
868
+ <p class='zzSTDTitle1'/>
869
+ <p class='MsoNormal'>
870
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
871
+ </p>
872
+ <div class='Section3'>
873
+ <a name='P' id='P'/>
874
+ <div class='zzHelp'>
875
+ <a name='_70234f78-64e5-4dfc-8b6f-f3f037348b6a' id='_70234f78-64e5-4dfc-8b6f-f3f037348b6a'/>
876
+ <p class='zzHelp'> Only use paddy or parboiled rice for the determination of husked rice yield. </p>
877
+ <p class='zzHelp'>
878
+ <a name='_e94663cc-2473-4ccc-9a72-983a74d989f3' id='_e94663cc-2473-4ccc-9a72-983a74d989f3'/>
879
+ Para 2.
880
+ </p>
881
+ </div>
882
+ </div>
883
+ </div>
884
+ OUTPUT
885
+ end
886
+
851
887
  it "processes boilerplate" do
852
888
  input = <<~INPUT
853
889
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -526,7 +526,7 @@ RSpec.describe IsoDoc do
526
526
 
527
527
  it "processes multiple terms & definitions sections" do
528
528
  input = <<~INPUT
529
- #{BLANK_HDR.sub(%r{<doctype>article</doctype>}, '<doctype>article</doctype><subdoctype>vocabulary</subdoctype>')}
529
+ #{BLANK_HDR.sub(%r{<doctype>standard</doctype>}, '<doctype>standard</doctype><subdoctype>vocabulary</subdoctype>')}
530
530
  <sections>
531
531
  <terms id='A' obligation='normative'>
532
532
  <title>Terms and definitions</title>
@@ -561,8 +561,7 @@ RSpec.describe IsoDoc do
561
561
  <language current='true'>en</language>
562
562
  <script current='true'>Latn</script>
563
563
  <status>
564
- <stage abbreviation='IS' language=''>60</stage>
565
- <stage abbreviation='IS' language='en'>International standard</stage>
564
+ <stage abbreviation='IS'>60</stage>
566
565
  <substage>60</substage>
567
566
  </status>
568
567
  <copyright>
@@ -575,13 +574,20 @@ RSpec.describe IsoDoc do
575
574
  </owner>
576
575
  </copyright>
577
576
  <ext>
578
- <doctype>article</doctype>
577
+ <doctype>standard</doctype>
579
578
  <subdoctype>vocabulary</subdoctype>
580
- <editorialgroup>
579
+ <editorialgroup identifier='ISO/ / / '>
580
+ <agency>ISO</agency>
581
581
  <technical-committee/>
582
582
  <subcommittee/>
583
583
  <workgroup/>
584
584
  </editorialgroup>
585
+ <approvalgroup identifier='ISO/ / / '>
586
+ <agency>ISO</agency>
587
+ <technical-committee/>
588
+ <subcommittee/>
589
+ <workgroup/>
590
+ </approvalgroup>
585
591
  <stagename>International standard</stagename>
586
592
  </ext>
587
593
  </bibdata>
@@ -708,7 +714,7 @@ RSpec.describe IsoDoc do
708
714
  </div>
709
715
  <p><br clear="all" class="section"/></p>
710
716
  <div class="WordSection3">
711
- <p class="zzSTDTitle1"/>
717
+ <p class="zzSTDTitle"/>
712
718
  </div>
713
719
  <br clear="all" style="page-break-before:left;mso-break-type:section-break"/>
714
720
  <div class="colophon"/>