metanorma 1.5.0 → 1.5.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 +4 -4
- data/lib/metanorma/collection_fileparse.rb +22 -9
- data/lib/metanorma/document.rb +7 -6
- data/lib/metanorma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c62d15c313b6595ca184016faa8f0996de7d1d8f1321e932e6adc89d230682d
|
4
|
+
data.tar.gz: f13f182618c3fec66f42e412bfe3d4baa142b877421458fb2555912ce077f8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d7e934fa1d1f0348a9877f25e037294e09513a3df04873ec6394b908d443cb2152480bd14c3e5948071657a6c4bcee2907964b8a2b408c7bb0d67a3f99e37c5
|
7
|
+
data.tar.gz: e1e626b4795c18b5a934262bc37faf0c4fe997832661f73e27e852f6bf66f67bde8c2b2edc86343463e3fde70eefd722e9af19fca186957761048193c70fc29b
|
@@ -38,10 +38,8 @@ module Metanorma
|
|
38
38
|
|
39
39
|
# @param bib [Nokogiri::XML::Element]
|
40
40
|
# @param identifier [String]
|
41
|
-
def update_bibitem(bib, identifier)
|
42
|
-
docid = bib
|
43
|
-
return fail_update_bibitem(docid, identifier) unless @files[docid]
|
44
|
-
|
41
|
+
def update_bibitem(bib, identifier)
|
42
|
+
docid = get_bibitem_docid(bib, identifier) or return
|
45
43
|
newbib = dup_bibitem(docid, bib)
|
46
44
|
bib.replace(newbib)
|
47
45
|
_file, url = targetfile(@files[docid], relative: true, read: false,
|
@@ -52,6 +50,19 @@ module Metanorma
|
|
52
50
|
newbib.at(ns("./docidentifier")).previous = uri_node
|
53
51
|
end
|
54
52
|
|
53
|
+
def get_bibitem_docid(bib, identifier)
|
54
|
+
# IDs for repo references are untyped by default
|
55
|
+
docid = bib.at(ns("./docidentifier[not(@type)]")) ||
|
56
|
+
bib.at(ns("./docidentifier"))
|
57
|
+
docid &&= docid.children.to_xml
|
58
|
+
if @files[docid]
|
59
|
+
docid
|
60
|
+
else
|
61
|
+
fail_update_bibitem(docid, identifier)
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
55
66
|
def fail_update_bibitem(docid, identifier)
|
56
67
|
error = "[metanorma] Cannot find crossreference to document #{docid} "\
|
57
68
|
"in document #{identifier}."
|
@@ -75,7 +86,8 @@ module Metanorma
|
|
75
86
|
# in another file in the collection)
|
76
87
|
# @param file [String] XML content
|
77
88
|
# @param identifier [String] docid
|
78
|
-
# @param internal_refs [Hash{String=>Hash{String=>String}] schema name to
|
89
|
+
# @param internal_refs [Hash{String=>Hash{String=>String}] schema name to
|
90
|
+
# anchor to filename
|
79
91
|
# @return [String] XML content
|
80
92
|
def update_xrefs(file, identifier, internal_refs)
|
81
93
|
docxml = Nokogiri::XML(file) { |config| config.huge }
|
@@ -142,11 +154,12 @@ module Metanorma
|
|
142
154
|
def update_direct_refs_to_docs(docxml, identifier)
|
143
155
|
erefs = collect_erefs(docxml)
|
144
156
|
docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |b|
|
145
|
-
docid = b
|
157
|
+
docid = b.at(ns("./docidentifier[@type = 'repository']"))&.text
|
146
158
|
next unless docid && %r{^current-metanorma-collection/}.match(docid)
|
147
159
|
|
148
160
|
update_bibitem(b, identifier)
|
149
|
-
docid = b
|
161
|
+
docid = b.at(ns("./docidentifier")) or next
|
162
|
+
docid = docid.children.to_xml
|
150
163
|
erefs[:citeas][docid] and update_anchors(b, docxml, docid)
|
151
164
|
end
|
152
165
|
end
|
@@ -211,9 +224,9 @@ module Metanorma
|
|
211
224
|
# anchor given the locality, and insert it into the crossref
|
212
225
|
def update_anchor_create_loc(_bib, eref, docid)
|
213
226
|
ins = eref.at(ns("./localityStack")) or return
|
214
|
-
type = ins
|
227
|
+
type = ins.at(ns("./locality/@type"))&.text
|
215
228
|
type = "clause" if type == "annex"
|
216
|
-
ref = ins
|
229
|
+
ref = ins.at(ns("./locality/referenceFrom"))&.text
|
217
230
|
anchor = @files[docid][:anchors].dig(type, ref) or return
|
218
231
|
ins << "<locality type='anchor'><referenceFrom>#{anchor.sub(/^_/, '')}"\
|
219
232
|
"</referenceFrom></locality>"
|
data/lib/metanorma/document.rb
CHANGED
@@ -40,9 +40,9 @@ module Metanorma
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def attachment_bibitem(identifier)
|
43
|
-
Nokogiri::XML
|
44
|
-
|
45
|
-
|
43
|
+
Nokogiri::XML <<~DOCUMENT
|
44
|
+
<bibdata><docidentifier>#{identifier}</docidentifier></bibdata>
|
45
|
+
DOCUMENT
|
46
46
|
end
|
47
47
|
|
48
48
|
private
|
@@ -94,9 +94,10 @@ module Metanorma
|
|
94
94
|
|
95
95
|
# @return [String]
|
96
96
|
def type
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
first = @bibitem.docidentifier.first
|
98
|
+
@type ||= (first&.type&.downcase ||
|
99
|
+
first&.id&.match(/^[^\s]+/)&.to_s)&.downcase ||
|
100
|
+
"standoc"
|
100
101
|
end
|
101
102
|
|
102
103
|
private
|
data/lib/metanorma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|