metanorma-generic 3.0.4 → 3.1.0
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 +4 -4
- data/lib/metanorma/generic/basicdoc.rng +5 -5
- data/lib/metanorma/generic/bibdata_config.rb +24 -0
- data/lib/metanorma/generic/converter.rb +18 -20
- data/lib/metanorma/generic/front.rb +16 -0
- data/lib/metanorma/generic/isodoc.rng +57 -6
- data/lib/metanorma/generic/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e884aa729dddf661d330c4788cd464554e00ff09c8666e9a86cd96c8da9b627f
|
4
|
+
data.tar.gz: 8502e2a0f09b31126952b0d16e4d919bac0c072806242476365ebb212bfcdba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189f3cb40d41e8e6b0e060baeb47deda8ea4e7eb7db97324f9c85f1d2f930e7f7061c03ee3c2d9827c0d0b95d574a9bc0b86f0e39a9d9f72a8ed0bf901a39707
|
7
|
+
data.tar.gz: 858646781e6f509702a268736a79b7663f47b346adf0cb99b66dc0863542882bdf5cc867ecc827a3be2ccfb42b00e1799dfcccb5438c08a10dbfb1a42088ef1c
|
@@ -198,14 +198,14 @@ Applicable to modify and delete</a:documentation>
|
|
198
198
|
</zeroOrMore>
|
199
199
|
</element>
|
200
200
|
</optional>
|
201
|
-
<
|
201
|
+
<zeroOrMore>
|
202
202
|
<element name="description">
|
203
|
-
<a:documentation>Description of the change described in this block</a:documentation>
|
204
|
-
<
|
203
|
+
<a:documentation>Description(s) of the change described in this block</a:documentation>
|
204
|
+
<oneOrMore>
|
205
205
|
<ref name="BasicBlock"/>
|
206
|
-
</
|
206
|
+
</oneOrMore>
|
207
207
|
</element>
|
208
|
-
</
|
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>
|
@@ -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
|
-
|
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
|
-
|
33
|
-
d == "article"
|
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
|
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
|
@@ -72,6 +72,46 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
|
|
72
72
|
</oneOrMore>
|
73
73
|
</element>
|
74
74
|
</define>
|
75
|
+
<define name="review">
|
76
|
+
<a:documentation>Generalise BasicDoc element from just review comments, to general annotations;
|
77
|
+
the type attribute defaults to `review` for reviews</a:documentation>
|
78
|
+
<element name="annotation">
|
79
|
+
<ref name="RequiredId"/>
|
80
|
+
<ref name="ReviewAttributes"/>
|
81
|
+
<oneOrMore>
|
82
|
+
<ref name="paragraph">
|
83
|
+
<a:documentation>Reviewer comments content</a:documentation>
|
84
|
+
</ref>
|
85
|
+
</oneOrMore>
|
86
|
+
</element>
|
87
|
+
</define>
|
88
|
+
<define name="ruby_pronunciation">
|
89
|
+
<a:documentation>Ruby annotation giving pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
|
90
|
+
<element name="ruby-pronunciation">
|
91
|
+
<attribute name="value">
|
92
|
+
<a:documentation>Ruby annotation value</a:documentation>
|
93
|
+
</attribute>
|
94
|
+
<ref name="LocalizedStringAttributes"/>
|
95
|
+
</element>
|
96
|
+
</define>
|
97
|
+
<define name="ruby_annotation">
|
98
|
+
<a:documentation>Ruby annotation giving information other than pronunciation of text: change tag from BasicDoc for disambiguation</a:documentation>
|
99
|
+
<element name="ruby-annotation">
|
100
|
+
<attribute name="value">
|
101
|
+
<a:documentation>Ruby annotation value</a:documentation>
|
102
|
+
</attribute>
|
103
|
+
<ref name="LocalizedStringAttributes"/>
|
104
|
+
</element>
|
105
|
+
</define>
|
106
|
+
<define name="annotation">
|
107
|
+
<a:documentation>Source code annotation, corresponding to a callout</a:documentation>
|
108
|
+
<element name="callout-annotation">
|
109
|
+
<ref name="RequiredId"/>
|
110
|
+
<oneOrMore>
|
111
|
+
<ref name="paragraph"/>
|
112
|
+
</oneOrMore>
|
113
|
+
</element>
|
114
|
+
</define>
|
75
115
|
<define name="section-title">
|
76
116
|
<a:documentation>Title(s) of a clause</a:documentation>
|
77
117
|
<element name="title">
|
@@ -540,7 +580,7 @@ normative or informative references, some split references into sections organiz
|
|
540
580
|
<ref name="OptionalId"/>
|
541
581
|
<optional>
|
542
582
|
<attribute name="style">
|
543
|
-
<a:documentation>CSS style: only background-color supported</a:documentation>
|
583
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
544
584
|
</attribute>
|
545
585
|
</optional>
|
546
586
|
</define>
|
@@ -620,7 +660,7 @@ This is done if the footnote reference is already presented in some other form,
|
|
620
660
|
<ref name="RequiredId"/>
|
621
661
|
<optional>
|
622
662
|
<attribute name="style">
|
623
|
-
<a:documentation>CSS style: only background-color supported</a:documentation>
|
663
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
624
664
|
</attribute>
|
625
665
|
</optional>
|
626
666
|
</define>
|
@@ -695,11 +735,22 @@ titlecase, or lowercase</a:documentation>
|
|
695
735
|
<ref name="BlockAttributes"/>
|
696
736
|
</define>
|
697
737
|
<define name="TableAttributes" combine="interleave">
|
738
|
+
<optional>
|
739
|
+
<attribute name="plain">
|
740
|
+
<a:documentation>Render as a plain attribute, with no shading or borders</a:documentation>
|
741
|
+
<data type="boolean"/>
|
742
|
+
</attribute>
|
743
|
+
</optional>
|
698
744
|
<optional>
|
699
745
|
<attribute name="width">
|
700
746
|
<a:documentation>Width of the table block in rendering</a:documentation>
|
701
747
|
</attribute>
|
702
748
|
</optional>
|
749
|
+
<optional>
|
750
|
+
<attribute name="style">
|
751
|
+
<a:documentation>CSS style: only background-color, color, border supported</a:documentation>
|
752
|
+
</attribute>
|
753
|
+
</optional>
|
703
754
|
<ref name="BlockAttributes"/>
|
704
755
|
</define>
|
705
756
|
<define name="FigureAttributes" combine="interleave">
|
@@ -1417,7 +1468,7 @@ numbers</a:documentation>
|
|
1417
1468
|
</optional>
|
1418
1469
|
<ref name="DocumentBody"/>
|
1419
1470
|
<optional>
|
1420
|
-
<ref name="
|
1471
|
+
<ref name="annotation-container">
|
1421
1472
|
<a:documentation>Annotations to the document</a:documentation>
|
1422
1473
|
</ref>
|
1423
1474
|
</optional>
|
@@ -1461,8 +1512,8 @@ numbers</a:documentation>
|
|
1461
1512
|
</oneOrMore>
|
1462
1513
|
</element>
|
1463
1514
|
</define>
|
1464
|
-
<define name="
|
1465
|
-
<element name="
|
1515
|
+
<define name="annotation-container">
|
1516
|
+
<element name="annotation-container">
|
1466
1517
|
<oneOrMore>
|
1467
1518
|
<ref name="review"/>
|
1468
1519
|
</oneOrMore>
|
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
|
+
version: 3.1.0
|
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-
|
11
|
+
date: 2025-07-21 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
|