metanorma-itu 1.2.16 → 1.3.0

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: 74f8f79bc99c8ff459c43ec1dd68f5fc1486f9f55d2632408a3d22514b5c9d9e
4
- data.tar.gz: 9c15a9900916ffaad81a23b3d44e8238da413fbf2bc042a8c5aa2ff34a67e62b
3
+ metadata.gz: 2ed5bdd15fc291b42dd7b7760aea1a16d11e20cbd098baed7d9670cf4377bef6
4
+ data.tar.gz: dd1cae93081ac5da55e4b1efee4fd908bf9fde4e01e244ae59ea061cb2d0262e
5
5
  SHA512:
6
- metadata.gz: 00f039f6898254841544adace9b22ecc17e9e470198885be2027dc2b435401203fd240ccbcc0a61dae4bf239791e42a62ec27235e940060aea64168f07b5526e
7
- data.tar.gz: ca7a801478f776e35b0dc25fac1b32cc9e5b610466a85ad381e4b689bef95159fbdb5e3017e3a542f0eaa8329bef5b724104b50b9abc5a6a070c63a00381376e
6
+ metadata.gz: 42380cb1f49fed3fc99f51e3455049cdf907b158dad19da9ae2a244a761802924ff1727af053f604bfbfab933dab73bd3b225c03af9318fd15362aebf7d89d7c
7
+ data.tar.gz: 1b4ced1d5237dd83b90254a77a47ed71f3ee97e4b9dc468e09789f8a4d9dd5efda9fd418b42a2e618ee6e66c0404ec43bbd9b0bc1d5e57bf0b8457d0ee5507d3
@@ -24,12 +24,12 @@ module Asciidoctor
24
24
  end
25
25
  end
26
26
 
27
- def insert_missing_sections(x)
28
- insert_scope(x)
29
- insert_norm_ref(x)
30
- insert_terms(x)
31
- insert_symbols(x)
32
- insert_conventions(x)
27
+ def insert_missing_sections(xml)
28
+ insert_scope(xml)
29
+ insert_norm_ref(xml)
30
+ insert_terms(xml)
31
+ insert_symbols(xml)
32
+ insert_conventions(xml)
33
33
  end
34
34
 
35
35
  def add_id
@@ -109,8 +109,10 @@ module Asciidoctor
109
109
 
110
110
  def smartquotes_cleanup(xmldoc)
111
111
  return super if @smartquotes
112
+
112
113
  xmldoc.traverse do |n|
113
114
  next unless n.text?
115
+
114
116
  n.replace(HTMLEntities.new.encode(
115
117
  n.text.gsub(/\u2019|\u2018|\u201a|\u201b/, "'").
116
118
  gsub(/\u201c|\u201d|\u201e|\u201f/, '"'), :basic))
@@ -175,6 +177,7 @@ module Asciidoctor
175
177
  return 4 if bib.at("./docidentifier[@type][not(@type = 'DOI' or "\
176
178
  "@type = 'metanorma' or @type = 'ISSN' or @type = "\
177
179
  "'ISBN')]")
180
+
178
181
  5
179
182
  end
180
183
 
@@ -1,10 +1,9 @@
1
1
  require "asciidoctor"
2
2
  require "asciidoctor/standoc/converter"
3
3
  require "fileutils"
4
- require_relative "./front.rb"
5
- require_relative "./validate.rb"
6
- require_relative "./cleanup.rb"
7
- require_relative "./macros.rb"
4
+ require_relative "./front"
5
+ require_relative "./validate"
6
+ require_relative "./cleanup"
8
7
 
9
8
  module Asciidoctor
10
9
  module ITU
@@ -17,12 +16,7 @@ module Asciidoctor
17
16
 
18
17
  register_for "itu"
19
18
 
20
- Asciidoctor::Extensions.register do
21
- inline_macro AddMacro
22
- inline_macro DelMacro
23
- end
24
-
25
- def title_validate(root)
19
+ def title_validate(_root)
26
20
  nil
27
21
  end
28
22
 
@@ -94,6 +88,7 @@ module Asciidoctor
94
88
  hdr != "terms and definitions" && node.level > 1
95
89
  return nil if ret == "symbols and abbreviated terms" &&
96
90
  hdr != "symbols and abbreviated terms" && node.level > 1
91
+
97
92
  ret
98
93
  end
99
94
 
@@ -110,6 +105,7 @@ module Asciidoctor
110
105
 
111
106
  def metadata_keywords(node, xml)
112
107
  return unless node.attr("keywords")
108
+
113
109
  node.attr("keywords").split(/,[ ]*/).sort.each_with_index do |kw, i|
