metanorma-generic 3.0.4 → 3.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5424d73a9cc722807659e46d7270dda1f24903f66adbea7032900727b54ad66b
4
- data.tar.gz: 79552d897c0464b21c9dd5d70b57a83f2a3926780c60721a44b06b4dc86bf16b
3
+ metadata.gz: 3f80f76fbe32fa0cd4ccb9eafce213a60096b15026f5b6a7abd728426f26a99a
4
+ data.tar.gz: '018891763c69c03a2025acbf55b12ad0035a8b448e3dd9de50cd73145efbe9bd'
5
5
  SHA512:
6
- metadata.gz: f15bb6bcab803c56fe35456cdf03eae535ea8ac9f98eb362010ae8fc85b47766fe90720c7603b7bbe29dd327cdfea6140dd1b48ab6d0b4dd2d8aff59d85e68ac
7
- data.tar.gz: 0dbb13b2cd90a9a529c062a69bc9fe0303b282dcfa8055fd9d94c005398d0250fd336c043633051a4eee5f3f5a4c8680489df0eb76ffa38aac025cced8fd4aa3
6
+ metadata.gz: 1e7c49c95103081c07f6d8a5f74480118eebae36e0a9897236335a1f93138237448348737c533b92c1fb4a1f11bdaefbb9b5701843e4f0fe9ceb654d0090c3fb
7
+ data.tar.gz: 9ce7d22da17427586d6aa90ab860b7aa41cfa61ea5f8f0605ebdbe79d42393bcf8da18d7c1b8b7446b98faeec3312c0f1889a6053421b1bf82978102e1ce2d18
@@ -198,14 +198,14 @@ Applicable to modify and delete</a:documentation>
198
198
  </zeroOrMore>
199
199
  </element>
200
200
  </optional>
201
- <optional>
201
+ <zeroOrMore>
202
202
  <element name="description">
203
- <a:documentation>Description of the change described in this block</a:documentation>
204
- <zeroOrMore>
203
+ <a:documentation>Description(s) of the change described in this block</a:documentation>
204
+ <oneOrMore>
205
205
  <ref name="BasicBlock"/>
206
- </zeroOrMore>
206
+ </oneOrMore>
207
207
  </element>
208
- </optional>
208
+ </zeroOrMore>
209
209
  <optional>
210
210
  <element name="newcontent">
211
211
  <a:documentation>New content to be added to the document; applicable to add and modify</a:documentation>
@@ -1291,13 +1291,13 @@ Restricted recursively to contain only other such inline elements with no identi
1291
1291
  <ref name="pure_strike"/>
1292
1292
  <ref name="pure_smallcap"/>
1293
1293
  <ref name="br"/>
1294
+ <ref name="stem"/>
1294
1295
  </choice>
1295
1296
  </define>
1296
1297
  <define name="NestedTextElement">
1297
1298
  <a:documentation>Contents of TextElement tags: leaves out tags that should occur only at top level of block: bookmark image hr pagebreak</a:documentation>
1298
1299
  <choice>
1299
1300
  <ref name="PureTextElement"/>
1300
- <ref name="stem"/>
1301
1301
  <ref name="eref"/>
1302
1302
  <ref name="xref"/>
1303
1303
  <ref name="hyperlink"/>
@@ -0,0 +1,24 @@
1
+ module Metanorma
2
+ module Generic
3
+ class BibdataConfig < ::Lutaml::Model::Serializable
4
+ class Bibdata < ::Lutaml::Model::Serializable
5
+ model ::RelatonBib::BibliographicItem
6
+ end
7
+
8
+ attribute :bibdata, Bibdata
9
+
10
+ xml do
11
+ root "metanorma"
12
+ map_element "bibdata", to: :bibdata, with: { from: :bibdata_from_xml,
13
+ to: :bibdata_to_xml }
14
+ end
15
+
16
+ def bibdata_from_xml(model, node)
17
+ node or return
18
+ model.bibdata = Relaton::Cli.parse_xml(node.adapter_node)
19
+ end
20
+
21
+ def bibdata_to_xml(model, parent, doc); end
22
+ end
23
+ end
24
+ end
@@ -2,6 +2,7 @@ require "asciidoctor"
2
2
  require "metanorma/standoc/converter"
