metanorma-un 0.4.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d89413090ed747b554d765b2c2670f943aab27e38f9b1db11c6adc6433932d31
4
- data.tar.gz: 5a2b19fda5a3ed32ab7231ca27fae981d5b315287b4d9cd17a9d272b8e604dd1
3
+ metadata.gz: f88f7b21e9d8de071434daa7df4a9982bec263f465c574c3c97b73971d433c37
4
+ data.tar.gz: 38b237c01381f9343a62e7cbff698915372c24ebda3d5b970c762a3db8db9ebc
5
5
  SHA512:
6
- metadata.gz: 4dfc69a0efb1d8a48b6b479bcbdcb70ef22e5c733a0e6edfe210a66033af618de7daf596182957b53f0ab0be0187c5b7ad2abb8261258ea0609bf9d79cbba139
7
- data.tar.gz: 61f54df3a3d6b56718f887c81d0c3fca978e25fcffbbfc41d9a4b3f9e99cd86a7f86f483cdda80701bf7db16714cd49d7b90db8d732ce5f77e55ac09e9202fa6
6
+ metadata.gz: 9079386c7b5b8df9a4bb61d8675f8c78a83e48235588516dbaa688f1b9e34ec037ff33f5e14de7c530b480a0a42cc6cb8817974f93505b47b4e36be657882d04
7
+ data.tar.gz: 90d5141f6da4430059e474803cb5ae25ebd9b6430a31b555b29c48b37ca5312c730b8e030eb0488f1b9d3ce338e49a03d47621d152a720f402325476556645b9
@@ -402,6 +402,16 @@
402
402
  </choice>
403
403
  </attribute>
404
404
  </optional>
405
+ <optional>
406
+ <attribute name="valign">
407
+ <choice>
408
+ <value>top</value>
409
+ <value>middle</value>
410
+ <value>bottom</value>
411
+ <value>baseline</value>
412
+ </choice>
413
+ </attribute>
414
+ </optional>
405
415
  <choice>
406
416
  <zeroOrMore>
407
417
  <ref name="TextElement"/>
@@ -429,6 +439,16 @@
429
439
  </choice>
430
440
  </attribute>
431
441
  </optional>
442
+ <optional>
443
+ <attribute name="valign">
444
+ <choice>
445
+ <value>top</value>
446
+ <value>middle</value>
447
+ <value>bottom</value>
448
+ <value>baseline</value>
449
+ </choice>
450
+ </attribute>
451
+ </optional>
432
452
  <choice>
433
453
  <zeroOrMore>
434
454
  <ref name="TextElement"/>
@@ -998,6 +1018,9 @@
998
1018
  <value>alphabet_upper</value>
999
1019
  </choice>
1000
1020
  </attribute>
1021
+ <optional>
1022
+ <attribute name="start"/>
1023
+ </optional>
1001
1024
  <oneOrMore>
1002
1025
  <ref name="li"/>
1003
1026
  </oneOrMore>
@@ -5,34 +5,14 @@ require_relative "validate"
5
5
 
6
6
  module Asciidoctor
7
7
  module UN
8
-
9
- # A {Converter} implementation that generates RSD output, and a document
10
- # schema encapsulation of the document for validation
11
- #
12
8
  class Converter < Standoc::Converter
13
9
  XML_ROOT_TAG = "un-standard".freeze
14
10
  XML_NAMESPACE = "https://www.metanorma.org/ns/un".freeze
15
11
 
16
12
  register_for "un"
17
13
 
18
- def metadata_author(node, xml)
19
- xml.contributor do |c|
20
- c.role **{ type: "author" }
21
- c.organization do |a|
22
- a.name Metanorma::UN::ORGANIZATION_NAME_LONG
23
- a.abbreviation Metanorma::UN::ORGANIZATION_NAME_SHORT
24
- end
25
- end
26
- end
27
-
28
- def metadata_publisher(node, xml)
29
- xml.contributor do |c|
30
- c.role **{ type: "publisher" }
31
- c.organization do |a|
32
- a.name Metanorma::UN::ORGANIZATION_NAME_LONG
33
- a.abbreviation Metanorma::UN::ORGANIZATION_NAME_SHORT
34
- end
35
- end
14
+ def default_publisher
15
+ "United Nations"
36
16
  end