114
110
  xml.keyword (i == 0 ? kw.capitalize : kw)
115
111
  end
@@ -117,22 +113,24 @@ module Asciidoctor
117
113
 
118
114
  def clause_parse(attrs, xml, node)
119
115
  node.option?("unnumbered") and attrs[:unnumbered] = true
120
- case clausetype = sectiontype1(node)
116
+ case sectiontype1(node)
121
117
  when "conventions" then attrs = attrs.merge(type: "conventions")
122
- when "history"
118
+ when "history"
123
119
  attrs[:preface] and attrs = attrs.merge(type: "history")
124
- when "source"
120
+ when "source"
125
121
  attrs[:preface] and attrs = attrs.merge(type: "source")
126
122
  end
127
123
  super
128
124
  end
129
125
 
130
126
  def html_extract_attributes(node)
131
- super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
127
+ super.merge(hierarchical_assets:
128
+ node.attr("hierarchical-object-numbering"))
132
129
  end
133
130
 
134
131
  def doc_extract_attributes(node)
135
- super.merge(hierarchical_assets: node.attr("hierarchical-object-numbering"))
132
+ super.merge(hierarchical_assets:
133
+ node.attr("hierarchical-object-numbering"))
136
134
  end
137
135
 
138
136
  def presentation_xml_converter(node)
@@ -86,6 +86,35 @@
86
86
  <text/>
87
87
  </element>
88
88
  </define>
89
+ <define name="erefType">
90
+ <optional>
91
+ <attribute name="normative">
92
+ <data type="boolean"/>
93
+ </attribute>
94
+ </optional>
95
+ <attribute name="citeas"/>
96
+ <attribute name="type">
97
+ <ref name="ReferenceFormat"/>
98
+ </attribute>
99
+ <optional>
100
+ <attribute name="alt"/>
101
+ </optional>
102
+ <optional>
103
+ <attribute name="case">
104
+ <choice>
105
+ <value>capital</value>
106
+ <value>lowercase</value>
107
+ </choice>
108
+ </attribute>
109
+ </optional>
110
+ <optional>
111
+ <attribute name="droploc">
112
+ <data type="boolean"/>
113
+ </attribute>
114
+ </optional>
115
+ <ref name="CitationType"/>
116
+ <text/>
117
+ </define>
89
118
  <define name="ul">
90
119
  <element name="ul">
91
120
  <attribute name="id">
@@ -775,6 +804,78 @@
775
804
  <ref name="paragraph"/>
776
805
  </element>
777
806
  </define>
807
+ <define name="em">
808
+ <element name="em">
809
+ <zeroOrMore>
810
+ <choice>
811
+ <ref name="PureTextElement"/>
812
+ <ref name="stem"/>
813
+ <ref name="index"/>
814
+ </choice>
815
+ </zeroOrMore>
816
+ </element>
817
+ </define>
818
+ <define name="strong">
819
+ <element name="strong">
820
+ <zeroOrMore>
821
+ <choice>
822
+ <ref name="PureTextElement"/>
823
+ <ref name="stem"/>
824
+ <ref name="index"/>
825
+ </choice>
826
+ </zeroOrMore>
827
+ </element>
828
+ </define>
829
+ <define name="tt">
830
+ <element name="tt">
831
+ <zeroOrMore>
832
+ <choice>
833
+ <ref name="PureTextElement"/>
834
+ <ref name="index"/>
835
+ </choice>
836
+ </zeroOrMore>
837
+ </element>
838
+ </define>
839
+ <define name="keyword">
840
+ <element name="keyword">
841
+ <zeroOrMore>
842
+ <choice>
843
+ <ref name="PureTextElement"/>
844
+ <ref name="index"/>
845
+ </choice>
846
+ </zeroOrMore>
847
+ </element>
848
+ </define>
849
+ <define name="strike">
850
+ <element name="strike">
851
+ <zeroOrMore>
852
+ <choice>
853
+ <ref name="PureTextElement"/>
854
+ <ref name="index"/>
855
+ </choice>
856
+ </zeroOrMore>
857
+ </element>
858
+ </define>
859
+ <define name="underline">
860
+ <element name="underline">
861
+ <zeroOrMore>
862
+ <choice>
863
+ <ref name="PureTextElement"/>
864
+ <ref name="index"/>
865
+ </choice>
866
+ </zeroOrMore>
867
+ </element>
868
+ </define>
869
+ <define name="smallcap">
870
+ <element name="smallcap">
871
+ <zeroOrMore>
872
+ <choice>
873
+ <ref name="PureTextElement"/>
874
+ <ref name="index"/>
875
+ </choice>
876
+ </zeroOrMore>
877
+ </element>
878
+ </define>
778
879
  </include>