3
3
  require "fileutils"
4
4
  require_relative "front"
5
+ require_relative "bibdata_config"
5
6
  require "metanorma"
6
7
  require "pathname"
7
8
 
@@ -16,23 +17,25 @@ module Metanorma
16
17
  end
17
18
 
18
19
  def docidentifier_cleanup(xmldoc)
20
+ docid = xmldoc.at("//bibdata/docidentifier") or return
21
+ docid.text.empty? or return
22
+ id = docidentifier_from_template(xmldoc) or return
23
+ (id.empty? and docid.remove) or docid.children = id
24
+ end
25
+
26
+ def docidentifier_from_template(xmldoc)
19
27
  b = boilerplate_isodoc(xmldoc) or return
20
28
  template = configuration.docid_template ||
21
29
  "{{ organization_name_short }} {{ docnumeric }}"
22
- docid = xmldoc.at("//bibdata/docidentifier")
23
- docid&.text&.empty? or return
24
- id = b.populate_template(template, nil)
25
- (id.empty? and docid.remove) or docid.children = id
30
+ b.populate_template(template, nil)
26
31
  end
27
32
 
28
33
  def doctype(node)
29
34
  d = super
30
35
  node.attr("doctype") == "article" and d = "article"
31
36
  a = configuration.default_doctype and @default_doctype = a
32
- unless configuration.doctypes
33
- d == "article" and return @default_doctype
34
- return d
35
- end
37
+ configuration.doctypes or
38
+ return d == "article" ? @default_doctype : d
36
39
  type = @default_doctype || configuration.doctypes.keys[0]
37
40
  if !configuration.doctypes.key?(d)
38
41
  node.attr("doctype") && node.attr("doctype") != "article" and # factory default
@@ -162,9 +165,16 @@ module Metanorma
162
165
  Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
163
166
  conv.meta.set(a, configuration.send(a))
164
167
  end
168
+ #conv.meta.set(:bibdata, bibdata_hash(xmldoc))
165
169
  conv
166
170
  end
167
171
 
172
+ def bibdata_hash(xmldoc)
173
+ b = xmldoc.at("//bibdata") || xmldoc.at("//xmlns:bibdata")
174
+ BibdataConfig.from_xml("<metanorma>#{b.to_xml}</metanorma>")
175
+ .bibdata.to_hash
176
+ end
177
+
168
178
  def boilerplate_file(xmldoc)
169
179
  f = configuration.boilerplate
170
180
  f.nil? and return super
@@ -172,18 +182,6 @@ module Metanorma
172
182
  f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
173
183
  super
174
184
  end
175
-
176
- def cleanup(xmldoc)
177
- super
178
- empty_metadata_cleanup(xmldoc)
179
- xmldoc
180
- end
181
-
182
- def empty_metadata_cleanup(xmldoc)
183
- xmldoc.xpath("//bibdata/ext//*").each do |x|
184
- x.remove if x.children.empty?
185
- end
186
- end
187
185
  end
188
186
  end
189
187
  end
@@ -60,6 +60,22 @@ module Metanorma
60
60
  a = node.attr(e) and ext.send e, a
61
61
  end
62
62
  end
63
+ empty_metadata_cleanup(ext.parent)
64
+ end
65
+
66
+ # Keep cleaning until no more elements are removed (recursive depth-first)
67
+ # Process elements in reverse doc order to handle nested removals properly
68
+ def empty_metadata_cleanup(ext)
69
+ loop do
70
+ removed_count = 0
71
+ ext.xpath(".//*").reverse_each do |element|
72
+ element.children.empty? && element.attributes.empty? or next
73
+ element.remove
74
+ removed_count += 1
75
+ end
76
+ removed_count.zero? and break # Stop when no elems removed this pass
77
+
78
+ end
63
79
  end
64
80
 
65
81
  def metadata_doctype(node, xml)
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <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">
3
- <!-- VERSION v2.0.7 -->
3
+ <!-- VERSION v2.1.0 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -42,33 +42,43 @@ All IdRefType instances point not to `@id` in Semantic XML, which is the Content
42
42
  but to `@anchor`, the user-supplied cross-reference</a:documentation>
