metanorma-un 0.8.3 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,24 +3,25 @@ require "roman-numerals"
3
3
  module IsoDoc
4
4
  module UN
5
5
  class Xref < IsoDoc::Xref
6
- def initial_anchor_names(d)
7
- preface_names(d.at(ns("//preface/abstract")))
8
- preface_names(d.at(ns("//foreword")))
9
- preface_names(d.at(ns("//introduction")))
10
- d.xpath(ns("//preface/clause")).each do |c|
6
+ def initial_anchor_names(doc)
7
+ preface_names(doc.at(ns("//preface/abstract")))
8
+ preface_names(doc.at(ns("//foreword")))
9
+ preface_names(doc.at(ns("//introduction")))
10
+ doc.xpath(ns("//preface/clause")).each do |c|
11
11
  preface_names(c)
12
12
  end
13
- preface_names(d.at(ns("//acknowledgements")))
13
+ preface_names(doc.at(ns("//acknowledgements")))
14
14
  sequential_asset_names(
15
- d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
16
- "//preface/clause | //acknowledgements")))
17
- middle_section_asset_names(d)
18
- clause_names(d, 0)
19
- termnote_anchor_names(d)
20
- termexample_anchor_names(d)
15
+ doc.xpath(ns("//preface/abstract | //foreword | //introduction | "\
16
+ "//preface/clause | //acknowledgements")),
17
+ )
18
+ middle_section_asset_names(doc)
19
+ clause_names(doc, 0)
20
+ termnote_anchor_names(doc)
21
+ termexample_anchor_names(doc)
21
22
  end
22
23
 
23
- def clause_names(docxml, sect_num)
24
+ def clause_names(docxml, _sect_num)
24
25
  q = "//clause[parent::sections]"
25
26
  @paranumber = 0
26
27
  i = 0
@@ -57,24 +58,28 @@ module IsoDoc
57
58
 
58
59
  def label_leaf_section(clause, lvl)
59
60
  @paranumber += 1
60
- @anchors[clause["id"]] = {label: @paranumber.to_s,
61
- xref: l10n("#{@labels['paragraph']} #{@paranumber}"),
62
- level: lvl, type: "paragraph" }
61
+ @anchors[clause["id"]] =
62
+ { label: @paranumber.to_s, elem: @labels["paragraph"],
63
+ xref: l10n("#{@labels['paragraph']} #{@paranumber}"),
64
+ level: lvl, type: "paragraph" }
63
65
  end
64
66
 
65
67
  def label_annex_leaf_section(clause, num, lvl)
66
68
  @paranumber += 1
67
- @anchors[clause["id"]] = {label: @paranumber.to_s,
68
- xref: l10n("#{@labels['paragraph']} #{num}.#{@paranumber}"),
69
- level: lvl, type: "paragraph" }
69
+ @anchors[clause["id"]] =
70
+ { label: @paranumber.to_s, elem: @labels["paragraph"],
71
+ xref: l10n("#{@labels['paragraph']} #{num}.#{@paranumber}"),
72
+ level: lvl, type: "paragraph" }
70
73
  end
71
74
 
72
75
  def section_names(clause, num, lvl)
73
76
  return num if clause.nil?
77
+
74
78
  leaf_section?(clause) and label_leaf_section(clause, lvl) and return
75
79
  num = num + 1
76
80
  lbl = levelnumber(num, 1)
77
81
  @anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
82
+ elem: @labels["clause"],
78
83
  xref: l10n("#{@labels['clause']} #{lbl}") }
79
84
  i = 1
80
85
  clause.xpath(ns(NONTERMINAL)).each do |c|
@@ -89,6 +94,7 @@ module IsoDoc
89
94
  /\.(?<leafnum>[^.]+$)/ =~ num
90
95
  clause["unnumbered"] == "true" or
91
96
  @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
97
+ elem: @labels["clause"],
92
98
  xref: l10n("#{@labels['clause']} #{num}") }
93
99
  i = 1
94
100
  clause.xpath(ns(NONTERMINAL)).each do |c|
@@ -97,27 +103,32 @@ module IsoDoc
97
103
  end
98
104
  end
99
105
 
100
- def annex_name_lbl(clause, num)
106
+ def annex_name_lbl(_clause, num)
101
107
  l10n("<strong>#{@labels['annex']} #{num}</strong>")
102
108
  end
103
109
 
104
110
  SUBCLAUSES =
105
111
  "./clause | ./references | ./term | ./terms | ./definitions".freeze
106
112
 
113
+ def annex_name_anchors(clause, num)
114
+ { label: annex_name_lbl(clause, num),
115
+ elem: @labels["annex"],
116
+ type: "clause", value: num.to_s, level: 1,
117
+ xref: "#{@labels['annex']} #{num}" }
118
+ end
107
119
 
108
120
  def annex_names(clause, num)
109
121
  hierarchical_asset_names(clause, num)
110
122
  leaf_section?(clause) and
111
123
  label_annex_leaf_section(clause, num, 1) and return
112
- @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
113
- type: "clause", value: num,
114
- xref: l10n("#{@labels['annex']} #{num}"), level: 1 }
124
+ @anchors[clause["id"]] = annex_name_anchors(clause, num)
115
125
  if a = single_annex_special_section(clause)
116
- annex_names1(a, "#{num}", 1)
126
+ annex_names1(a, num.to_s, 1)
117
127
  else
118
128
  i = 1
