metanorma-standoc 1.2.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,13 +8,15 @@ module Metanorma
8
8
  @minimal_version = '0.8.0'
9
9
  version_output, = Open3.capture2e("latexml --VERSION")
10
10
  @actual_version = version_output&.match(%r{\d+(.\d+)*})
11
+ rescue
12
+ warn "LaTeXML not found in PATH, please ensure that LaTeXML is installed."
11
13
  end
12
14
 
13
15
  def satisfied
14
16
  version = @actual_version
15
17
 
16
18
  if version.to_s.empty?
17
- abort "LaTeXML not found in PATH, please make sure that you installed LaTeXML"
19
+ abort "LaTeXML not found in PATH, please ensure that LaTeXML is installed."
18
20
  end
19
21
 
20
22
  if Gem::Version.new(version) < Gem::Version.new(@minimal_version)
@@ -40,7 +42,9 @@ module Metanorma
40
42
  end
41
43
 
42
44
  def cmd
43
- @cmd
45
+ if @cmd.nil?
46
+ satisfied
47
+ end
44
48
  end
45
49
  end
46
50
  end
@@ -8,8 +8,6 @@ module Metanorma
8
8
  @short = :standoc
9
9
  @input_format = :asciidoc
10
10
  @asciidoctor_backend = :standoc
11
-
12
- Metanorma::Standoc::Requirements[:latexml].satisfied
13
11
  end
14
12
 
15
13
  def output_formats
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Standoc
3
- VERSION = "1.2.4".freeze
3
+ VERSION = "1.3.0".freeze
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "asciidoctor", "~> 1.5.7"
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 0.10.0"
31
+ spec.add_dependency "isodoc", "~> 1.0.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
33
  spec.add_dependency "relaton", "~> 0.5.0"
34
34
  spec.add_dependency "relaton-iev", "~> 0.1.0"
@@ -1158,6 +1158,122 @@ r = 1 %</stem>
1158
1158
  OUTPUT
1159
1159
  end
1160
1160
 
1161
+ it "renumbers numeric references in Bibliography sequentially" do
1162
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
1163
+ #{ASCIIDOC_BLANK_HDR}
1164
+
1165
+ == Clause
1166
+ <<iso123>>
1167
+ <<iso124>>
1168
+
1169
+ [bibliography]
1170
+ == Bibliography
1171
+
1172
+ * [[[iso124,ISO 124]]] _Standard 124_
1173
+ * [[[iso123,1]]] _Standard 123_
1174
+ INPUT
1175
+ #{BLANK_HDR}
1176
+ <sections><clause id="_" inline-header="false" obligation="normative">
1177
+ <title>Clause</title>
1178
+ <p id="_"><eref type="inline" bibitemid="iso123" citeas="[2]"/>
1179
+ <eref type="inline" bibitemid="iso124" citeas="ISO 124"/></p>
1180
+ </clause>
1181
+ </sections><bibliography><references id="_" obligation="informative">
1182
+ <title>Bibliography</title>
1183
+ <bibitem id="iso124" type="standard">
1184
+ <title format="text/plain">Standard 124</title>
1185
+ <docidentifier>ISO 124</docidentifier>
1186
+ <contributor>
1187
+ <role type="publisher"/>
1188
+ <organization>
1189
+ <name>ISO</name>
1190
+ </organization>
1191
+ </contributor>
1192
+ </bibitem>
1193
+ <bibitem id="iso123">
1194
+ <formattedref format="application/x-isodoc+xml">
1195
+ <em>Standard 123</em>
1196
+ </formattedref>
1197
+ <docidentifier type="metanorma">[2]</docidentifier>
1198
+ </bibitem>
1199
+ </references></bibliography>
1200
+ OUTPUT
1201
+ end
1202
+
1203
+ it "renumbers numeric references in Bibliography subclauses sequentially" do
1204
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
1205
+ #{ASCIIDOC_BLANK_HDR}
1206
+
1207
+ == Clause
1208
+ <<iso123>>
1209
+ <<iso124>>
1210
+ <<iso125>>
1211
+ <<iso126>>
1212
+
1213
+ [bibliography]
1214
+ == Bibliography
1215
+
1216
+ [bibliography]
1217
+ === Clause 1
1218
+ * [[[iso124,ISO 124]]] _Standard 124_
1219
+ * [[[iso123,1]]] _Standard 123_
1220
+
1221
+ [bibliography]
1222
+ === {blank}
1223
+ * [[[iso125,ISO 125]]] _Standard 124_
1224
+ * [[[iso126,1]]] _Standard 123_
1225
+
1226
+ INPUT
1227
+ #{BLANK_HDR}
1228
+ <sections><clause id="_" inline-header="false" obligation="normative">
1229
+ <title>Clause</title>
1230
+ <p id="_"><eref type="inline" bibitemid="iso123" citeas="[2]"/>
1231
+ <eref type="inline" bibitemid="iso124" citeas="ISO 124"/>
1232
+ <eref type="inline" bibitemid="iso125" citeas="ISO 125"/>
1233
+ <eref type="inline" bibitemid="iso126" citeas="[4]"/></p>
1234
+ </clause>
1235
+ </sections><bibliography><clause id="_" obligation="informative"><title>Bibliography</title><references id="_" obligation="informative">
1236
+ <title>Clause 1</title>
1237
+ <bibitem id="iso124" type="standard">
1238
+ <title format="text/plain">Standard 124</title>
1239
+ <docidentifier>ISO 124</docidentifier>
1240
+ <contributor>
1241
+ <role type="publisher"/>
1242
+ <organization>
1243
+ <name>ISO</name>
1244
+ </organization>
1245
+ </contributor>
1246
+ </bibitem>
1247
+ <bibitem id="iso123">
1248
+ <formattedref format="application/x-isodoc+xml">
1249
+ <em>Standard 123</em>
1250
+ </formattedref>
1251
+ <docidentifier type="metanorma">[2]</docidentifier>
1252
+ </bibitem>
1253
+ </references>
1254
+ <references id="_" obligation="informative">
1255
+
1256
+ <bibitem id="iso125" type="standard">
1257
+ <title format="text/plain">Standard 124</title>
1258
+ <docidentifier>ISO 125</docidentifier>
1259
+ <contributor>
1260
+ <role type="publisher"/>
1261
+ <organization>
1262
+ <name>ISO</name>
1263
+ </organization>
1264
+ </contributor>
1265
+ </bibitem>
1266
+ <bibitem id="iso126">
1267
+ <formattedref format="application/x-isodoc+xml">
1268
+ <em>Standard 123</em>
1269
+ </formattedref>
1270
+ <docidentifier type="metanorma">[4]</docidentifier>
1271
+ </bibitem>
1272
+ </references></clause></bibliography>
1273
+ </standard-document>
1274
+ OUTPUT
1275
+ end
1276
+
1161
1277
 
