metanorma-standoc 2.4.3 → 2.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0ade5d859084779fe2f7357438926e03e0359adbf528d4db67a1851200f7e45
4
- data.tar.gz: d17ee40a8d465764b0d7577a0ab69db5d96ab1c4e5c923b77059326d2e52e45c
3
+ metadata.gz: 8989224ddc5bb169f13c102066f005b7c72e0d6ff0cd7a2c2122ef57ed7f6923
4
+ data.tar.gz: ff257fb02f7feb16d680f111ae39c8806abaff034e087659586bbd43bc34a6e5
5
5
  SHA512:
6
- metadata.gz: 794db303464ba57e25b5ccb240b794524842fe99a42cf136f7f0ff3d0e77f82eb017676b3a0b9ef491b655ffe42b50d9332d880c4a10c9ca7a705252e62c5199
7
- data.tar.gz: 6f9f27b816283a7cf27fc3b441cfd9d04a72c7a26da7d66264f3984e391e4ab3f3be384e167e1a813d8bfabcc070d98f162908a5f1a9dd5670dca3614e002873
6
+ metadata.gz: 837c2c91f59f93374b747c23b71f5740b1e64d0e29e06d8e7e4076bb7c0ce24700b29b17434ece743d1e1fbcd7b6fa5b245526207525f2b6cbfb6c5a2be6dd29
7
+ data.tar.gz: ab6f75ce5add0b40f99d47a47b123ccfc090291b5e6adb4f1c41687e541f53f111dff9fecb6c6ecb46ff5aeaee8ad0af97bd444da8f9b00525b210fa8c1d7430
@@ -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']") ||
@@ -113,7 +113,7 @@ module Metanorma
113
113
  def gather_unitsml(unitsml, xmldoc, tag)
114
114
  tags = xmldoc.xpath(".//m:#{tag}", "m" => UNITSML_NS)
115
115
  .each_with_object({}) do |x, m|
116
- m[x["id"]] = x.remove
116
+ m[x["xml:id"]] = x.remove
117
117
  end
118
118
  return if tags.empty?
119
119
 
@@ -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 do |b|
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
- ref.at("./docidentifier[@type = 'metanorma']") ||
191
- ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']") ||
192
- ref.at("./docidentifier[@primary = 'true'][not(@language)]") ||
193
- ref.at("./docidentifier[@primary = 'true']") ||
194
- ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']") ||
195
- ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]") ||
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
- /;/.match?(x["target"]) or next
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,9 +22,11 @@ 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
29
+ inline_macro Metanorma::Standoc::DateInlineMacro
28
30
  inline_macro Metanorma::Standoc::SpanInlineMacro
29
31
  inline_macro Metanorma::Standoc::AltTermInlineMacro
30
32
  inline_macro Metanorma::Standoc::AdmittedTermInlineMacro
@@ -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.1 -->
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"/>
@@ -1009,6 +1012,7 @@
1009
1012
  <ref name="del"/>
1010
1013
  <ref name="span"/>
1011
1014
  <ref name="erefstack"/>
1015
+ <ref name="date_inline"/>
1012
1016
  </choice>
1013
1017
  </define>
1014
1018
  <define name="add">
@@ -1050,6 +1054,23 @@
1050
1054
  </oneOrMore>
1051
1055
  </element>
1052
1056
  </define>
1057
+ <define name="date_inline">
1058
+ <element name="date">
1059
+ <attribute name="value"/>
1060
+ <optional>
1061
+ <attribute name="format"/>
1062
+ </optional>
1063
+ <optional>
1064
+ <attribute name="language"/>
1065
+ </optional>
1066
+ <optional>
1067
+ <attribute name="script"/>
1068
+ </optional>
1069
+ <optional>
1070
+ <attribute name="locale"/>
1071
+ </optional>
1072
+ </element>
1073
+ </define>
1053
1074
  <define name="concept">
1054
1075
  <element name="concept">
1055
1076
  <optional>
@@ -2136,6 +2157,7 @@
2136
2157
  <choice>
2137
2158
  <value>identical</value>
2138
2159
  <value>modified</value>
2160
+ <value>adapted</value>
2139
2161
  <value>restyled</value>