43
43
  <text/>
44
44
  </define>
45
- <define name="index-primary">
46
- <element name="primary">
45
+ <define name="review">
46
+ <a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
47
+ the type attribute defaults to `review` for reviews</a:documentation>
48
+ <element name="annotation">
49
+ <ref name="RequiredId"/>
50
+ <ref name="ReviewAttributes"/>
47
51
  <oneOrMore>
48
- <choice>
49
- <ref name="PureTextElement"/>
50
- <ref name="stem"/>
51
- </choice>
52
+ <ref name="paragraph">
53
+ <a:documentation>Reviewer comments content</a:documentation>
54
+ </ref>
52
55
  </oneOrMore>
53
56
  </element>
54
57
  </define>
55
- <define name="index-secondary">
56
- <element name="secondary">
57
- <oneOrMore>
58
- <choice>
59
- <ref name="PureTextElement"/>
60
- <ref name="stem"/>
61
- </choice>
62
- </oneOrMore>
58
+ <define name="ruby_pronunciation">
59
+ <a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
60
+ <element name="ruby-pronunciation">
61
+ <attribute name="value">
62
+ <a:documentation>Ruby annotation value</a:documentation>
63
+ </attribute>
64
+ <ref name="LocalizedStringAttributes"/>
63
65
  </element>
64
66
  </define>
65
- <define name="index-tertiary">
66
- <element name="tertiary">
67
+ <define name="ruby_annotation">
68
+ <a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
69
+ <element name="ruby-annotation">
70
+ <attribute name="value">
71
+ <a:documentation>Ruby annotation value</a:documentation>
72
+ </attribute>
73
+ <ref name="LocalizedStringAttributes"/>
74
+ </element>
75
+ </define>
76
+ <define name="annotation">
77
+ <a:documentation>Source code annotation, corresponding to a callout</a:documentation>
78
+ <element name="callout-annotation">
79
+ <ref name="RequiredId"/>
67
80
  <oneOrMore>
68
- <choice>
69
- <ref name="PureTextElement"/>
70
- <ref name="stem"/>
71
- </choice>
81
+ <ref name="paragraph"/>
72
82
  </oneOrMore>
73
83
  </element>
74
84
  </define>
@@ -540,7 +550,7 @@ normative or informative references, some split references into sections organiz
540
550
  <ref name="OptionalId"/>
541
551
  <optional>
542
552
  <attribute name="style">
543
- <a:documentation>CSS style: only background-color supported</a:documentation>
553
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
544
554
  </attribute>
545
555
  </optional>
546
556
  </define>
@@ -552,28 +562,6 @@ normative or informative references, some split references into sections organiz
552
562
  </oneOrMore>
553
563
  </element>
554
564
  </define>