1162
1278
  private
1163
1279
 
@@ -115,7 +115,6 @@ EOS
115
115
  <title type="title-main" format="text/plain" language="fr" script="Latn">Échantillonnage</title>
116
116
  <title type="main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc - Échantillonnage</title>
117
117
  <uri type="src">https://www.iso.org/standard/23281.html</uri>
118
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
119
118
  <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
120
119
  <docidentifier type="ISO">ISO 123</docidentifier>
121
120
  <contributor>
@@ -157,7 +156,6 @@ EOS
157
156
  <title type="title-main" format="text/plain" language="fr" script="Latn">Échantillonnage</title>
158
157
  <title type="main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc - Échantillonnage</title>
159
158
  <uri type="src">https://www.iso.org/standard/23281.html</uri>
160
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
161
159
  <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
162
160
  <docidentifier type="ISO">ISO 123:2001</docidentifier>
163
161
  <date type="published">
@@ -220,7 +218,6 @@ EOS
220
218
  <title type="title-main" format="text/plain" language="fr" script="Latn">Échantillonnage</title>
221
219
  <title type="main" format="text/plain" language="fr" script="Latn">Latex de caoutchouc - Échantillonnage</title>
222
220
  <uri type="src">https://www.iso.org/standard/23281.html</uri>
223
- <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
224
221
  <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
225
222
  <docidentifier type="ISO">ISO 123:2001</docidentifier>
226
223
  <date type="published">
@@ -676,19 +673,19 @@ EOS
676
673
  private
677
674
 
678
675
  def mock_isobib_get_123
679
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", "2001", {}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
676
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", "2001", {:title=>"<em>Standard</em>"}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_DATED))
680
677
  end
681
678
 
682
679
  def mock_isobib_get_123_undated
683
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
680
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 123", nil, {:title=>"<em>Standard</em>"}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_123_UNDATED))
684
681
  end
685
682
 
686
683
  def mock_isobib_get_124
687
- expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
684
+ expect(RelatonIso::IsoBibliography).to receive(:get).with("ISO 124", "2014", {:title=>"<em>Standard</em>"}).and_return(RelatonIsoBib::XMLParser.from_xml(ISO_124_DATED))
688
685
  end
689
686
 
