metanorma-standoc 3.5.1.pre.alpha.3 → 3.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/Gemfile +2 -2
- data/lib/metanorma/cleanup/term_lookup.rb +70 -2
- data/lib/metanorma/standoc/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: a2fc39afd675df76a394516bfc05cb59224218ac48612019830cd82f69746052
|
|
4
|
+
data.tar.gz: 64e3c4be18db8e985bc51a2aa9981316f0f96e30b7d930a57cd7e06a5af3fd28
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2dfb7d49e7edb4f873fba01fdd89c8b647bf24f40025227884b5175a630d74104c2661349db82d6bd7414d136a8f555115b7bfd0113c28c2648b7c07e2de17e
|
|
7
|
+
data.tar.gz: e950814917e050286b3bdc0e06bef1c96b7e40ee7145afa6ff843bedf0cfeca90c4e5de3333167e9412c50783dc1046ff1d83d43cba7dcfe1d2d374f19736c68
|
data/Gemfile
CHANGED
|
@@ -28,8 +28,8 @@ gem "isodoc", github: "metanorma/isodoc", branch: "main"
|
|
|
28
28
|
# release. Prefer the released gem over a git pin: relaton main has since
|
|
29
29
|
# moved to lutaml-store ~> 0.3, which conflicts with glossarist 2.14's
|
|
30
30
|
# lutaml-store ~> 0.2.0 and makes this bundle unresolvable.
|
|
31
|
-
gem "relaton", "~> 3.0
|
|
32
|
-
gem "pubid", "~> 2.0
|
|
31
|
+
gem "relaton", "~> 3.0"
|
|
32
|
+
gem "pubid", "~> 2.0"
|
|
33
33
|
|
|
34
34
|
gem "metanorma-plugin-lutaml", github: "metanorma/metanorma-plugin-lutaml", branch: "main"
|
|
35
35
|
|
|
@@ -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
|
|
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
|
|
4
|
+
version: 3.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: 2026-10-
|
|
11
|
+
date: 2026-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|