2140
2162
  <value>context-added</value>
2141
2163
  <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
@@ -27,7 +27,7 @@ module Metanorma
27
27
 
28
28
  def process(_parent, target, attr)
29
29
  args = preprocess_attrs(attr) or return
30
- ret = "<index-xref also='#{target == 'also'}'>"\
30
+ ret = "<index-xref also='#{target == 'also'}'>" \
31
31
  "<primary>#{args[:primary]}</primary>"
32
32
  ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
33
33
  ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
@@ -69,7 +69,7 @@ module Metanorma
69
69
  rpend = attributes["rpend"]
70
70
  end
71
71
 
72
- "<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>"\
72
+ "<ruby>#{target}<rp>#{rpbegin}</rp><rt>#{rt}</rt>" \
73
73
  "<rp>#{rpend}</rp></ruby>"
74
74
  end
75
75
  end
@@ -101,6 +101,18 @@ module Metanorma
101
101
  end
102
102
  end
103
103
 
104
+ class DateInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
105
+ use_dsl
106
+ named :date
107
+ using_format :short
108
+
109
+ def process(_parent, _target, attrs)
110
+ format = "%F"
111
+ attrs.size >= 2 and format = attrs[2]
112
+ %{<date format='#{format}' value='#{attrs[1]}'/>}
113
+ end
114
+ end
115
+
104
116
  class AddMacro < Asciidoctor::Extensions::InlineMacroProcessor
105
117
  use_dsl
106
118
  named :add
@@ -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 biblionote version edition).each do |k|
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][:year])
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
- title: match[:text], usrlbl: match[:usrlbl] }
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
- text: match[:text], usrlbl: match[:usrlbl],
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, /^\d+$/.match?(code[:id]) ? "[#{code[:id]}]" : code[:id])
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].sub(/[:-](19|20)[0-9][0-9]$/, ""))
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).merge(process: 1)
205
- elsif !matched2.nil? then isorefmatches2code(matched2).merge(process: 2)
206
- elsif !matched3.nil? then isorefmatches3code(matched3).merge(process: 3)
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 ret += "<note>#{spans[:note]}</note>"
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
- defs = @definitions
10
- @definitions = false
9
+ stash_symbols
11
10
  clause_parse(attrs, xml, node)
12
- @definitions = defs
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
- defs = @definitions
30
- termdefs = @term_def
28
+ stash_symbols
31
29
  @definitions = true
32
- @term_def = false
30
+ stash_term_def
33
31
  xml_section << node.content
34
- @definitions = defs
35
- @term_def = termdefs
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
- defs = @term_def
41
- @term_def = false
38
+ stash_term_def
42
39
  clause_parse(attrs, xml, node)
43
- @term_def = defs
40
+ pop_term_def
44
41
  end
45
42
 
46
43
  def terms_boilerplate_parse(attrs, xml, node)
47
- defs = @term_def
48
- @term_def = false
44
+ stash_term_def
49
45
  clause_parse(attrs.merge(type: "boilerplate"), xml, node)
50
- @term_def = defs
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
- if seen_xref.children[0].name == "concept"
110
- xml_t.origin { |o| o << seen_xref.children[0].to_xml }
111
- else
125
+ attrs = {}
126
+ body = seen_xref.children[0]
127
+ unless body.name == "concept"
112
128
  attrs = termsource_origin_attrs(node, seen_xref)
113
- attrs.delete(:text)
114
- xml_t.origin **attr_code(attrs) do |o|
115
- o << seen_xref.children[0].children.to_xml
116
- end
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)
@@ -122,7 +122,7 @@ module Metanorma
122
122
  err2 = "There is a crossreference to an instance of #{inner.name} " \
123
123
  "nested within #{outer.name}: #{i.to_xml}"
124
124
  @log.add("Style", i, err2)
125
- @fatalerror << err2
125
+ # @fatalerror << err2
126
126
  end
127
127
 
128
128
  def concept_validate(doc, tag, refterm)
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.4.3".freeze
22
+ VERSION = "2.4.5".freeze
23
23
  end
24
24
  end
@@ -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.3
4
+ version: 2.4.5
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-04-25 00:00:00.000000000 Z
11
+ date: 2023-06-05 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