779
880
  <!-- end overrides -->
780
881
  <define name="colgroup">
@@ -793,7 +894,35 @@
793
894
  <value>internal</value>
794
895
  </define>
795
896
  <define name="TextElement" combine="choice">
796
- <ref name="concept"/>
897
+ <choice>
898
+ <ref name="concept"/>
899
+ <ref name="add"/>
900
+ <ref name="del"/>
901
+ </choice>
902
+ </define>
903
+ <define name="add">
904
+ <element name="add">
905
+ <choice>
906
+ <ref name="PureTextElement"/>
907
+ <ref name="eref"/>
908
+ <ref name="stem"/>
909
+ <ref name="keyword"/>
910
+ <ref name="xref"/>
911
+ <ref name="hyperlink"/>
912
+ </choice>
913
+ </element>
914
+ </define>
915
+ <define name="del">
916
+ <element name="del">
917
+ <choice>
918
+ <ref name="PureTextElement"/>
919
+ <ref name="eref"/>
920
+ <ref name="stem"/>
921
+ <ref name="keyword"/>
922
+ <ref name="xref"/>
923
+ <ref name="hyperlink"/>
924
+ </choice>
925
+ </element>
797
926
  </define>
798
927
  <define name="concept">
799
928
  <element name="concept">
@@ -234,36 +234,6 @@
234
234
  <text/>
235
235
  </element>
236
236
  </define>
237
- <define name="TextElement" combine="choice">
238
- <choice>
239
- <ref name="add"/>
240
- <ref name="del"/>
241
- </choice>
242
- </define>
243
- <define name="add">
244
- <element name="add">
245
- <choice>
246
- <ref name="PureTextElement"/>
247
- <ref name="eref"/>
248
- <ref name="stem"/>
249
- <ref name="keyword"/>
250
- <ref name="xref"/>
251
- <ref name="hyperlink"/>
252
- </choice>
253
- </element>
254
- </define>
255
- <define name="del">
256
- <element name="del">
257
- <choice>
258
- <ref name="PureTextElement"/>
259
- <ref name="eref"/>
260
- <ref name="stem"/>
261
- <ref name="keyword"/>
262
- <ref name="xref"/>
263
- <ref name="hyperlink"/>
264
- </choice>
265
- </element>
266
- </define>
267
237
  <define name="ipnoticereceived">
268
238
  <element name="ip-notice-received">
269
239
  <data type="boolean"/>
@@ -1,9 +1,9 @@
1
1
  require "isodoc"
2
2
  require "fileutils"
3
- require_relative "./ref.rb"
4
- require_relative "./xref.rb"
5
- require_relative "./terms.rb"
6
- require_relative "./cleanup.rb"
3
+ require_relative "./ref"
4
+ require_relative "./xref"
5
+ require_relative "./terms"
6
+ require_relative "./cleanup"
7
7
 
8
8
  module IsoDoc
9
9
  module ITU
@@ -14,6 +14,7 @@ module IsoDoc
14
14
  def preface(isoxml, out)
15
15
  isoxml.xpath(ns(FRONT_CLAUSE)).each do |c|
16
16
  next unless is_clause?(c.name)
17
+
17
18
  title = c&.at(ns("./title"))
18
19
  out.div **attr_code(clause_attrs(c)) do |s|
19
20
  clause_name(nil, title, s, class: "IntroTitle")
@@ -34,12 +35,14 @@ module IsoDoc
34
35
 
35
36
  def para_class(node)
36
37
  return "supertitle" if node["class"] == "supertitle"
38
+
37
39
  super
38
40
  end
39
41
 
40
42
  def ol_depth(node)
41
- return super unless node["class"] == "steps" or
43
+ return super unless node["class"] == "steps" ||
42
44
  node.at(".//ancestor::xmlns:ol[@class = 'steps']")
45
+
43
46
  depth = node.ancestors("ul, ol").size + 1
44
47
  type = :arabic
45
48
  type = :alphabet if [2, 7].include? depth
@@ -54,19 +57,22 @@ module IsoDoc
54
57
  div.h1 **{ class: r_a ? "RecommendationAnnex" : "Annex" } do |t|
55
58
  name&.children&.each { |c2| parse(c2, t) }
56
59
  end
57
- annex_obligation_subtitle(annex, div) unless @meta.get[:doctype_original] == "resolution"
60
+ @meta.get[:doctype_original] == "resolution" or
61
+ annex_obligation_subtitle(annex, div)
58
62
  end
