metanorma-standoc 3.5.1.pre.alpha.2 → 3.5.1.pre.alpha.4
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/cleanup/term_lookup.rb +70 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -3
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8f41ce37c36a6738ac98eb9e86bb5138321e7589211ad2707d936b43b552014
|
|
4
|
+
data.tar.gz: 7fadb5258380cb3b8eaa287373d74be84eea3d2da1c2bb828009eb2cecf3e615
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8df61e622e50667ba826c7a25326f6deb289a70db9c61640ff110fe42746a9fce0e9280845b828d2cf5ffa4e41bbd724d385260695705530d9b4d2e5cbea1673
|
|
7
|
+
data.tar.gz: 113665c40908bd8001d1e98cdd4ce737b27e227170388bbb37508603451585db90a42fec5c7dba989a568eae298754327ff26b46a920d15d0fa0f28a7414f057
|
|
@@ -103,9 +103,77 @@ module Metanorma
|
|
|
103
103
|
def lookup_refterm(node)
|
|
104
104
|
target = norm_ref_id1(node)
|
|
105
105
|
if @lookup[:term][target].nil? && @lookup[:symbol][target].nil?
|
|
106
|
-
|
|
106
|
+
if (fallback = unique_term_fallback(target, node))
|
|
107
|
+
target = fallback
|
|
108
|
+
else
|
|
109
|
+
remove_missing_ref(node, target)
|
|
110
|
+
return
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
if (x = node.at("../xrefrender"))
|
|
114
|
+
modify_ref_node(x, target)
|
|
107
115
|
else
|
|
108
|
-
|
|
116
|
+
# bare mention resolved by fallback: the macro left no xrefrender
|
|
117
|
+
ref = Nokogiri::XML::Node.new("xref", @xmldoc)
|
|
118
|
+
ref["target"] = @lookup[:term][target] || target
|
|
119
|
+
node.at("..").add_child(ref)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Mentions are looked up by bare name, but terms in domain-scoped
|
|
124
|
+
# vocabularies are anchored with a domain prefix, so a bare mention
|
|
125
|
+
# misses every key. Resolve a mention whose designation is unique
|
|
126
|
+
# document-wide, or unique within the domain of the term containing
|
|
127
|
+
# the mention.
|
|
128
|
+
# Mentions are looked up by bare name, but terms in domain-scoped
|
|
129
|
+
# vocabularies are anchored with a domain prefix, so a bare mention
|
|
130
|
+
# misses every key. Resolve a mention whose designation is unique
|
|
131
|
+
# document-wide, or unique within the domain of the term containing
|
|
132
|
+
# the mention.
|
|
133
|
+
def unique_term_fallback(target, node)
|
|
134
|
+
cands = @lookup[:term].keys.select do |k|
|
|
135
|
+
k == target || k.end_with?("-#{target}")
|
|
136
|
+
end
|
|
137
|
+
return nil if cands.empty?
|
|
138
|
+
return cands.first if cands.size == 1
|
|
139
|
+
|
|
140
|
+
term = mention_enclosing_term(node) or return nil
|
|
141
|
+
name = first_descendant(term, "name")&.text or return nil
|
|
142
|
+
anchor = term[:anchor] || term["anchor"] or return nil
|
|
143
|
+
name_key = norm_ref_id_text(name)
|
|
144
|
+
prefix_key = anchor.sub(/\Aterm-/, "").sub(/-#{Regexp.escape(name_key)}\z/, "")
|
|
145
|
+
narrowed = cands.select { |k| k.start_with?("#{prefix_key}-") }
|
|
146
|
+
narrowed.size == 1 ? narrowed.first : nil
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def first_descendant(node, name)
|
|
150
|
+
node.children&.each do |c|
|
|
151
|
+
next unless c.respond_to?(:name)
|
|
152
|
+
|
|
153
|
+
return c if c.name == name
|
|
154
|
+
found = begin
|
|
155
|
+
first_descendant(c, name)
|
|
156
|
+
rescue StandardError
|
|
157
|
+
nil
|
|
158
|
+
end
|
|
159
|
+
return found if found
|
|
160
|
+
end
|
|
161
|
+
nil
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# The moxml/leptris XML engine's XPath does not support the ancestor
|
|
165
|
+
# axis, and Node#parent is unreliable on XPath-result nodes; hop the
|
|
166
|
+
# parent axis with ".." instead.
|
|
167
|
+
def mention_enclosing_term(node)
|
|
168
|
+
cur = node
|
|
169
|
+
loop do
|
|
170
|
+
cur = begin
|
|
171
|
+
cur&.at("..")
|
|
172
|
+
rescue StandardError
|
|
173
|
+
nil
|
|
174
|
+
end
|
|
175
|
+
return nil if cur.nil?
|
|
176
|
+
return cur if cur.name == "term"
|
|
109
177
|
end
|
|
110
178
|
end
|
|
111
179
|
|
data/metanorma-standoc.gemspec
CHANGED
|
@@ -49,10 +49,9 @@ Gem::Specification.new do |spec|
|
|
|
49
49
|
# content back (the 0.13 SvgMapping contract: vectory processes its own
|
|
50
50
|
# tree and returns the result instead of mutating the caller's document).
|
|
51
51
|
spec.add_dependency "vectory", "~> 0.13", ">= 0.13.2"
|
|
52
|
-
#
|
|
53
|
-
# when a requirement names one, and the ecosystem target is relaton 3.0+
|
|
52
|
+
# Stable relaton-cli 3.0.0 is out; the ecosystem target is relaton 3.0+
|
|
54
53
|
# (glossarist 2.14+ requires relaton ~> 3.0.0.pre.alpha).
|
|
55
|
-
spec.add_dependency "relaton-cli", ">= 3.0.0
|
|
54
|
+
spec.add_dependency "relaton-cli", ">= 3.0.0", "< 3.1.0"
|
|
56
55
|
spec.add_dependency "relaton-iev", "~> 2.0"
|
|
57
56
|
spec.add_dependency "svg_conform", "~> 0.2"
|
|
58
57
|
|
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.1.pre.alpha.
|
|
4
|
+
version: 3.5.1.pre.alpha.4
|
|
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-10-
|
|
11
|
+
date: 2026-10-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -260,7 +260,7 @@ dependencies:
|
|
|
260
260
|
requirements:
|
|
261
261
|
- - ">="
|
|
262
262
|
- !ruby/object:Gem::Version
|
|
263
|
-
version: 3.0.0
|
|
263
|
+
version: 3.0.0
|
|
264
264
|
- - "<"
|
|
265
265
|
- !ruby/object:Gem::Version
|
|
266
266
|
version: 3.1.0
|
|
@@ -270,7 +270,7 @@ dependencies:
|
|
|
270
270
|
requirements:
|
|
271
271
|
- - ">="
|
|
272
272
|
- !ruby/object:Gem::Version
|
|
273
|
-
version: 3.0.0
|
|
273
|
+
version: 3.0.0
|
|
274
274
|
- - "<"
|
|
275
275
|
- !ruby/object:Gem::Version
|
|
276
276
|
version: 3.1.0
|