37
17
 
38
18
  def metadata_committee(node, xml)
@@ -49,41 +29,35 @@ module Asciidoctor
49
29
  end
50
30
  end
51
31
 
32
+ def asciidoc_sub(text)
33
+ Asciidoctor::Standoc::Utils::asciidoc_sub(text)
34
+ end
35
+
52
36
  def title(node, xml)
53
37
  ["en"].each do |lang|
54
- xml.title **{ type: "main", language: lang, format: "text/plain" } do |t|
55
- t << (Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title")) || node.title)
38
+ xml.title **{ type: "main", language: lang,
39
+ format: "text/plain" } do |t|
40
+ t << (asciidoc_sub(node.attr("title")) || node.title)
56
41
  end
57
42
  node.attr("subtitle") and
58
- xml.title **{ type: "subtitle", language: lang, format: "text/plain" } do |t|
59
- t << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("subtitle"))
60
- end
43
+ xml.title **{ type: "subtitle", language: lang,
44
+ format: "text/plain" } do |t|
45
+ t << asciidoc_sub(node.attr("subtitle"))
46
+ end
61
47
  end
62
48
  end
63
49
 
64
50
  def metadata_id(node, xml)
65
51
  dn = node.attr("docnumber")
66
52
  if docstatus = node.attr("status")
67
- abbr = IsoDoc::UN::Metadata.new("en", "Latn", {}).stage_abbr(docstatus)
53
+ abbr = IsoDoc::UN::Metadata.new("en", "Latn", @i18n)
54
+ .stage_abbr(docstatus)
68
55
  dn = "#{dn}(#{abbr})" unless abbr.empty?
69
56
  end
70
57
  xml.docidentifier { |i| i << dn }
71
58
  xml.docnumber { |i| i << node.attr("docnumber") }
72
59
  end
73
60
 
74
- def metadata_copyright(node, xml)
75
- from = node.attr("copyright-year") || Date.today.year
76
- xml.copyright do |c|
77
- c.from from
78
- c.owner do |owner|
79
- owner.organization do |o|
80
- o.name Metanorma::UN::ORGANIZATION_NAME_LONG
81
- o.abbreviation Metanorma::UN::ORGANIZATION_NAME_SHORT
82
- end
83
- end
84
- end
85
- end
86
-
87
61
  def metadata_distribution(node, xml)
88
62
  xml.distribution node.attr("distribution") if node.attr("distribution")
89
63
  end
@@ -92,17 +66,26 @@ module Asciidoctor
92
66
  xml.session do |session|
93
67
  session.number node.attr("session") if node.attr("session")
94
68
  session.date node.attr("session-date") if node.attr("session-date")
95
- node&.attr("item-number")&.split(/,[ ]*/)&.each { |i| session.item_number i }
96
- node&.attr("item-name")&.split(/,[ ]*/)&.each { |i| session.item_name i }
97
- node&.attr("subitem-name")&.split(/,[ ]*/)&.each { |i| session.subitem_name i }
98
- session.collaborator node.attr("collaborator") if node.attr("collaborator")
69
+ node&.attr("item-number")&.split(/,[ ]*/)&.each do |i|
70
+ session.item_number i
71
+ end
72
+ node&.attr("item-name")&.split(/,[ ]*/)&.each do |i|
73
+ session.item_name i
74
+ end
75
+ node&.attr("subitem-name")&.split(/,[ ]*/)&.each do |i|
76
+ session.subitem_name i
77
+ end
78
+ node.attr("collaborator") and
79
+ session.collaborator node.attr("collaborator")
99
80
  session.id node.attr("agenda-id") if node.attr("agenda-id")