119
129
  clause.xpath(ns(SUBCLAUSES)).each do |c|
120
130
  next if c["unnumbered"] == "true"
131
+
121
132
  annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
122
133
  i += 1 if !leaf_section?(c)
123
134
  end
@@ -129,10 +140,11 @@ module IsoDoc
129
140
  label_annex_leaf_section(clause, num, level) and return
130
141
  /\.(?<leafnum>[^.]+$)/ =~ num
131
142
  @anchors[clause["id"]] = { label: leafnum, xref: l10n("#{@labels['annex']} #{num}"),
132
- level: level, type: "clause" }
143
+ level: level, type: "clause", elem: @labels["annex"] }
133
144
  i = 1
134
145
  clause.xpath(ns("./clause | ./references")).each do |c|
135
146
  next if c["unnumbered"] == "true"
147
+
136
148
  annex_names1(c, "#{num}.#{annex_levelnum(i, level + 1)}", level + 1)
137
149
  i += 1 if !leaf_section?(c)
138
150
  end
@@ -156,6 +168,7 @@ module IsoDoc
156
168
  i = 0
157
169
  clause.xpath(ns(".//admonition")).each do |t|
158
170
  next if t["id"].nil? || t["id"].empty?
171
+
159
172
  i += 1 unless t["unnumbered"] == "true"
160
173
  @anchors[t["id"]] = anchor_struct(i.to_s, nil, @labels["admonition"],
161
174
  "box", t["unnumbered"])
@@ -166,6 +179,7 @@ module IsoDoc
166
179
  i = 0
167
180
  clause.xpath(ns(".//admonition")).each do |t|
168
181
  next if t["id"].nil? || t["id"].empty?
182
+
169
183
  i += 1 unless t["unnumbered"] == "true"
170
184
  @anchors[t["id"]] =
171
185
  anchor_struct("#{num}.#{i}", nil, @labels["admonition"], "box",
@@ -152,9 +152,7 @@
152
152
  <data type="boolean"/>
153
153
  </attribute>
154
154
  </optional>
155
- <oneOrMore>
156
- <ref name="PureTextElement"/>
157
- </oneOrMore>
155
+ <ref name="XrefBody"/>
158
156
  </element>
159
157
  </define>
160
158
  <define name="erefType">
@@ -188,6 +186,42 @@
188
186
  <ref name="PureTextElement"/>
189
187
  </oneOrMore>
190
188
  </define>
189
+ <define name="localityStack">
190
+ <element name="localityStack">
191
+ <optional>
192
+ <attribute name="connective">
193
+ <choice>
194
+ <value>and</value>
195
+ <value>or</value>
196
+ <value>from</value>
197
+ <value>to</value>
198
+ <value/>
199
+ </choice>
200
+ </attribute>
201
+ </optional>
202
+ <zeroOrMore>
203
+ <ref name="locality"/>
204
+ </zeroOrMore>
205
+ </element>
206
+ </define>
207
+ <define name="sourceLocalityStack">
208
+ <element name="sourceLocalityStack">
209
+ <optional>
210
+ <attribute name="connective">
211
+ <choice>
212
+ <value>and</value>
213
+ <value>or</value>
214
+ <value>from</value>
215
+ <value>to</value>
216
+ <value/>
217
+ </choice>
218
+ </attribute>
219
+ </optional>
220
+ <zeroOrMore>
221
+ <ref name="sourceLocality"/>
222
+ </zeroOrMore>
223
+ </element>
224
+ </define>
191
225
  <define name="ul">
192
226
  <element name="ul">
193
227
  <attribute name="id">
@@ -1098,6 +1132,16 @@
1098
1132
  </define>
1099
1133
  </include>
1100
1134
  <!-- end overrides -->
1135
+ <define name="image" combine="choice">
1136
+ <element name="svg">
1137
+ <oneOrMore>
1138
+ <choice>
1139
+ <text/>
1140
+ <ref name="AnyElement"/>
1141
+ </choice>
1142
+ </oneOrMore>
1143
+ </element>
1144
+ </define>
1101
1145
  <define name="MultilingualRenderingType">
1102
1146
  <choice>
1103
1147
  <value>common</value>
@@ -2631,4 +2675,30 @@
2631
2675
  </zeroOrMore>
2632
2676
  </element>
2633
2677
  </define>
2678
+ <define name="XrefBody">
2679
+ <zeroOrMore>
2680
+ <ref name="XrefTarget"/>
2681
+ </zeroOrMore>
2682
+ <oneOrMore>
2683
+ <ref name="PureTextElement"/>
2684
+ </oneOrMore>
2685
+ </define>
2686
+ <define name="XrefTarget">
2687
+ <element name="location">
2688
+ <attribute name="target">
2689
+ <data type="string">
2690
+ <param name="pattern">\i\c*|\c+#\c+</param>
2691
+ </data>
2692
+ </attribute>
2693
+ <attribute name="connective">
2694
+ <choice>
2695
+ <value>and</value>
2696
+ <value>or</value>
2697
+ <value>from</value>
2698
+ <value>to</value>
2699
+ <value/>
2700
+ </choice>
2701
+ </attribute>
2702
+ </element>
2703
+ </define>
2634
2704
  </grammar>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.8.3".freeze
3
+ VERSION = "0.8.6".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.8.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iso-639
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  requirements: []
294
- rubygems_version: 3.2.32
294
+ rubygems_version: 3.3.9
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Metanorma for UN.