690
687
  def mock_ietfbib_get_123
691
- expect(RelatonIetf::IetfBibliography).to receive(:get).with("RFC 123", nil, {}).and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
688
+ expect(RelatonIetf::IetfBibliography).to receive(:get).with("RFC 123", nil, {:title=>"<em>Standard</em>"}).and_return(RelatonIsoBib::XMLParser.from_xml(IETF_123_SHORT))
692
689
  end
693
690
 
694
691
  end
@@ -69,7 +69,7 @@ RSpec.describe Asciidoctor::Standoc do
69
69
  OUTPUT
70
70
  end
71
71
 
72
- it "processes complex dl reference" do
72
+ it "processes complex dl reference" do
73
73
  expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
74
74
  #{ASCIIDOC_BLANK_HDR}
75
75
  [bibliography]
@@ -434,6 +434,323 @@ home run record in 1998.</note>
434
434
  </validity>
435
435
  </bibitem></references></bibliography>
436
436
  </standard-document>
437
+ OUTPUT
438
+ end
439
+
440
+ it "processes complex dl reference with dot path keys" do
441
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
442
+ #{ASCIIDOC_BLANK_HDR}
443
+ [bibliography]
444
+ == Normative References
445
+
446
+ [[ISO/TC211]]
447
+ [%bibitem]
448
+ === {blank}
449
+ fetched:: 2019-06-30
450
+ title::
451
+ title.type:: main
452
+ title.content:: Geographic information
453
+ title::
454
+ title.type:: subtitle
455
+ title.content:: Geographic information subtitle
456
+ title.language:: en
457
+ title.script:: Latn
458
+ title.format:: text/plain
459
+ type:: standard
460
+ docid::
461
+ docid.type:: ISO
462
+ docid.id:: TC211
463
+ docnumber:: 211
464
+ edition:: 1
465
+ language:: en
466
+ language:: fr
467
+ script:: Latn
468
+ version.revision_date:: 2019-04-01
469
+ version.draft:: draft
470
+ biblionote.type:: bibnote
471
+ biblionote.content::
472
+ +
473
+ --
474
+ Mark set a major league
475
+ home run record in 1998.
476
+ --
477
+ docstatus.stage:: stage
478
+ docstatus.substage:: substage
479
+ docstatus.iteration:: iteration
480
+ date::
481
+ date.type:: issued
482
+ date.value:: 2014
483
+ date::
484
+ date.type:: published
485
+ date.from:: 2014-04
486
+ date.to:: 2014-05
487
+ date::
488
+ date.type:: accessed
489
+ date.value:: 2015-05-20
490
+ abstract::
491
+ abstract.content::
492
+ +
493
+ --
494
+ ISO 19115-1:2014 defines the schema required for ...
495
+ --
496
+ abstract::
497
+ abstract.content:: L'ISO 19115-1:2014 définit le schéma requis pour ...
498
+ abstract.language:: fr
499
+ abstract.script:: Latn
500
+ abstract.format:: text/plain
501
+ copyright.owner.name:: International Organization for Standardization
502
+ copyright.owner.abbreviation:: ISO
503
+ copyright.owner.url:: www.iso.org
504
+ copyright.from:: 2014
505
+ copyright.to:: 2020
506
+ link::
507
+ link.type:: src
508
+ link.content:: https://www.iso.org/standard/53798.html
509
+ link::
510
+ link.type:: obp
511
+ link.content:: https://www.iso.org/obp/ui/#!iso:std:53798:en
512
+ link::
513
+ link.type:: rss
514
+ link.content:: https://www.iso.org/contents/data/standard/05/37/53798.detail.rss
515
+ medium::
516
+ medium.form:: medium form
517
+ medium.size:: medium size
518
+ medium.scale:: medium scale
519
+ place:: bib place
520
+ extent.type:: section
521
+ extent.reference_from:: 7
522
+ accesslocation:: accesslocation1
523
+ accesslocation:: accesslocation2
524
+ classification.type:: type
525
+ classification.value:: value
526
+ validity.begins:: 2010-10-10 12:21
527
+ validity.ends:: 2011-02-03 18:30
528
+ contributor::
529
+ contributor.organization.name:: International Organization for Standardization
530
+ contributor.organization.url:: www.iso.org
531
+ contributor.organization.abbreviation:: ISO
532
+ contributor.organization.subdivision:: division
533
+ contributor.role.type:: publisher
534
+ contributor.role.description:: Publisher role
535
+ contributor::
536
+ contributor.person.name.completename.content:: A. Bierman
537
+ contributor.person.name.completename.language:: en
538
+ contributor.person.affiliation.organization.name:: IETF
539
+ contributor.person.affiliation.organization.abbreviation:: IETF
540
+ contributor.person.affiliation.organization.identifier.type:: uri
541
+ contributor.person.affiliation.organization.identifier.id:: www.ietf.org
542
+ contributor.person.affiliation.description:: Affiliation description
543
+ contributor.person.contact::
544
+ contributor.person.contact.street:: 8 Street St
545
+ contributor.person.contact.city:: City
546
+ contributor.person.contact.postcode:: 123456
547
+ contributor.person.contact.country:: Country
548
+ contributor.person.contact.state:: State
549
+ contributor.person.contact::
550
+ contributor.person.contact.type:: phone
551
+ contributor.person.contact.value:: 223322
552
+ contributor.role:: author
553
+ contributor::
554
+ contributor.organization.name:: IETF
555
+ contributor.organization.abbreviation:: IETF
556
+ contributor.organization.identifier.type:: uri
557
+ contributor.organization.identifier.id:: www.ietf.org
558
+ contributor.role:: publisher
559
+ contributor::
560
+ contributor.person.name.language:: en
561
+ contributor.person.name.initial:: A.
562
+ contributor.person.name.surname:: Bierman
563
+ contributor.person.affiliation.organization.name:: IETF
564
+ contributor.person.affiliation.organization.abbreviation:: IETF
565
+ contributor.person.affiliation.description.content:: Affiliation description
566
+ contributor.person.affiliation.description.language:: en
567
+ contributor.person.affiliation.description.script:: Latn
568
+ contributor.person.identifier.type:: uri
569
+ contributor.person.identifier.id:: www.person.com
570
+ contributor.role:: author
571
+ relation::
572
+ relation.type:: updates
573
+ relation.bibitem.formattedref:: ISO 19115:2003
574
+ relation.bibitem.bib_locality.type:: page
575
+ relation.bibitem.bib_locality.reference_from:: 7
576
+ relation.bibitem.bib_locality.reference_to:: 10
577
+ relation::
578
+ relation.type:: updates
579
+ relation.bibitem.type:: standard
580
+ relation.bibitem.formattedref:: ISO 19115:2003/Cor 1:2006
581
+ series::
582
+ series.type:: main
583
+ series.title.type:: original
584
+ series.title.content:: ISO/IEC FDIS 10118-3
585
+ series.title.language:: en
586
+ series.title.script:: Latn
587
+ series.title.format:: text/plain
588
+ series.place:: Serie's place
589
+ series.organization:: Serie's organization
590
+ series.abbreviation.content:: ABVR
591
+ series.abbreviation.language:: en
592
+ series.abbreviation.script:: Latn
593
+ series.from:: 2009-02-01
594
+ series.to:: 2010-12-20
595
+ series.number:: serie1234
596
+ series.partnumber:: part5678
597
+ series::
598
+ series.type:: alt
599
+ series.formattedref.content:: serieref
600
+ series.formattedref.language:: en
601
+ series.formattedref.script:: Latn
602
+
603
+ INPUT
604
+ #{BLANK_HDR}
605
+ <sections>
606
+ </sections><bibliography><references id="_" obligation="informative">
607
+ <title>Normative References</title>
608
+ <bibitem id="TC211" type="standard">
609
+ <fetched>2019-06-30</fetched>
610
+ <title type="main" format="text/plain">Geographic information</title>
611
+ <title type="subtitle" format="text/plain" language="en" script="Latn">Geographic information subtitle</title>
612
+ <uri type="src">https://www.iso.org/standard/53798.html</uri>
613
+ <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:53798:en</uri>
614
+ <uri type="rss">https://www.iso.org/contents/data/standard/05/37/53798.detail.rss</uri>
615
+ <docidentifier type="ISO">TC211</docidentifier>
616
+ <docnumber>211</docnumber>
617
+ <date type="issued">
618
+ <on>2014</on>
619
+ </date>
620
+ <date type="published">
621
+ <from>2014</from>
622
+ <to>2014</to>
623
+ </date>
624
+ <date type="accessed">
625
+ <on>2015</on>
626
+ </date>
627
+ <contributor>
628
+ <role type="publisher"><description>Publisher role</description></role>
629
+ <organization>
630
+ <name>International Organization for Standardization</name>
631
+ <subdivision>division</subdivision>
632
+ <abbreviation>ISO</abbreviation>
633
+ <uri>www.iso.org</uri>
634
+ </organization>
635
+ </contributor>
636
+ <contributor>
637
+ <role type="author"/>
638
+ <person>
639
+ <name>
640
+ <completename language="en">A. Bierman</completename>
641
+ </name>
642
+ <affiliation>
643
+ <description format="text/plain">Affiliation description</description>
644
+ <organization>
645
+ <name>IETF</name>
646
+ <abbreviation>IETF</abbreviation>
647
+ <identifier type="uri">www.ietf.org</identifier>
648
+ </organization>
649
+ </affiliation>
650
+ <address>
651
+ <street>8 Street St</street>
652
+ <city>City</city>
653
+ <state>State</state>
654
+ <country>Country</country>
655
+ <postcode>123456</postcode>
656
+ </address>
657
+ <phone>223322</phone>
658
+ </person>
659
+ </contributor>
660
+ <contributor>
661
+ <role type="publisher"/>
662
+ <organization>
663
+ <name>IETF</name>
664
+ <abbreviation>IETF</abbreviation>
665
+ <identifier type="uri">www.ietf.org</identifier>
666
+ </organization>
667
+ </contributor>
668
+ <contributor>
669
+ <role type="author"/>
670
+ <person>
671
+ <name>
672
+ <initial language="en">A.</initial>
673
+ <surname language="en">Bierman</surname>
674
+ </name>
675
+ <affiliation>
676
+ <description language="en" script="Latn">Affiliation description</description>
677
+ <organization>
678
+ <name>IETF</name>
679
+ <abbreviation>IETF</abbreviation>
680
+ </organization>
681
+ </affiliation>
682
+ <identifier type="uri">www.person.com</identifier>
683
+ </person>
684
+ </contributor>
685
+ <edition>1</edition>
686
+ <version>
687
+ <revision-date>2019-04-01</revision-date>
688
+ <draft>draft</draft>
689
+ </version>
690
+ <note type="bibnote">Mark set a major league
691
+ home run record in 1998.</note>
692
+ <language>en</language>
693
+ <language>fr</language>
694
+ <script>Latn</script>
695
+ <abstract format="text/plain">ISO 19115-1:2014 defines the schema required for …​</abstract>
696
+ <abstract format="text/plain" language="fr" script="Latn">L’ISO 19115-1:2014 définit le schéma requis pour …​</abstract>
697
+ <status>
698
+ <stage>stage</stage>
699
+ <substage>substage</substage>
700
+ <iteration>iteration</iteration>
701
+ </status>
702
+ <copyright>
703
+ <from>2014</from>
704
+ <to>2020</to>
705
+ <owner>
706
+ <organization>
707
+ <name>International Organization for Standardization</name>
708
+ <abbreviation>ISO</abbreviation>
709
+ <uri>www.iso.org</uri>
710
+ </organization>
711
+ </owner>
712
+ </copyright>
713
+ <relation type="updates">
714
+ <bibitem>
715
+ <formattedref format="text/plain">ISO 19115:2003</formattedref>
716
+ </bibitem>
717
+ </relation>
718
+ <relation type="updates">
719
+ <bibitem type="standard">
720
+ <formattedref format="text/plain">ISO 19115:2003/Cor 1:2006</formattedref>
721
+ </bibitem>
722
+ </relation>
723
+ <series type="main">
724
+ <title type="original" format="text/plain" language="en" script="Latn">ISO/IEC FDIS 10118-3</title>
725
+ <place>Serie’s place</place>
726
+ <organization>Serie’s organization</organization>
727
+ <abbreviation language="en" script="Latn">ABVR</abbreviation>
728
+ <from>2009-02-01</from>
729
+ <to>2010-12-20</to>
730
+ <number>serie1234</number>
731
+ <partnumber>part5678</partnumber>
732
+ </series>
733
+ <series type="alt">
734
+ <formattedref format="text/plain" language="en" script="Latn">serieref</formattedref>
735
+ </series>
736
+ <medium>
737
+ <form>medium form</form>
738
+ <size>medium size</size>
739
+ <scale>medium scale</scale>
740
+ </medium>
741
+ <place>bib place</place>
742
+ <locality type="section">
743
+ <referenceFrom>7</referenceFrom>
744
+ </locality>
745
+ <accesslocation>accesslocation1</accesslocation>
746
+ <accesslocation>accesslocation2</accesslocation>
747
+ <classification type="type">value</classification>
748
+ <validity>
749
+ <validityBegins>2010-10-10 12:21</validityBegins>
750
+ <validityEnds>2011-02-03 18:30</validityEnds>
751
+ </validity>
752
+ </bibitem></references></bibliography>
753
+ </standard-document>
437
754
  OUTPUT
438
755
  end
439
756