100
- session.item_footnote node.attr("item-footnote") if node.attr("item-footnote")
81
+ node.attr("item-footnote") and
82
+ session.item_footnote node.attr("item-footnote")
101
83
  end
102
84
  end
103
85
 
104
86
  def metadata_language(node, xml)
105
- languages = node&.attr("language")&.split(/,[ ]*/) || %w(ar ru en fr zh es)
87
+ languages = node&.attr("language")&.split(/,[ ]*/) ||
88
+ %w(ar ru en fr zh es)
106
89
  languages.each { |l| xml.language l }
107
90
  end
108
91
 
@@ -124,15 +107,19 @@ module Asciidoctor
124
107
 
125
108
  def makexml(node)
126
109
  @draft = node.attributes.has_key?("draft")
127
- @no_number_subheadings = node.attributes.has_key?("do-not-number-subheadings")
110
+ @no_number_subheadings =
111
+ node.attributes.has_key?("do-not-number-subheadings")
128
112
  super
129
113
  end
130
114
 
131
115
  def doctype(node)
132
- d = node.attr("doctype")
133
- unless %w{plenary recommendation addendum communication corrigendum reissue
134
- agenda budgetary sec-gen-notes expert-report resolution plenary-attachment}.include? d
135
- @log.add("Document Attributes", nil, "#{d} is not a legal document type: reverting to 'recommendation'")
116
+ d = super
117
+ unless %w{plenary recommendation addendum communication corrigendum
118
+ reissue agenda budgetary sec-gen-notes expert-report resolution
119
+ plenary-attachment}.include? d
120
+ @log.add(
121
+ "Document Attributes", nil,
122
+ "#{d} is not a legal document type: reverting to 'recommendation'")
136
123
  d = "recommendation"
137
124
  end
138
125
  d
@@ -141,9 +128,12 @@ module Asciidoctor
141
128
  def outputs(node, ret)
142
129
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
143
130
  presentation_xml_converter(node).convert(@filename + ".xml")
144
- html_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.html")
145
- doc_converter(node).convert(@filename + ".presentation.xml", nil, false, "#{@filename}.doc")
146
- pdf_converter(node)&.convert(@filename + ".presentation.xml", nil, false, "#{@filename}.pdf")
131
+ html_converter(node).convert(@filename + ".presentation.xml",
132
+ nil, false, "#{@filename}.html")
133
+ doc_converter(node).convert(@filename + ".presentation.xml",
134
+ nil, false, "#{@filename}.doc")
135
+ pdf_converter(node)&.convert(@filename + ".presentation.xml",
136
+ nil, false, "#{@filename}.pdf")
147
137
  end
148
138
 
149
139
  def validate(doc)
@@ -217,10 +207,8 @@ module Asciidoctor
217
207
  end
218
208
 
219
209
  def admonition_attrs(node)
220
- attr_code(super.merge(
221
- "unnumbered": node.option?("unnumbered"),
222
- "subsequence": node.attr("subsequence"),
223
- ))
210
+ attr_code(super.merge("unnumbered": node.option?("unnumbered"),
211
+ "subsequence": node.attr("subsequence")))
224
212
  end
225
213
 
226
214
  def sectiontype_streamline(ret)
@@ -42,8 +42,11 @@
42
42
  </define>
43
43
  <define name="xref">
44
44
  <element name="xref">
45
+ <!-- attribute target { xsd:IDREF }, -->
45
46
  <attribute name="target">
46
- <data type="IDREF"/>
47
+ <data type="string">
48
+ <param name="pattern">\i\c*|\c+#\c+</param>
49
+ </data>
47
50
  </attribute>
48
51
  <optional>
49
52
  <attribute name="type">
@@ -61,6 +64,11 @@
61
64
  </choice>
62
65
  </attribute>
63
66
  </optional>
67
+ <optional>
68
+ <attribute name="droploc">
69
+ <data type="boolean"/>
70
+ </attribute>
71
+ </optional>
64
72
  <text/>
65
73
  </element>
