metanorma-standoc 2.4.3 → 2.4.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/standoc/blocks.rb +2 -1
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +0 -1
- data/lib/metanorma/standoc/cleanup_maths.rb +1 -1
- data/lib/metanorma/standoc/cleanup_ref.rb +20 -13
- data/lib/metanorma/standoc/cleanup_xref.rb +5 -5
- data/lib/metanorma/standoc/converter.rb +1 -0
- data/lib/metanorma/standoc/isodoc.rng +5 -1
- data/lib/metanorma/standoc/macros.rb +1 -0
- data/lib/metanorma/standoc/merge_bibitems.rb +2 -2
- data/lib/metanorma/standoc/ref.rb +34 -20
- data/lib/metanorma/standoc/ref_utility.rb +51 -3
- data/lib/metanorma/standoc/spans_to_bibitem.rb +3 -1
- data/lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb +3 -2
- data/lib/metanorma/standoc/terms.rb +40 -24
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75e40756e5df255cdb9b0f3bb4d4d2f020ac176558e26bc673bf9b0cf9197d48
|
4
|
+
data.tar.gz: d1c03ebbfa2bffdc9e526370584ee26757c43e0d545c279a15b89000743efc18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70c270785a8fa09a9734bca27b90a119b3bd7c9b78ab48f88aed19e6e5f805086996acc55412741c260b2ae272bac27b3ede2e6158aa215c12b0751bba98462a
|
7
|
+
data.tar.gz: 81881b81ae25e30dd2e4cfc22ff424fe268355697f62feaf18e3e07c2f55769fc64ab9f9a228cd5e815abf3144db6ec5d215702786863cb04d952d6b1f8ed9d4
|
@@ -197,8 +197,9 @@ module Metanorma
|
|
197
197
|
type: node.attr("type"))))
|
198
198
|
end
|
199
199
|
|
200
|
+
# term sources occasionally turning up as "source source"?
|
200
201
|
def paragraph(node)
|
201
|
-
node.role == "source" and return termsource(node)
|
202
|
+
node.role&.sub(/ .*$/, "") == "source" and return termsource(node)
|
202
203
|
noko do |xml|
|
203
204
|
xml.p **para_attrs(node) do |xml_t|
|
204
205
|
xml_t << node.content
|
@@ -238,7 +238,6 @@ module Metanorma
|
|
238
238
|
def bibdata_embed_id_cleanup(xmldoc)
|
239
239
|
@embed_id.nil? and return
|
240
240
|
bibdata = xmldoc.at("//bibdata")
|
241
|
-
#require "debug"; binding.b
|
242
241
|
@embed_id.each do |d|
|
243
242
|
bibdata = bibdata.at("./relation[@type = 'derivedFrom']/bibitem")
|
244
243
|
ident = bibdata.at("./docidentifier[@primary = 'true']") ||
|
@@ -116,9 +116,7 @@ module Metanorma
|
|
116
116
|
|
117
117
|
def biblio_hidden_inherit(xmldoc)
|
118
118
|
xmldoc.xpath("//references[@hidden = 'true']").each do |r|
|
119
|
-
r.xpath("./bibitem").each
|
120
|
-
b["hidden"] = true
|
121
|
-
end
|
119
|
+
r.xpath("./bibitem").each { |b| b["hidden"] = true }
|
122
120
|
end
|
123
121
|
end
|
124
122
|
|
@@ -164,7 +162,7 @@ module Metanorma
|
|
164
162
|
|
165
163
|
def format_ref(ref, type)
|
166
164
|
ret = Nokogiri::XML.fragment(ref)
|
167
|
-
ret.traverse { |x| x.remove if x.name == "fn"}
|
165
|
+
ret.traverse { |x| x.remove if x.name == "fn" }
|
168
166
|
ref = to_xml(ret)
|
169
167
|
return @isodoc.docid_prefix(type, ref) if type != "metanorma"
|
170
168
|
return "[#{ref}]" if /^\d+$/.match(ref) && !/^\[.*\]$/.match(ref)
|
@@ -182,18 +180,27 @@ module Metanorma
|
|
182
180
|
xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
|
183
181
|
docid = select_docid(ref) or next
|
184
182
|
reference = format_ref(docid.children.to_xml, docid["type"])
|
185
|
-
@anchors[ref["id"]] = { xref: reference }
|
183
|
+
@anchors[ref["id"]] = { xref: reference, id: idtype2cit(ref) }
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def idtype2cit(ref)
|
188
|
+
ref.xpath("./docidentifier/@type").each_with_object({}) do |t, m|
|
189
|
+
m[t.text] and next
|
190
|
+
docid = select_docid(ref, t.text) or next
|
191
|
+
m[t.text] = format_ref(docid.children.to_xml, docid["type"])
|
186
192
|
end
|
187
193
|
end
|
188
194
|
|
189
|
-
def select_docid(ref)
|
190
|
-
|
191
|
-
|
192
|
-
ref.at("./docidentifier[@primary = 'true'][
|
193
|
-
ref.at("./docidentifier[@primary = 'true']") ||
|
194
|
-
ref.at("./docidentifier[
|
195
|
-
ref.at("./docidentifier[not(@type = 'DOI')][
|
196
|
-
ref.at("./docidentifier[not(@type = 'DOI')]")
|
195
|
+
def select_docid(ref, type = nil)
|
196
|
+
type and t = "[@type = '#{type}']"
|
197
|
+
ref.at("./docidentifier[@type = 'metanorma']#{t}") ||
|
198
|
+
ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']#{t}") ||
|
199
|
+
ref.at("./docidentifier[@primary = 'true'][not(@language)]#{t}") ||
|
200
|
+
ref.at("./docidentifier[@primary = 'true']#{t}") ||
|
201
|
+
ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']#{t}") ||
|
202
|
+
ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]#{t}") ||
|
203
|
+
ref.at("./docidentifier[not(@type = 'DOI')]#{t}")
|
197
204
|
end
|
198
205
|
|
199
206
|
def fetch_termbase(_termbase, _id)
|
@@ -72,17 +72,17 @@ module Metanorma
|
|
72
72
|
elem.name = name
|
73
73
|
elem["bibitemid"] = elem["target"]
|
74
74
|
if ref = @anchors&.dig(elem["target"], :xref)
|
75
|
+
t = @anchors.dig(elem["target"], :id, elem["style"]) and
|
76
|
+
ref = t
|
75
77
|
elem["citeas"] = @c.decode(ref)
|
76
|
-
else
|
77
|
-
elem["citeas"] = ""
|
78
|
-
xref_to_eref1(elem)
|
78
|
+
else xref_to_eref1(elem)
|
79
79
|
end
|
80
80
|
elem.delete("target")
|
81
|
-
elem.delete("style")
|
82
81
|
extract_localities(elem)
|
83
82
|
end
|
84
83
|
|
85
84
|
def xref_to_eref1(elem)
|
85
|
+
elem["citeas"] = ""
|
86
86
|
@internal_eref_namespaces.include?(elem["type"]) or
|
87
87
|
@log.add("Crossreferences", elem,
|
88
88
|
"#{elem['target']} does not have a corresponding " \
|
@@ -132,7 +132,7 @@ module Metanorma
|
|
132
132
|
|
133
133
|
def xref_compound_cleanup(xmldoc)
|
134
134
|
xmldoc.xpath("//xref").each do |x|
|
135
|
-
|
135
|
+
x["target"].include?(";") or next
|
136
136
|
locations = x["target"].split(";")
|
137
137
|
x["target"] = locations.first.sub(/^[^!]*!/, "")
|
138
138
|
xref_compound_cleanup1(x, locations)
|
@@ -22,6 +22,7 @@ module Metanorma
|
|
22
22
|
Asciidoctor::Extensions.register do
|
23
23
|
preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
|
24
24
|
preprocessor Metanorma::Standoc::Datamodel::DiagramPreprocessor
|
25
|
+
preprocessor Metanorma::Plugin::Glossarist::DatasetPreprocessor
|
25
26
|
preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
|
26
27
|
preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
|
27
28
|
inline_macro Metanorma::Standoc::PreferredTermInlineMacro
|
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v1.2.
|
20
|
+
<!-- VERSION v1.2.2 -->
|
21
21
|
<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">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
@@ -211,6 +211,9 @@
|
|
211
211
|
<data type="boolean"/>
|
212
212
|
</attribute>
|
213
213
|
</optional>
|
214
|
+
<optional>
|
215
|
+
<attribute name="style"/>
|
216
|
+
</optional>
|
214
217
|
<ref name="CitationType"/>
|
215
218
|
<oneOrMore>
|
216
219
|
<ref name="PureTextElement"/>
|
@@ -2136,6 +2139,7 @@
|
|
2136
2139
|
<choice>
|
2137
2140
|
<value>identical</value>
|
2138
2141
|
<value>modified</value>
|
2142
|
+
<value>adapted</value>
|
2139
2143
|
<value>restyled</value>
|
2140
2144
|
<value>context-added</value>
|
2141
2145
|
<value>generalisation</value>
|
@@ -12,6 +12,7 @@ require_relative "./macros_embed"
|
|
12
12
|
require_relative "./datamodel/attributes_table_preprocessor"
|
13
13
|
require_relative "./datamodel/diagram_preprocessor"
|
14
14
|
require "metanorma-plugin-datastruct"
|
15
|
+
require "metanorma-plugin-glossarist"
|
15
16
|
require "metanorma-plugin-lutaml"
|
16
17
|
|
17
18
|
module Metanorma
|
@@ -35,12 +35,12 @@ module Metanorma
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def merge1(old, new)
|
38
|
-
%i(link docid date title series).each do |k|
|
38
|
+
%i(link docid date title series biblionote).each do |k|
|
39
39
|
merge_by_type(old, new, k, :type)
|
40
40
|
end
|
41
41
|
merge_extent(old, new)
|
42
42
|
merge_contributor(old, new)
|
43
|
-
%i(place
|
43
|
+
%i(place version edition).each do |k|
|
44
44
|
merge_simple(old, new, k)
|
45
45
|
end
|
46
46
|
merge_relations(old, new)
|
@@ -14,25 +14,28 @@ module Metanorma
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def isorefrender1(bib, match, year, allp = "")
|
17
|
+
def isorefrender1(bib, match, code, year, allp = "")
|
18
18
|
bib.title(**plaintxt) { |i| i << ref_normalise(match[:text]) }
|
19
19
|
docid(bib, match[:usrlbl]) if match[:usrlbl]
|
20
|
+
docid(bib, code[:usrlabel]) if code && code[:usrlabel]
|
20
21
|
docid(bib, id_and_year(match[:code], year) + allp)
|
21
22
|
docnumber(bib, match[:code])
|
22
23
|
end
|
23
24
|
|
24
|
-
def isorefmatchescode(match)
|
25
|
+
def isorefmatchescode(match, _item)
|
26
|
+
code = analyse_ref_code(match[:code])
|
25
27
|
yr = norm_year(match[:year])
|
26
28
|
{ code: match[:code], year: yr, match: match,
|
27
|
-
title: match[:text], usrlbl: match[:usrlbl],
|
28
|
-
lang: (@lang || :all) }
|
29
|
+
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel],
|
30
|
+
analyse_code: code, lang: (@lang || :all) }
|
29
31
|
end
|
30
32
|
|
31
33
|
def isorefmatchesout(item, xml)
|
32
34
|
if item[:doc] then use_retrieved_relaton(item, xml)
|
33
35
|
else
|
34
36
|
xml.bibitem **attr_code(ref_attributes(item[:ref][:match])) do |t|
|
35
|
-
isorefrender1(t, item[:ref][:match], item[:ref][:
|
37
|
+
isorefrender1(t, item[:ref][:match], item[:ref][:analyse_code],
|
38
|
+
item[:ref][:year])
|
36
39
|
item[:ref][:year] and t.date type: "published" do |d|
|
37
40
|
set_date_range(d, item[:ref][:year])
|
38
41
|
end
|
@@ -41,21 +44,24 @@ module Metanorma
|
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
44
|
-
def isorefmatches2code(match)
|
47
|
+
def isorefmatches2code(match, _item)
|
48
|
+
code = analyse_ref_code(match[:code])
|
45
49
|
{ code: match[:code], no_year: true, lang: (@lang || :all),
|
46
50
|
note: match[:fn], year: nil, match: match,
|
47
|
-
|
51
|
+
analyse_code: code,
|
52
|
+
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel] }
|
48
53
|
end
|
49
54
|
|
50
55
|
def isorefmatches2out(item, xml)
|
51
56
|
if item[:doc] then use_retrieved_relaton(item, xml)
|
52
|
-
else isorefmatches2_1(xml, item[:ref][:match]
|
57
|
+
else isorefmatches2_1(xml, item[:ref][:match],
|
58
|
+
item[:ref][:analyse_code])
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
56
|
-
def isorefmatches2_1(xml, match)
|
62
|
+
def isorefmatches2_1(xml, match, code)
|
57
63
|
xml.bibitem **attr_code(ref_attributes(match)) do |t|
|
58
|
-
isorefrender1(t, match, "--")
|
64
|
+
isorefrender1(t, match, code, "--")
|
59
65
|
t.date type: "published" do |d|
|
60
66
|
d.on "--"
|
61
67
|
end
|
@@ -68,13 +74,14 @@ module Metanorma
|
|
68
74
|
end
|
69
75
|
end
|
70
76
|
|
71
|
-
def isorefmatches3code(match)
|
77
|
+
def isorefmatches3code(match, _item)
|
78
|
+
code = analyse_ref_code(match[:code])
|
72
79
|
yr = norm_year(match[:year])
|
73
80
|
hasyr = !yr.nil? && yr != "--"
|
74
81
|
{ code: match[:code], match: match, yr: yr, hasyr: hasyr,
|
75
82
|
year: hasyr ? yr : nil,
|
76
83
|
all_parts: true, no_year: yr == "--",
|
77
|
-
|
84
|
+
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel],
|
78
85
|
lang: (@lang || :all) }
|
79
86
|
end
|
80
87
|
|
@@ -82,14 +89,15 @@ module Metanorma
|
|
82
89
|
if item[:doc] then use_retrieved_relaton(item, xml)
|
83
90
|
else
|
84
91
|
isorefmatches3_1(xml, item[:ref][:match],
|
92
|
+
item[:ref][:analyse_code],
|
85
93
|
item[:ref][:yr],
|
86
94
|
item[:ref][:hasyr], item[:doc])
|
87
95
|
end
|
88
96
|
end
|
89
97
|
|
90
|
-
def isorefmatches3_1(xml, match, year, _hasyr, _ref)
|
98
|
+
def isorefmatches3_1(xml, match, code, year, _hasyr, _ref)
|
91
99
|
xml.bibitem(**attr_code(ref_attributes(match))) do |t|
|
92
|
-
isorefrender1(t, match, year, " (all parts)")
|
100
|
+
isorefrender1(t, match, code, year, " (all parts)")
|
93
101
|
conditional_date(t, match, year == "--")
|
94
102
|
iso_publisher(t, match[:code])
|
95
103
|
if match.names.include?("fn") && match[:fn]
|
@@ -110,7 +118,9 @@ module Metanorma
|
|
110
118
|
end
|
111
119
|
# code[:id].sub!(/[:-](19|20)[0-9][0-9]$/, "")
|
112
120
|
docid(bib, match[:usrlbl]) if match[:usrlbl]
|
113
|
-
docid(bib,
|
121
|
+
docid(bib, code[:usrlabel]) if code[:usrlabel]
|
122
|
+
code[:id] and
|
123
|
+
docid(bib, /^\d+$/.match?(code[:id]) ? "[#{code[:id]}]" : code[:id])
|
114
124
|
code[:type] == "repo" and
|
115
125
|
bib.docidentifier code[:key], type: "repository"
|
116
126
|
end
|
@@ -125,7 +135,7 @@ module Metanorma
|
|
125
135
|
yr_match = refitem1yr(code[:id])
|
126
136
|
refitem_render1(match, code, t)
|
127
137
|
/^\d+$|^\(.+\)$/.match?(code[:id]) or
|
128
|
-
docnumber(t, code[:id]
|
138
|
+
docnumber(t, code[:id]&.sub(/[:-](19|20)[0-9][0-9]$/, ""))
|
129
139
|
conditional_date(t, yr_match || match, false)
|
130
140
|
end
|
131
141
|
end
|
@@ -146,7 +156,7 @@ module Metanorma
|
|
146
156
|
{ code: code[:id], analyse_code: code, localfile: code[:localfile],
|
147
157
|
year: (m = refitem1yr(code[:id])) ? m[:year] : nil,
|
148
158
|
title: match[:text], match: match, hidden: code[:hidden],
|
149
|
-
usrlbl: match[:usrlbl], lang: (@lang || :all) }
|
159
|
+
usrlbl: match[:usrlbl] || code[:usrlabel], lang: (@lang || :all) }
|
150
160
|
end
|
151
161
|
|
152
162
|
def refitem1yr(code)
|
@@ -201,13 +211,17 @@ module Metanorma
|
|
201
211
|
matched, matched2, matched3 = reference1_matches(item)
|
202
212
|
if matched3.nil? && matched2.nil? && matched.nil?
|
203
213
|
refitemcode(item, node).merge(process: 0)
|
204
|
-
elsif !matched.nil? then isorefmatchescode(matched
|
205
|
-
|
206
|
-
elsif !
|
214
|
+
elsif !matched.nil? then isorefmatchescode(matched,
|
215
|
+
item).merge(process: 1)
|
216
|
+
elsif !matched2.nil? then isorefmatches2code(matched2,
|
217
|
+
item).merge(process: 2)
|
218
|
+
elsif !matched3.nil? then isorefmatches3code(matched3,
|
219
|
+
item).merge(process: 3)
|
207
220
|
end
|
208
221
|
end
|
209
222
|
|
210
223
|
def reference1out(item, xml)
|
224
|
+
item[:ref][:analyse_code] ||= analyse_ref_code(item[:ref][:code])
|
211
225
|
case item[:ref][:process]
|
212
226
|
when 0 then refitemout(item, xml)
|
213
227
|
when 1 then isorefmatchesout(item, xml)
|
@@ -52,6 +52,7 @@ module Metanorma
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def docnumber(bib, code)
|
55
|
+
code or return
|
55
56
|
bib.docnumber do |d|
|
56
57
|
d << @c.decode(code).sub(/^[^\d]*/, "")
|
57
58
|
end
|
@@ -105,12 +106,59 @@ module Metanorma
|
|
105
106
|
ret.merge(numeric: true)
|
106
107
|
end
|
107
108
|
|
108
|
-
# ref id = (usrlbl)code[:-]year
|
109
|
-
# code = \[? number \]? | ident | nofetch(code) | hidden(code) |
|
110
|
-
# dropid(code) | # (repo|path):(key,code) | local-file(source,? key)
|
111
109
|
def analyse_ref_code(code)
|
112
110
|
ret = { id: code }
|
113
111
|
code.nil? || code.empty? and return ret
|
112
|
+
analyse_ref_code_csv(ret) ||
|
113
|
+
analyse_ref_code_nested(ret)
|
114
|
+
end
|
115
|
+
|
116
|
+
def analyse_ref_code_csv(ret)
|
117
|
+
ret[:id].include?("=") or return nil
|
118
|
+
line = CSV.parse_line(ret[:id], liberal_parsing: true) or return nil
|
119
|
+
a = analyse_ref_code_csv_breakup(line)
|
120
|
+
analyse_ref_code_csv_map(a)
|
121
|
+
rescue StandardError
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
|
125
|
+
def analyse_ref_code_csv_breakup(line)
|
126
|
+
line.each_with_object({}) do |x, m|
|
127
|
+
kv = x.split("=", 2)
|
128
|
+
kv.size == 1 and kv = ["code", kv.first]
|
129
|
+
m[kv[0].to_sym] = kv[1].delete_prefix('"').delete_suffix('"')
|
130
|
+
.delete_prefix("'").delete_suffix("'")
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def analyse_ref_code_csv_map(source)
|
135
|
+
source.each_with_object({}) do |(k, v), ret|
|
136
|
+
case k
|
137
|
+
when :dropid, :hidden, :nofetch
|
138
|
+
ret[k] = v == "true"
|
139
|
+
when :repo, :path
|
140
|
+
ret[:type] = k.to_s
|
141
|
+
ret[:key] = v
|
142
|
+
ret[:nofetch] = true
|
143
|
+
source[:code] or
|
144
|
+
ret[:id] = v.sub(%r{^[^/]+/}, "")
|
145
|
+
when :"local-file"
|
146
|
+
ret[:localfile] = v
|
147
|
+
when :number
|
148
|
+
if source[:code] then ret[:usrlabel] = "(#{v})"
|
149
|
+
else ret[:numeric] = true
|
150
|
+
end
|
151
|
+
when :usrlabel
|
152
|
+
ret[:usrlabel] = "(#{v})"
|
153
|
+
when :code then ret[:id] = v
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# ref id = (usrlbl)code[:-]year
|
159
|
+
# code = \[? number \]? | ident | nofetch(code) | hidden(code) |
|
160
|
+
# dropid(code) | # (repo|path):(key,code) | local-file(source,? key)
|
161
|
+
def analyse_ref_code_nested(ret)
|
114
162
|
analyse_ref_numeric(
|
115
163
|
analyse_ref_repo_path(
|
116
164
|
analyse_ref_dropid(
|
@@ -70,7 +70,9 @@ module Metanorma
|
|
70
70
|
ret = ""
|
71
71
|
spans[:edition] and ret += "<edition>#{spans[:edition]}</edition>"
|
72
72
|
spans[:version] and ret += "<version>#{spans[:version]}</version>"
|
73
|
-
spans[:note] and
|
73
|
+
spans[:note] and
|
74
|
+
ret += "<note type='#{spans[:note][:type]}'>#{spans[:note][:val]}" \
|
75
|
+
"</note>".sub(/<note type=''>/, "<note>")
|
74
76
|
ret
|
75
77
|
end
|
76
78
|
|
@@ -45,9 +45,10 @@ module Metanorma
|
|
45
45
|
when "pages", "volume", "issue"
|
46
46
|
ret[:extent][span[:key].to_sym] ||= []
|
47
47
|
ret[:extent][span[:key].to_sym] << span[:val]
|
48
|
-
when "pubplace", "title", "type", "series", "edition", "version"
|
49
|
-
"note"
|
48
|
+
when "pubplace", "title", "type", "series", "edition", "version"
|
50
49
|
ret[span[:key].to_sym] = span[:val]
|
50
|
+
when "note"
|
51
|
+
ret[span[:key].to_sym] = { type: span[:type], val: span[:val] }
|
51
52
|
when "in_title"
|
52
53
|
ret[:in][:title] = span[:val]
|
53
54
|
when "publisher"
|
@@ -6,10 +6,9 @@ module Metanorma
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def nonterm_symbols_parse(attrs, xml, node)
|
9
|
-
|
10
|
-
@definitions = false
|
9
|
+
stash_symbols
|
11
10
|
clause_parse(attrs, xml, node)
|
12
|
-
|
11
|
+
pop_symbols
|
13
12
|
end
|
14
13
|
|
15
14
|
def symbols_attrs(node, attr)
|
@@ -26,28 +25,45 @@ module Metanorma
|
|
26
25
|
node.role == "nonterm" and return nonterm_symbols_parse(attr, xml, node)
|
27
26
|
xml.definitions **attr_code(attr) do |xml_section|
|
28
27
|
xml_section.title { |t| t << node.title }
|
29
|
-
|
30
|
-
termdefs = @term_def
|
28
|
+
stash_symbols
|
31
29
|
@definitions = true
|
32
|
-
|
30
|
+
stash_term_def
|
33
31
|
xml_section << node.content
|
34
|
-
|
35
|
-
|
32
|
+
pop_symbols
|
33
|
+
pop_term_def
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
37
|
def nonterm_term_def_subclause_parse(attrs, xml, node)
|
40
|
-
|
41
|
-
@term_def = false
|
38
|
+
stash_term_def
|
42
39
|
clause_parse(attrs, xml, node)
|
43
|
-
|
40
|
+
pop_term_def
|
44
41
|
end
|
45
42
|
|
46
43
|
def terms_boilerplate_parse(attrs, xml, node)
|
47
|
-
|
48
|
-
@term_def = false
|
44
|
+
stash_term_def
|
49
45
|
clause_parse(attrs.merge(type: "boilerplate"), xml, node)
|
50
|
-
|
46
|
+
pop_term_def
|
47
|
+
end
|
48
|
+
|
49
|
+
def stash_term_def
|
50
|
+
@stashed_term_def ||= []
|
51
|
+
@stashed_term_def.push(@term_def)
|
52
|
+
@term_def = false
|
53
|
+
end
|
54
|
+
|
55
|
+
def pop_term_def
|
56
|
+
@term_def = @stashed_term_def.pop
|
57
|
+
end
|
58
|
+
|
59
|
+
def stash_symbols
|
60
|
+
@stashed_definitions ||= []
|
61
|
+
@stashed_definitions.push(@definitions)
|
62
|
+
@definitions = false
|
63
|
+
end
|
64
|
+
|
65
|
+
def pop_symbols
|
66
|
+
@definitions = @stashed_definitions.pop
|
51
67
|
end
|
52
68
|
|
53
69
|
# subclause contains subclauses
|
@@ -106,14 +122,14 @@ module Metanorma
|
|
106
122
|
end
|
107
123
|
|
108
124
|
def add_term_source(node, xml_t, seen_xref, match)
|
109
|
-
|
110
|
-
|
111
|
-
|
125
|
+
attrs = {}
|
126
|
+
body = seen_xref.children[0]
|
127
|
+
unless body.name == "concept"
|
112
128
|
attrs = termsource_origin_attrs(node, seen_xref)
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
129
|
+
body = body.children
|
130
|
+
end
|
131
|
+
xml_t.origin **attr_code(attrs) do |o|
|
132
|
+
o << body.to_xml
|
117
133
|
end
|
118
134
|
add_term_source_mod(xml_t, match)
|
119
135
|
end
|
@@ -136,15 +152,15 @@ module Metanorma
|
|
136
152
|
def extract_termsource_refs(text, node)
|
137
153
|
matched = TERM_REFERENCE_RE.match text
|
138
154
|
matched.nil? and @log.add("AsciiDoc Input", node,
|
139
|
-
"term reference not in expected format:"\
|
155
|
+
"term reference not in expected format:" \
|
140
156
|
"#{text}")
|
141
157
|
matched
|
142
158
|
end
|
143
159
|
|
144
160
|
def termsource_attrs(node, matched)
|
145
|
-
status = node.attr("status") ||
|
161
|
+
status = node.attr("status")&.downcase ||
|
146
162
|
(matched[:text] ? "modified" : "identical")
|
147
|
-
{ status: status, type: node.attr("type") || "authoritative" }
|
163
|
+
{ status: status, type: node.attr("type")&.downcase || "authoritative" }
|
148
164
|
end
|
149
165
|
|
150
166
|
def termsource(node)
|
data/metanorma-standoc.gemspec
CHANGED
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_dependency "isodoc", "~> 2.5.4"
|
34
34
|
spec.add_dependency "metanorma", ">= 1.5.0"
|
35
35
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
36
|
+
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
|
36
37
|
spec.add_dependency "metanorma-plugin-lutaml"
|
37
38
|
spec.add_dependency "ruby-jing"
|
38
39
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
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: 2.4.
|
4
|
+
version: 2.4.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: 2023-
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.2.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: metanorma-plugin-glossarist
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.1
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.1
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: metanorma-plugin-lutaml
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|