59
63
 
60
64
  def annex_obligation_subtitle(annex, div)
61
65
  info = annex["obligation"] == "informative"
62
- div.p **{class: "annex_obligation" } do |p|
63
- p << (info ? @i18n.inform_annex : @i18n.norm_annex).sub(/%/, @meta.get[:doctype] || "")
66
+ div.p **{ class: "annex_obligation" } do |p|
67
+ p << (info ? @i18n.inform_annex : @i18n.norm_annex)
68
+ .sub(/%/, @meta.get[:doctype] || "")
64
69
  end
65
70
  end
66
71
 
67
72
  def annex(isoxml, out)
68
73
  isoxml.xpath(ns("//annex")).each do |c|
69
- @meta.get[:doctype_original] == "recommendation-annex" or page_break(out)
74
+ @meta.get[:doctype_original] == "recommendation-annex" or
75
+ page_break(out)
70
76
  out.div **attr_code(id: c["id"], class: "Section3") do |s|
71
77
  annex_name(c, nil, s) unless c.at(ns("./title"))
72
78
  c.elements.each do |c1|
@@ -106,7 +112,8 @@ module IsoDoc
106
112
  out.p(**{ align: "center", style: "text-align:center;" }) do |p|
107
113
  p.i do |i|
108
114
  i << "("
109
- isoxml.at(ns("//bibdata/title[@type = 'resolution-placedate']")).children.each { |n| parse(n, i) }
115
+ isoxml.at(ns("//bibdata/title[@type = 'resolution-placedate']"))
116
+ .children.each { |n| parse(n, i) }
110
117
  i << ")"
111
118
  end
112
119
  isoxml.xpath(ns("//note[@type = 'title-footnote']")).each do |f|
@@ -117,7 +124,7 @@ module IsoDoc
117
124
 
118
125
  def middle_title_recommendation(isoxml, out)
119
126
  out.p(**{ class: "zzSTDTitle1" }) do |p|
120
- id = @meta.get[:docnumber] and p << "#{@meta.get[:doctype]} #{id}"
127
+ id = @meta.get[:docnumber] and p << "#{@meta.get[:doctype]} #{id}"
121
128
  end
122
129
  out.p(**{ class: "zzSTDTitle2" }) do |p|
123
130
  p << @meta.get[:doctitle]
@@ -129,27 +136,6 @@ module IsoDoc
129
136
  out.p(**{ class: "zzSTDTitle3" }) { |p| p << s }
130
137
  end
131
138
 
132
- def add_parse(node, out)
133
- out.span **{class: "addition"} do |e|
134
- node.children.each { |n| parse(n, e) }
135
- end
136
- end
137
-
138
- def del_parse(node, out)
139
- out.span **{class: "deletion"} do |e|
140
- node.children.each { |n| parse(n, e) }
141
- end
142
- end
143
-
144
- def error_parse(node, out)
145
- case node.name
146
- when "add" then add_parse(node, out)
147
- when "del" then del_parse(node, out)
148
- else
149
- super
150
- end
151
- end
152
-
153
139
  def note_p_parse(node, div)
154
140
  name = node&.at(ns("./name"))&.remove
155
141
  div.p do |p|
@@ -172,12 +158,13 @@ module IsoDoc
172
158
  node.children.each { |n| parse(n, div) }
173
159
  end
174
160
 
175
- def table_footnote_reference_format(a)
176
- a.content = a.content + ")"
161
+ def table_footnote_reference_format(node)
162
+ node.content += ")"
177
163
  end
178
164
 
179
165
  def note_parse(node, out)
180
166
  return if node["type"] == "title-footnote"
167
+
181
168
  super
182
169
  end
183
170
 
@@ -188,9 +175,9 @@ module IsoDoc
188
175
  end
189
176
  end
190
177
 
191
- def clause_core(c, out)
192
- out.div **attr_code(clause_attrs(c)) do |s|
193
- c.elements.each do |c1|
178
+ def clause_core(clause, out)
179
+ out.div **attr_code(clause_attrs(clause)) do |s|
180
+ clause.elements.each do |c1|
194
181
  if c1.name == "title" then clause_name(nil, c1, s, nil)
195
182
  else
196
183
  parse(c1, s)
@@ -201,6 +188,7 @@ module IsoDoc
201
188
 
202
189
  def scope(isoxml, out, num)
203
190
  return super unless @meta.get[:doctype_original] == "resolution"
191
+
204
192
  f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
205
193
  clause_core(f, out)
206
194
  num + 1