66
74
  </define>
@@ -578,6 +586,8 @@
578
586
  <ref name="ol"/>
579
587
  <ref name="dl"/>
580
588
  <ref name="formula"/>
589
+ <ref name="quote"/>
590
+ <ref name="sourcecode"/>
581
591
  </choice>
582
592
  </oneOrMore>
583
593
  </element>
@@ -661,6 +671,16 @@
661
671
  </choice>
662
672
  </attribute>
663
673
  </optional>
674
+ <optional>
675
+ <attribute name="valign">
676
+ <choice>
677
+ <value>top</value>
678
+ <value>middle</value>
679
+ <value>bottom</value>
680
+ <value>baseline</value>
681
+ </choice>
682
+ </attribute>
683
+ </optional>
664
684
  <choice>
665
685
  <zeroOrMore>
666
686
  <choice>
@@ -697,6 +717,16 @@
697
717
  </choice>
698
718
  </attribute>
699
719
  </optional>
720
+ <optional>
721
+ <attribute name="valign">
722
+ <choice>
723
+ <value>top</value>
724
+ <value>middle</value>
725
+ <value>bottom</value>
726
+ <value>baseline</value>
727
+ </choice>
728
+ </attribute>
729
+ </optional>
700
730
  <choice>
701
731
  <zeroOrMore>
702
732
  <choice>
@@ -834,6 +864,13 @@
834
864
  </define>
835
865
  <define name="standard-document">
836
866
  <element name="standard-document">
867
+ <attribute name="version"/>
868
+ <attribute name="type">
869
+ <choice>
870
+ <value>semantic</value>
871
+ <value>presentation</value>
872
+ </choice>
873
+ </attribute>
837
874
  <ref name="bibdata"/>
838
875
  <optional>
839
876
  <ref name="boilerplate"/>
@@ -855,7 +892,7 @@
855
892
  <oneOrMore>
856
893
  <choice>
857
894
  <ref name="content"/>
858
- <ref name="preface_abstract"/>
895
+ <ref name="abstract"/>
859
896
  <ref name="foreword"/>
860
897
  <ref name="introduction"/>
861
898
  <ref name="acknowledgements"/>
@@ -922,6 +959,9 @@
922
959
  <optional>
923
960
  <attribute name="script"/>
924
961
  </optional>
962
+ <optional>
963
+ <attribute name="type"/>
964
+ </optional>
925
965
  <optional>
926
966
  <attribute name="obligation">
927
967
  <choice>
@@ -961,9 +1001,6 @@
961
1001
  </define>
962
1002
  <define name="content-subsection">
963
1003
  <element name="clause">
964
- <optional>
965
- <attribute name="type"/>
966
- </optional>
967
1004
  <ref name="Content-Section"/>
968
1005
  </element>
969
1006
  </define>
@@ -992,6 +1029,9 @@
992
1029
  </choice>
993
1030
  </attribute>
994
1031
  </optional>
1032
+ <optional>
1033
+ <attribute name="type"/>
1034
+ </optional>
995
1035
  <optional>
996
1036
  <ref name="section-title"/>
997
1037
  </optional>
@@ -1011,9 +1051,6 @@
1011
1051
  </define>
1012
1052
  <define name="clause">
1013
1053
  <element name="clause">
1014
- <optional>
1015
- <attribute name="type"/>
1016
- </optional>
1017
1054
  <ref name="Clause-Section"/>
1018
1055
  </element>
1019
1056
  </define>
@@ -1042,18 +1079,24 @@
1042
1079
  </choice>
1043
1080
  </attribute>
1044
1081
  </optional>
1082
+ <optional>
1083
+ <attribute name="type"/>
1084
+ </optional>
1045
1085
  <optional>
1046
1086
  <ref name="section-title"/>
1047
1087
  </optional>
1048
1088
  <group>
