metanorma-bipm 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,12 +107,6 @@ module IsoDoc
107
107
  jcgm_eref(docxml, "//fmt-origin[not(.//termref)]")
108
108
  end
109
109
 
110
- # KILL
111
- def quotesourcex(docxml)
112
- super
113
- jcgm_eref(docxml, "//quote//source")
114
- end
115
-
116
110
  def jcgm_eref(docxml, xpath)
117
111
  @jcgm or return
118
112
  docxml.xpath(ns(xpath)).each { |x| extract_brackets(x) }
@@ -120,7 +114,8 @@ module IsoDoc
120
114
  docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
121
115
  docxml.xpath(ns(xpath)).each do |x| # rubocop: disable Style/CombinableLoops
122
116
  if x.parent.next&.text? && /^\],\s+\[$/.match?(x.parent.next.text) &&
123
- %w(eref origin fmt-eref fmt-origin).include?(x.parent.next.next&.name)
117
+ %w(eref origin fmt-eref
118
+ fmt-origin).include?(x.parent.next.next&.name)
124
119
  x.parent.next.replace(", ")
125
120
  end
126
121
  end
@@ -144,19 +139,9 @@ module IsoDoc
144
139
  end
145
140
  end
146
141
 
147
- # KILL
148
- def termsource1_xx(elem)
149
- # elem["status"] == "modified" and return super
150
- while elem&.next_element&.name == "termsource"
151
- elem << "; #{to_xml(elem.next_element.remove.children)}"
152
- end
153
- elem.children = l10n("[#{termsource_adapt(elem['status'])}" \
154
- "#{to_xml(elem.children).strip}]")
155
- end
156
-
157
142
  def termsource_label(elem, sources)
158
- elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
159
- end
143
+ elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
144
+ end
160
145
 
161
146
  def termsource_adapt(status)
162
147
  case status
@@ -179,10 +164,6 @@ module IsoDoc
179
164
  end
180
165
 
181
166
  def termsource_modification(elem)
182
- # if elem["status"] == "modified"
183
- # origin = elem.at(ns("./origin"))
184
- # s = termsource_status(elem["status"]) and origin.next = l10n(", #{s}")
185
- # end
186
167
  termsource_add_modification_text(elem.at(ns("./modification")))
187
168
  end
188
169
 
@@ -204,6 +185,101 @@ module IsoDoc
204
185
  @xrefs.bookmark_anchor_names(docxml)
205
186
  end
206
187
 
188
+ def fn_label_brackets(fnote)
189
+ "<sup><span class='fmt-label-delim'>(</span>" \
190
+ "#{fn_label(fnote)}" \
191
+ "<span class='fmt-label-delim'>)</span></sup>"
192
+ end
193
+
194
+ def fn_ref_label(fnote)
195
+ if @jcgm then iso_fn_ref_label(fnote)
196
+ else fn_label_brackets(fnote)
197
+ end
198
+ end
199
+
200
+ # copied from ISO
201
+ def iso_fn_ref_label(fnote)
202
+ if fnote.ancestors("table, figure").empty? ||
203
+ !fnote.ancestors("name, fmt-name").empty?
204
+ "<sup>#{fn_label(fnote)}" \
205
+ "<span class='fmt-label-delim'>)</span></sup>"
206
+ else
207
+ "<sup>#{fn_label(fnote)}</sup>"
208
+ end
209
+ end
210
+
211
+ def fn_body_label(fnote)
212
+ if @jcgm then super
213
+ else fn_label_brackets(fnote)
214
+ end
215
+ end
216
+
217
+ # explode out all the subclauses into separate entries
218
+ # assume no hanging clauses
219
+ def sort_footnote_sections(docxml)
220
+ ret = super
221
+ ret.flat_map do |x|
222
+ clauses = x.xpath(ns(".//clause[not(./clause)]"))
223
+ clauses.empty? ? [x] : clauses.to_a
224
+ end
225
+ end
226
+
227
+ # quote/table/fn references are not unique within quote
228
+ # if there are multiple tables
229
+ def renumber_document_footnote_key(fnote)
230
+ key = fnote["reference"]
231
+ !@jcgm && (t = fnote.at("./ancestor::xmlns:table")) and
232
+ key = "#{t['id']} #{key}"
233
+ key
234
+ end
235
+
236
+ def renumber_document_footnote(fnote, idx, seen)
237
+ fnote["original-reference"] = fnote["reference"]
238
+ key = renumber_document_footnote_key(fnote)
239
+ if seen[key]
240
+ fnote["reference"] = seen[fnote["reference"]]
241
+ else
242
+ seen[key] = idx
243
+ fnote["reference"] = idx
244
+ idx += 1
245
+ end
246
+ idx
247
+ end
248
+
249
+ def document_footnotes(docxml)
250
+ @jcgm and return super
251
+ sects = sort_footnote_sections(docxml)
252
+ excl = non_document_footnotes(docxml)
253
+ fns = filter_document_footnotes(sects, excl)
254
+ #sects.select { |s| s.at(ns(".//fn")) }.each_with_index do |s, i|
255
+ sects.each_with_index do |s, i|
256
+ ret = footnote_collect(renumber_document_footnotes(fns[i], 1))
257
+ f = footnote_container(fns[i], ret) and s << f
258
+ end
259
+ end
260
+
261
+ def renumber_document_footnotes(fns, idx)
262
+ @jcgm and return super
263
+ fns.each_with_object({}) do |f, seen|
264
+ idx = renumber_document_footnote(f, idx, seen)
265
+ end
266
+ fns
267
+ end
268
+
269
+ def table_fn(elem)
270
+ !@jcgm && !elem.ancestors("quote").empty? and return
271
+ super
272
+ end
273
+
274
+ def non_document_footnotes(docxml)
275
+ table_fns = docxml.xpath(ns("//table//fn")) -
276
+ docxml.xpath(ns("//table/name//fn"))
277
+ @jcgm or table_fns -= docxml.xpath(ns("//quote//table//fn"))
278
+ fig_fns = docxml.xpath(ns("//figure//fn")) -
279
+ docxml.xpath(ns("//figure/name//fn"))
280
+ table_fns + fig_fns
281
+ end
282
+
207
283
  include Init
208
284
  end
209
285
  end
@@ -382,33 +382,7 @@ in a document (e.g. sourcecode annotations)</a:documentation>
382
382
  <a:documentation>Block intended to capture reviewer comments about some text in the document</a:documentation>
383
383
  <element name="review">
384
384
  <ref name="RequiredId"/>
385
- <attribute name="reviewer">
386
- <a:documentation>The party who has offered the comment</a:documentation>
387
- </attribute>
388
- <optional>
389
- <attribute name="type">
390
- <a:documentation>The type of reviewer comment</a:documentation>
391
- </attribute>
392
- </optional>
393
- <optional>
394
- <attribute name="date">
395
- <a:documentation>The date when the comment was made</a:documentation>
396
- <data type="dateTime"/>
397
- </attribute>
398
- </optional>
399
- <optional>
400
- <attribute name="from">
401
- <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
402
- If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
403
- <data type="IDREF"/>
404
- </attribute>
405
- </optional>
406
- <optional>
407
- <attribute name="to">
408
- <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
409
- <data type="IDREF"/>
410
- </attribute>
411
- </optional>
385
+ <ref name="ReviewAttributes"/>
412
386
  <oneOrMore>
413
387
  <ref name="paragraph">
414
388
  <a:documentation>Reviewer comments content</a:documentation>
@@ -416,6 +390,35 @@ If not provided, the comment applies in the vicinity of the place it has been in
416
390
  </oneOrMore>
417
391
  </element>
418
392
  </define>
393
+ <define name="ReviewAttributes">
394
+ <attribute name="reviewer">
395
+ <a:documentation>The party who has offered the comment</a:documentation>
396
+ </attribute>
397
+ <optional>
398
+ <attribute name="type">
399
+ <a:documentation>The type of reviewer comment</a:documentation>
400
+ </attribute>
401
+ </optional>
402
+ <optional>
403
+ <attribute name="date">
404
+ <a:documentation>The date when the comment was made</a:documentation>
405
+ <data type="dateTime"/>
406
+ </attribute>
407
+ </optional>
408
+ <optional>
409
+ <attribute name="from">
410
+ <a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
411
+ If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
412
+ <data type="IDREF"/>
413
+ </attribute>
414
+ </optional>
415
+ <optional>
416
+ <attribute name="to">
417
+ <a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
418
+ <data type="IDREF"/>
419
+ </attribute>
420
+ </optional>
421
+ </define>
419
422
  <define name="NumberingAttributes">
420
423
  <optional>
421
424
  <attribute name="unnumbered">
@@ -857,6 +860,7 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
857
860
  <define name="tr">
858
861
  <a:documentation>Sequence of cells to be displayed as a row in a table</a:documentation>
859
862
  <element name="tr">
863
+ <ref name="TrAttributes"/>
860
864
  <oneOrMore>
861
865
  <choice>
862
866
  <ref name="td">
@@ -869,6 +873,9 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
869
873
  </oneOrMore>
870
874
  </element>
871
875
  </define>
876
+ <define name="TrAttributes">
877
+ <empty/>
878
+ </define>
872
879
  <define name="tr-no-id">
873
880
  <a:documentation>Sequence of cells to be displayed as a row in a table: optional ID attributes recursively (for use in Relaton, metadata)</a:documentation>
874
881
  <element name="tr">
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v2.0.0 -->
20
+ <!-- VERSION v2.0.2 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -33,6 +33,15 @@
33
33
  </zeroOrMore>
34
34
  </element>
35
35
  </define>
36
+ <define name="fn" combine="interleave">
37
+ <optional>
38
+ <attribute name="hiddenref">
39
+ <a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
40
+ This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
41
+ <data type="boolean"/>
42
+ </attribute>
43
+ </optional>
44
+ </define>
36
45
  <define name="index-primary">
37
46
  <element name="primary">
38
47
  <oneOrMore>
@@ -414,6 +423,21 @@ normative or informative references, some split references into sections organiz
414
423
  </oneOrMore>
415
424
  </choice>
416
425
  </define>
426
+ <define name="TdAttributes" combine="interleave">
427
+ <attribute name="style">
428
+ <a:documentation>CSS style: only background-color supported</a:documentation>
429
+ </attribute>
430
+ </define>
431
+ <define name="ThAttributes" combine="interleave">
432
+ <attribute name="style">
433
+ <a:documentation>CSS style: only background-color supported</a:documentation>
434
+ </attribute>
435
+ </define>
436
+ <define name="TrAttributes">
437
+ <attribute name="style">
438
+ <a:documentation>CSS style: only background-color supported</a:documentation>
439
+ </attribute>
440
+ </define>
417
441
  <define name="table-note">
418
442
  <element name="note">
419
443
  <ref name="OptionalId"/>
@@ -1263,6 +1287,11 @@ numbers</a:documentation>
1263
1287
  <a:documentation>Colophon or postface material</a:documentation>
1264
1288
  </ref>
1265
1289
  </optional>
1290
+ <optional>
1291
+ <ref name="review-container">
1292
+ <a:documentation>Annotations to the document</a:documentation>
1293
+ </ref>
1294
+ </optional>
1266
1295
  </element>
1267
1296
  </define>
1268
1297
  <define name="misccontainer">
@@ -1273,6 +1302,13 @@ numbers</a:documentation>
1273
1302
  </oneOrMore>
1274
1303
  </element>
1275
1304
  </define>
1305
+ <define name="review-container">
1306
+ <element name="review-container">
1307
+ <oneOrMore>
1308
+ <ref name="review"/>
1309
+ </oneOrMore>
1310
+ </element>
1311
+ </define>
1276
1312
  <define name="preface">
1277
1313
  <element name="preface">
1278
1314
  <oneOrMore>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Bipm
3
- VERSION = "2.6.1".freeze
3
+ VERSION = "2.6.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-bipm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.1
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-04 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-generic