555
- <define name="sub">
556
- <a:documentation>Subscript text. Corresponds to HTML `sub</a:documentation>
557
- <element name="sub">
558
- <zeroOrMore>
559
- <choice>
560
- <ref name="PureTextElement"/>
561
- <ref name="stem"/>
562
- </choice>
563
- </zeroOrMore>
564
- </element>
565
- </define>
566
- <define name="sup">
567
- <a:documentation>Superscript text. Corresponds to HTML `sup`</a:documentation>
568
- <element name="sup">
569
- <zeroOrMore>
570
- <choice>
571
- <ref name="PureTextElement"/>
572
- <ref name="stem"/>
573
- </choice>
574
- </zeroOrMore>
575
- </element>
576
- </define>
577
565
  <define name="pagebreak">
578
566
  <a:documentation>Page break. Only applicable in paged layouts (e.g. PDF, Word), and not flow layouts (e.g. HTML)</a:documentation>
579
567
  <element name="pagebreak">
@@ -620,7 +608,7 @@ This is done if the footnote reference is already presented in some other form,
620
608
  <ref name="RequiredId"/>
621
609
  <optional>
622
610
  <attribute name="style">
623
- <a:documentation>CSS style: only background-color supported</a:documentation>
611
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
624
612
  </attribute>
625
613
  </optional>
626
614
  </define>
@@ -695,11 +683,22 @@ titlecase, or lowercase</a:documentation>
695
683
  <ref name="BlockAttributes"/>
696
684
  </define>
697
685
  <define name="TableAttributes" combine="interleave">
686
+ <optional>
687
+ <attribute name="plain">
688
+ <a:documentation>Render as a plain attribute, with no shading or borders</a:documentation>
689
+ <data type="boolean"/>
690
+ </attribute>
691
+ </optional>
698
692
  <optional>
699
693
  <attribute name="width">
700
694
  <a:documentation>Width of the table block in rendering</a:documentation>
701
695
  </attribute>
702
696
  </optional>
697
+ <optional>
698
+ <attribute name="style">
699
+ <a:documentation>CSS style: only background-color, color, border supported</a:documentation>
700
+ </attribute>
701
+ </optional>
703
702
  <ref name="BlockAttributes"/>
704
703
  </define>
705
704
  <define name="FigureAttributes" combine="interleave">
@@ -1043,7 +1042,6 @@ That concept may be defined as a term within the current document, or it may be
1043
1042
  <zeroOrMore>
1044
1043
  <choice>
1045
1044
  <ref name="PureTextElement"/>
1046
- <ref name="stem"/>
1047
1045
  <ref name="index"/>
1048
1046
  <ref name="index-xref"/>
1049
1047
  </choice>
@@ -1056,7 +1054,6 @@ That concept may be defined as a term within the current document, or it may be
1056
1054
  <zeroOrMore>
1057
1055
  <choice>
1058
1056
  <ref name="PureTextElement"/>
1059
- <ref name="stem"/>
1060
1057
  <ref name="index"/>
1061
1058
  <ref name="index-xref"/>
1062
1059
  </choice>
@@ -1417,7 +1414,7 @@ numbers</a:documentation>
1417
1414
  </optional>
1418
1415
  <ref name="DocumentBody"/>
1419
1416
  <optional>
1420
- <ref name="review-container">
1417
+ <ref name="annotation-container">
1421
1418
  <a:documentation>Annotations to the document</a:documentation>
1422
1419
  </ref>
1423
1420
  </optional>
@@ -1461,8 +1458,8 @@ numbers</a:documentation>
1461
1458
  </oneOrMore>
1462
1459
  </element>
1463
1460
  </define>
1464
- <define name="review-container">
1465
- <element name="review-container">
1461
+ <define name="annotation-container">
1462
+ <element name="annotation-container">
1466
1463
  <oneOrMore>
1467
1464
  <ref name="review"/>
1468
1465
  </oneOrMore>
@@ -1974,10 +1971,7 @@ used in document amendments</a:documentation>
1974
1971
  <element name="name">
1975
1972
  <a:documentation>The symbolic form of the designation</a:documentation>
1976
1973
  <oneOrMore>
1977
- <choice>
1978
- <ref name="PureTextElement"/>
1979
- <ref name="stem"/>
1980
- </choice>
1974
+ <ref name="PureTextElement"/>
1981
1975
  </oneOrMore>
1982
1976
  </element>
1983
1977
  </element>
@@ -2030,7 +2024,6 @@ used in document amendments</a:documentation>
2030
2024
  <zeroOrMore>
2031
2025
  <choice>
2032
2026
  <ref name="PureTextElement"/>
2033
- <ref name="stem"/>
2034
2027
  <ref name="index"/>
2035
2028
  <ref name="index-xref"/>
2036
2029
  </choice>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "3.0.4".freeze
3
+ VERSION = "3.1.1".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.4
4
+ version: 3.1.1
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-06-23 00:00:00.000000000 Z
11
+ date: 2025-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -237,6 +237,7 @@ files:
237
237
  - lib/metanorma-generic.rb
238
238
  - lib/metanorma/generic.rb
239
239
  - lib/metanorma/generic/basicdoc.rng
240
+ - lib/metanorma/generic/bibdata_config.rb
240
241
  - lib/metanorma/generic/biblio-standoc.rng
241
242
  - lib/metanorma/generic/biblio.rng
242
243
  - lib/metanorma/generic/converter.rb