1049
- <group>
1050
- <zeroOrMore>
1051
- <ref name="BasicBlock"/>
1052
- </zeroOrMore>
1053
- <zeroOrMore>
1054
- <ref name="note"/>
1055
- </zeroOrMore>
1056
- </group>
1089
+ <choice>
1090
+ <group>
1091
+ <zeroOrMore>
1092
+ <ref name="BasicBlock"/>
1093
+ </zeroOrMore>
1094
+ <zeroOrMore>
1095
+ <ref name="note"/>
1096
+ </zeroOrMore>
1097
+ </group>
1098
+ <ref name="amend"/>
1099
+ </choice>
1057
1100
  <zeroOrMore>
1058
1101
  <choice>
1059
1102
  <ref name="clause-subsection"/>
@@ -1180,6 +1223,9 @@
1180
1223
  <optional>
1181
1224
  <attribute name="script"/>
1182
1225
  </optional>
1226
+ <optional>
1227
+ <attribute name="type"/>
1228
+ </optional>
1183
1229
  <optional>
1184
1230
  <attribute name="obligation">
1185
1231
  <choice>
@@ -1447,11 +1493,6 @@
1447
1493
  </optional>
1448
1494
  </element>
1449
1495
  </define>
1450
- <define name="preface_abstract">
1451
- <element name="abstract">
1452
- <ref name="Basic-Section"/>
1453
- </element>
1454
- </define>
1455
1496
  <define name="term-clause">
1456
1497
  <element name="clause">
1457
1498
  <optional>
@@ -1501,4 +1542,79 @@
1501
1542
  <ref name="CitationType"/>
1502
1543
  </element>
1503
1544
  </define>
1545
+ <define name="amend">
1546
+ <element name="amend">
1547
+ <optional>
1548
+ <attribute name="id">
1549
+ <data type="ID"/>
1550
+ </attribute>
1551
+ </optional>
1552
+ <attribute name="change">
1553
+ <choice>
1554
+ <value>add</value>
1555
+ <value>modify</value>
1556
+ <value>delete</value>
1557
+ </choice>
1558
+ </attribute>
1559
+ <optional>
1560
+ <attribute name="path"/>
1561
+ </optional>
1562
+ <optional>
1563
+ <attribute name="path_end"/>
1564
+ </optional>
1565
+ <optional>
1566
+ <attribute name="title"/>
1567
+ </optional>
1568
+ <optional>
1569
+ <element name="location">
1570
+ <zeroOrMore>
1571
+ <ref name="locality"/>
1572
+ </zeroOrMore>
1573
+ </element>
1574
+ </optional>
1575
+ <zeroOrMore>
1576
+ <ref name="autonumber"/>
1577
+ </zeroOrMore>
1578
+ <optional>
1579
+ <element name="description">
1580
+ <zeroOrMore>
1581
+ <ref name="BasicBlock"/>
1582
+ </zeroOrMore>
1583
+ </element>
1584
+ </optional>
1585
+ <optional>
1586
+ <element name="newcontent">
1587
+ <zeroOrMore>
1588
+ <ref name="BasicBlock"/>
1589
+ </zeroOrMore>
1590
+ </element>
1591
+ </optional>
1592
+ <optional>
1593
+ <element name="description">
1594
+ <zeroOrMore>
1595
+ <ref name="BasicBlock"/>
1596
+ </zeroOrMore>
1597
+ </element>
1598
+ </optional>
1599
+ </element>
1600
+ </define>
1601
+ <define name="autonumber">
1602
+ <element name="autonumber">
1603
+ <attribute name="type">
1604
+ <choice>
1605
+ <value>requirement</value>
1606
+ <value>recommendation</value>
1607
+ <value>permission</value>
1608
+ <value>table</value>
1609
+ <value>figure</value>
1610
+ <value>admonition</value>
1611
+ <value>formula</value>
1612
+ <value>sourcecode</value>
1613
+ <value>example</value>
1614
+ <value>note</value>
1615
+ </choice>
1616
+ </attribute>
1617
+ <text/>
1618
+ </element>
1619
+ </define>
1504
1620
  </grammar>