metanorma-standoc 3.5.27 → 3.5.29
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd644e14545ddd034770bfa7cbaedd6dfa03e0d965747f9e785e3c8d35bed0b0
|
|
4
|
+
data.tar.gz: 027e65ca1ce3c58e0263d31060d14948be953567841d615be8d2e4df7d15afdb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 43cb4721ce0f090f1d1bc04f82cabb72f32892582b6049b2841ddde12ebcaa471fa1fb907bd1ad959f29c77253c5d8444da43f308957fab08b53c86cc012ac85
|
|
7
|
+
data.tar.gz: 7ad4bd3554f62d9404b2df08a8555585f455614c7732de6a0c458a1b482265ce1401a48b5456a3def1db85507c9745a60e0dbdcb795a21044dcaa709ec9da3ff
|
|
@@ -7,23 +7,89 @@ module Metanorma
|
|
|
7
7
|
def ref_dl_cleanup(xmldoc)
|
|
8
8
|
xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
|
|
9
9
|
bib = dl_bib_extract(c) or next
|
|
10
|
+
normalize_asciibib_contact(bib, c)
|
|
10
11
|
validate_ref_dl(bib, c)
|
|
11
12
|
xml = Relaton::Bib::ItemData.new(
|
|
12
13
|
**Relaton::Bib::HashParserV1.hash_to_bib(bib),
|
|
13
14
|
).to_xml or next
|
|
14
15
|
bibitem = Nokogiri::XML(xml)
|
|
15
|
-
ref_dl_cleanup_id(bibitem.root, c)
|
|
16
|
+
ref_dl_cleanup_id(bibitem.root, c, bib["id"])
|
|
17
|
+
wrap_asciibib_contact(bibitem.root)
|
|
18
|
+
default_asciibib_role(bibitem.root, c)
|
|
16
19
|
c.replace(bibitem.root)
|
|
17
20
|
end
|
|
18
21
|
end
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
# metanorma-standoc#1412: the citation target is the authored
|
|
24
|
+
# id::, but the legacy Relaton hash parser strips non-word
|
|
25
|
+
# characters from the id (ANSI.X9.95 becomes ANSIX995), leaving
|
|
26
|
+
# cross-references dangling. The anchor is set from the authored
|
|
27
|
+
# string instead.
|
|
28
|
+
def ref_dl_cleanup_id(bibitem, clause, authored_id = nil)
|
|
21
29
|
bibitem["anchor"] = bibitem["id"]
|
|
30
|
+
authored_id && !authored_id.empty? and
|
|
31
|
+
bibitem["anchor"] = authored_id
|
|
22
32
|
clause["anchor"] && !/^_/.match(clause["anchor"]) and
|
|
23
33
|
bibitem["anchor"] = clause["anchor"]
|
|
24
34
|
add_id(bibitem)
|
|
25
35
|
end
|
|
26
36
|
|
|
37
|
+
LEGACY_ASCIIDIB_CONTACT_KEYS =
|
|
38
|
+
%w(street city state country postcode).freeze
|
|
39
|
+
|
|
40
|
+
# metanorma-standoc#1413: the legacy AsciiBib syntax puts street/
|
|
41
|
+
# city/state/country/postcode directly under contact; the
|
|
42
|
+
# canonical form nests them under contact.address, which is what
|
|
43
|
+
# the Relaton hash parser reads. Accept the legacy keys with a
|
|
44
|
+
# deprecation warning naming the canonical form.
|
|
45
|
+
def normalize_asciibib_contact(bib, clause)
|
|
46
|
+
contributors = bib["contributor"]
|
|
47
|
+
contributors = [contributors] unless contributors.is_a?(Array)
|
|
48
|
+
contributors.each do |c|
|
|
49
|
+
org = c.is_a?(Hash) && c["organization"]
|
|
50
|
+
next unless org.is_a?(Hash)
|
|
51
|
+
contacts = org["contact"]
|
|
52
|
+
next unless contacts.is_a?(Hash)
|
|
53
|
+
|
|
54
|
+
legacy = contacts.slice(*LEGACY_ASCIIDIB_CONTACT_KEYS)
|
|
55
|
+
next if legacy.empty?
|
|
56
|
+
|
|
57
|
+
@log.add("STANDOC_73", clause, params: [legacy.keys.join(", ")])
|
|
58
|
+
contacts["address"] = contacts["address"] ? contacts["address"].merge(legacy) : legacy
|
|
59
|
+
LEGACY_ASCIIDIB_CONTACT_KEYS.each { |k| contacts.delete(k) }
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# metanorma-standoc#1413: the Relaton exporter emits address/
|
|
64
|
+
# phone/email/uri directly under organization; the Metanorma
|
|
65
|
+
# schema nests them in a contact element.
|
|
66
|
+
def wrap_asciibib_contact(bibitem)
|
|
67
|
+
bibitem.xpath(".//organization").each do |org|
|
|
68
|
+
direct = org.xpath("./address | ./phone | ./email | ./uri")
|
|
69
|
+
next if direct.empty?
|
|
70
|
+
|
|
71
|
+
contact = Nokogiri::XML::Node.new("contact", org.document)
|
|
72
|
+
logo = org.at_xpath("./logo")
|
|
73
|
+
logo&.before(contact) || org << contact
|
|
74
|
+
direct.each { |n| contact << n }
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# metanorma-standoc#1413: the schema requires a role on every
|
|
79
|
+
# contributor; a role-less AsciiBib contributor renders as
|
|
80
|
+
# author (the released 1.15.3 behaviour) with a warning naming
|
|
81
|
+
# the explicit key.
|
|
82
|
+
def default_asciibib_role(org, clause)
|
|
83
|
+
org.xpath("./contributor").each do |c|
|
|
84
|
+
next if c.at("./role")
|
|
85
|
+
|
|
86
|
+
@log.add("STANDOC_74", clause, params: [])
|
|
87
|
+
role = Nokogiri::XML::Node.new("role", org.document)
|
|
88
|
+
role["type"] = "author"
|
|
89
|
+
c.before(role)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
27
93
|
# do not accept implicit id
|
|
28
94
|
def validate_ref_dl(bib, clause)
|
|
29
95
|
id = bib["id"]
|
|
@@ -227,6 +227,15 @@ module Metanorma
|
|
|
227
227
|
STANDOC_72: { category: "Update Units",
|
|
228
228
|
error: "Update records file %s is malformed: %s",
|
|
229
229
|
severity: 0 },
|
|
230
|
+
STANDOC_73: { category: "Bibliography",
|
|
231
|
+
error: "Legacy AsciiBib contact keys %s are deprecated; " \
|
|
232
|
+
"nest them under contact.address (e.g. " \
|
|
233
|
+
"contact.address.street)",
|
|
234
|
+
severity: 1 },
|
|
235
|
+
STANDOC_74: { category: "Bibliography",
|
|
236
|
+
error: "Contributor is missing a role; defaulting to " \
|
|
237
|
+
"author. Set contributor.role:: explicitly",
|
|
238
|
+
severity: 1 },
|
|
230
239
|
RELATON_1: { category: "Relaton",
|
|
231
240
|
error: "(Error from Relaton) %s",
|
|
232
241
|
severity: 0 },
|
|
@@ -36,6 +36,10 @@ module Metanorma
|
|
|
36
36
|
|
|
37
37
|
# Clause sections nested inside terms (e.g. level definitions
|
|
38
38
|
# under a "Learning outcomes" terms clause in IHO S5 guidelines).
|
|
39
|
+
attribute :definition_lists,
|
|
40
|
+
Metanorma::Document::Components::Lists::DefinitionList,
|
|
41
|
+
collection: true
|
|
42
|
+
|
|
39
43
|
attribute :clause, ClauseSection, collection: true
|
|
40
44
|
|
|
41
45
|
# Term entries
|
|
@@ -58,6 +62,7 @@ module Metanorma
|
|
|
58
62
|
map_element "fmt-xref-label", to: :fmt_xref_label
|
|
59
63
|
map_element "p", to: :paragraphs
|
|
60
64
|
map_element "ul", to: :unordered_lists
|
|
65
|
+
map_element "dl", to: :definition_lists
|
|
61
66
|
map_element "term", to: :terms
|
|
62
67
|
map_element "terms", to: :term_sections
|
|
63
68
|
map_element "clause", to: :clause
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metanorma-standoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.
|
|
4
|
+
version: 3.5.29
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|