metanorma-standoc 2.5.2 → 2.5.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20b6d6b6948c9eae42b87ef8c6c8a96fcbabdd64f44d3effd972285e5f30ec62
4
- data.tar.gz: c048925049205b4fbbb2ce7883bc786b7ffd97970bae250226844fbf9801000f
3
+ metadata.gz: 5e909b2a76be142e305b420f79f8d6da87ab4b6106b391c666bb9f61c3b65a3e
4
+ data.tar.gz: 300b7c8578c9da40fa9241b714041c0cf320b7351a73f536b4df26bd3861f9f3
5
5
  SHA512:
6
- metadata.gz: 437c944d237d240b0efc821cc7b84e99dc919557f8474c07922c1dd688dbdb7838e13d523fcfe44b308bdf322c1b4a5405a7c95553ef633e12b7e99b28906714
7
- data.tar.gz: f233558ba151d531f9c67c07e75e6b2c22aabc38054db61d594abb17b6445c4e31a52931129686156b53e11bec282ec256d964b1bd9b339eca64449a8109a75d
6
+ metadata.gz: 9a93b92c8da197cb4adccb1111b6da0d45199f707c62574a9000f7bbc0b7a01c81105fa5db81e85c3db91b26899efd60a59aa8e31e0d7b6357726a2b11eabf1d
7
+ data.tar.gz: 37d9cd30e6ecf8bc5e6e98bf27c23843554a538e9691511e2020979d9652ed2e1a242d754a2cafadac45c737ac9cda3fa94fabae805c827dd026ea0490a969b0
@@ -3,14 +3,14 @@ module Metanorma
3
3
  module Cleanup
4
4
  def external_terms_boilerplate(sources)
5
5
  @i18n.l10n(
6
- @i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
6
+ @i18n.external_terms_boilerplate.gsub("%", sources || "???"),
7
7
  @lang, @script, @locale
8
8
  )
9
9
  end
10
10
 
11
11
  def internal_external_terms_boilerplate(sources)
12
12
  @i18n.l10n(
13
- @i18n.internal_external_terms_boilerplate.gsub(/%/, sources || "??"),
13
+ @i18n.internal_external_terms_boilerplate.gsub("%", sources || "??"),
14
14
  @lang, @script
15
15
  )
16
16
  end
@@ -107,8 +107,8 @@ module Metanorma
107
107
 
108
108
  def initial_boilerplate(xml, isodoc)
109
109
  xml.at("//boilerplate") and return
110
- preface = xml.at("//preface") || xml.at("//sections") ||
111
- xml.at("//annex") || xml.at("//references") or return
110
+ preface = xml.at("//preface | //sections | //annex | //references") or
111
+ return
112
112
  b = boilerplate(xml, isodoc) or return
113
113
  preface.previous = b
114
114
  end
@@ -151,7 +151,7 @@ module Metanorma
151
151
  ret
152
152
  end
153
153
 
154
- # remove Metanorma namespace, so generated doc containing boilerplate
154
+ # remove Metanorma namespace, so generated doc containing boilerplate
155
155
  # can be queried consistently
156
156
  # _\d+ anchor is assigned to titleless clauses, will clash with main doc
157
157
  # instances of same
@@ -106,7 +106,7 @@ module Metanorma
106
106
 
107
107
  def add_misc_container(xmldoc)
108
108
  unless ins = xmldoc.at("//metanorma-extension")
109
- a = xmldoc.at("//termdocsource") || xmldoc.at("//bibdata")
109
+ a = xmldoc.xpath("//termdocsource")&.last || xmldoc.at("//bibdata")
110
110
  a.next = "<metanorma-extension/>"
111
111
  ins = xmldoc.at("//metanorma-extension")
112
112
  end
@@ -170,17 +170,14 @@ module Metanorma
170
170
  ref
171
171
  end
172
172
 
173
- ISO_PUBLISHER_XPATH =
174
- "./contributor[role/@type = 'publisher']/" \
175
- "organization[abbreviation = 'ISO' or abbreviation = 'IEC' or " \
176
- "name = 'International Organization for Standardization' or " \
177
- "name = 'International Electrotechnical Commission']".freeze
178
-
179
173
  def reference_names(xmldoc)
180
174
  xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
181
- docid = select_docid(ref) or next
182
- reference = format_ref(docid.children.to_xml, docid["type"])
183
- @anchors[ref["id"]] = { xref: reference, id: idtype2cit(ref) }
175
+ @anchors[ref["id"]] = if docid = select_docid(ref)
176
+ reference = format_ref(docid.children.to_xml,
177
+ docid["type"])
178
+ { xref: reference, id: idtype2cit(ref) }
179
+ else { xref: ref["id"], id: ref["id"] }
180
+ end
184
181
  end
185
182
  end
186
183
 
@@ -54,13 +54,12 @@ module Metanorma
54
54
  end
55
55
 
56
56
  def inline_anchor_xref_attrs1(match, target, text)
57
- { target: target,
57
+ { target: target, hidden: match[:hidden],
58
58
  type: match[:fn].nil? ? "inline" : "footnote",
59
59
  case: match[:case]&.sub(/%$/, ""),
60
60
  style: match[:style]&.sub(/^style=/, "")&.sub(/%$/, "") || @xrefstyle,
61
61
  droploc: match[:drop].nil? && match[:drop2].nil? ? nil : true,
62
- text: inline_anchor_xref_text(match, text),
63
- hidden: match[:hidden] }
62
+ text: inline_anchor_xref_text(match, text) }
64
63
  end
65
64
 
66
65
  def inline_anchor_xref_match(text)
@@ -71,9 +70,7 @@ module Metanorma
71
70
  end
72
71
 
73
72
  def inline_anchor_xref_text(match, text)
74
- if %i[case fn drop drop2 hidden style].any? do |x|
75
- !match[x].nil?
76
- end
73
+ if %i[case fn drop drop2 hidden style].any? { |x| !match[x].nil? }
77
74
  match[:text]
78
75
  else text
79
76
  end
@@ -199,12 +196,8 @@ module Metanorma
199
196
  term_designation(xml, node, "admitted", node.text)
200
197
  when "deprecated"
201
198
  term_designation(xml, node, "deprecates", node.text)
202
- when "domain" then xml.domain { |a| a << node.text }
203
-
204
- when "strike" then xml.strike { |s| s << node.text }
205
- when "underline" then xml.underline { |s| s << node.text }
206
- when "smallcap" then xml.smallcap { |s| s << node.text }
207
- when "keyword" then xml.keyword { |s| s << node.text }
199
+ when "domain", "strike", "underline", "smallcap", "keyword"
200
+ xml.send(node.role) { |s| s << node.text }
208
201
  when /^css /
209
202
  xml.span style: node.role.sub(/^css /, "") do |s|
210
203
  s << node.text
@@ -234,9 +227,8 @@ module Metanorma
234
227
  end
235
228
 
236
229
  def image_attributes1(node, uri, type)
237
- attr_code(src: uri,
230
+ attr_code(src: uri, mimetype: type,
238
231
  id: Metanorma::Utils::anchor_or_uuid,
239
- mimetype: type,
240
232
  height: node.attr("height") || "auto",
241
233
  width: node.attr("width") || "auto",
242
234
  filename: node.attr("filename"),
@@ -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.3 -->
20
+ <!-- VERSION v1.2.4 -->
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">
@@ -2068,6 +2068,9 @@
2068
2068
  </define>
2069
2069
  <define name="termdefinition">
2070
2070
  <element name="definition">
2071
+ <optional>
2072
+ <attribute name="type"/>
2073
+ </optional>
2071
2074
  <choice>
2072
2075
  <ref name="verbaldefinition"/>
2073
2076
  <ref name="nonverbalrep"/>
@@ -1,3 +1,5 @@
1
+ require "pathname"
2
+
1
3
  module Metanorma
2
4
  module Standoc
3
5
  class EmbedIncludeProcessor < Asciidoctor::Extensions::Preprocessor
@@ -13,19 +15,58 @@ module Metanorma
13
15
 
14
16
  def embed_acc(doc, reader)
15
17
  { lines: [], hdr: [], id: [],
16
- doc: doc, reader: reader, prev: nil }
18
+ orig: doc, doc: doc, file: nil, path: nil,
19
+ reader: reader, prev: nil }
17
20
  end
18
21
 
19
22
  # presupposes single embed
20
- def return_to_document(doc, ret)
21
- doc.attributes["embed_hdr"] = ret[:hdr]
22
- doc.attributes["embed_id"] = ret[:id]
23
- ::Asciidoctor::Reader.new ret[:lines].flatten
23
+ def return_to_document(doc, embed)
24
+ doc.attributes["embed_hdr"] = embed[:hdr]
25
+ doc.attributes["embed_id"] = embed[:id]
26
+ read_flattened_embeds(flatten_embeds(embed), doc)
27
+ end
28
+
29
+ # lines can contain recursive embed structs, containing the lines to read
30
+ # and the file they are in; read these into the (new) reader.
31
+ # This is intended to resolve any file crossreferences, with
32
+ # file paths resolved relative to current file directory
33
+ # -- but it won't: https://github.com/metanorma/metanorma-standoc/issues/802
34
+ def read_flattened_embeds(ret, doc)
35
+ reader = ::Asciidoctor::PreprocessorReader.new doc
36
+ b = Pathname.new doc.base_dir
37
+ ret.reverse.each do |l|
38
+ if l[:file]
39
+ new = Pathname.new(l[:path]).relative_path_from(b).to_s
40
+ reader.push_include l[:lines], new, l[:path]
41
+ else reader.unshift_lines l[:lines]
42
+ end
43
+ end
44
+ reader
45
+ end
46
+
47
+ # lines can contain recursive embed structs, which are resolved into a
48
+ # flat listing of included line chunks (top level doc has { file: nil } )
49
+ def flatten_embeds(emb)
50
+ acc = []
51
+ ret = emb[:lines].each_with_object([]) do |l, m|
52
+ if l.is_a?(Hash)
53
+ acc, m = update_embeds(acc, m, emb)
54
+ flatten_embeds(l).each { |x| m << x }
55
+ else acc << l end
56
+ end
57
+ acc, ret = update_embeds(acc, ret, emb)
58
+ ret
59
+ end
60
+
61
+ def update_embeds(lines, acc, emb)
62
+ lines.empty? or
63
+ acc << { file: emb[:file], path: emb[:path], lines: lines }
64
+ [[], acc]
24
65
  end
25
66
 
26
67
  def process_line(line, acc, headings)
27
68
  if /^embed::/.match?(line)
28
- e = embed(line, acc[:doc], acc[:reader], headings)
69
+ e = embed(line, acc, headings)
29
70
  acc = process_embed(acc, e, acc[:prev])
30
71
  else
31
72
  acc[:lines] << line
@@ -35,22 +76,31 @@ module Metanorma
35
76
  end
36
77
 
37
78
  def process_embed(acc, embed, prev)
79
+ acc, embed = process_embed_anchor(acc, embed, prev)
80
+ acc[:lines] << embed
81
+ acc[:hdr] << embed[:hdr]
82
+ acc[:id] += embed[:id]
83
+ acc
84
+ end
85
+
86
+ def process_embed_anchor(acc, embed, prev)
38
87
  if /^\[\[.+\]\]/.match?(prev) # anchor
39
88
  acc[:id] << prev.sub(/^\[\[/, "").sub(/\]\]$/, "")
40
89
  i = embed[:lines].index { |x| /^== /.match?(x) } and
41
90
  embed[:lines][i] += " #{prev}" # => bookmark
42
91
  end
43
- acc[:lines] << embed[:lines]
44
- acc[:hdr] << embed[:hdr]
45
- acc[:id] += embed[:id]
46
- acc
92
+ [acc, embed]
47
93
  end
48
94
 
49
- def filename(line, doc, reader)
95
+ def filename(line, acc)
50
96
  m = /^embed::([^\[]+)\[/.match(line)
51
- f = doc.normalize_system_path m[1], reader.dir, nil,
52
- target_name: "include file"
53
- File.exist?(f) ? f : nil
97
+ f = acc[:doc].normalize_system_path m[1], acc[:reader].dir, nil,
98
+ target_name: "include file"
99
+ unless File.exist?(f)
100
+ err = "Missing embed file: #{line}"
101
+ raise err
102
+ end
103
+ [m[1], f]
54
104
  end
55
105
 
56
106
  def readlines_safe(file)
@@ -65,21 +115,27 @@ module Metanorma
65
115
  end
66
116
  end
67
117
 
68
- def embed(line, doc, reader, headings)
69
- inc_path = filename(line, doc, reader) or return line
118
+ def embed(line, acc, headings)
119
+ fname, inc_path = filename(line, acc)
70
120
  lines = filter_sections(read(inc_path), headings)
71
- doc = Asciidoctor::Document.new [], { safe: :safe }
72
- reader = ::Asciidoctor::PreprocessorReader.new doc, lines
73
- ret = embed_acc(doc, reader).merge(strip_header(reader.read_lines))
74
- embed_recurse(ret, doc, reader, headings)
121
+ n = Asciidoctor::Document
122
+ .new [], { safe: :safe, base_dir: File.dirname(inc_path) }
123
+ r = ::Asciidoctor::PreprocessorReader.new n, lines
124
+ ret = embed_acc(n, r).merge(strip_header(r.read_lines))
125
+ .merge(file: fname, path: inc_path, orig: acc[:orig])
126
+ ret[:hdr] or
127
+ raise "Embedding an incomplete document with no header: #{ret[:path]}"
128
+ embed_recurse(ret, n, r, headings)
75
129
  end
76
130
 
77
131
  def embed_recurse(ret, doc, reader, headings)
78
132
  ret1 = ret[:lines].each_with_object(embed_acc(doc, reader)) do |line, m|
79
133
  process_line(line, m, headings)
80
134
  end
81
- { lines: ret1[:lines], id: ret[:id] + ret1[:id],
82
- hdr: { text: ret[:hdr].join("\n"), child: ret1[:hdr] } }
135
+ ret.merge(
136
+ { lines: ret1[:lines], id: ret[:id] + ret1[:id],
137
+ hdr: { text: ret[:hdr].join("\n"), child: ret1[:hdr] } },
138
+ )
83
139
  end
84
140
 
85
141
  def strip_header(lines)
@@ -47,8 +47,7 @@ module Metanorma
47
47
  def isorefmatches2code(match, _item)
48
48
  code = analyse_ref_code(match[:code])
49
49
  { code: match[:code], no_year: true, lang: (@lang || :all),
50
- note: match[:fn], year: nil, match: match,
51
- analyse_code: code,
50
+ note: match[:fn], year: nil, match: match, analyse_code: code,
52
51
  title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel] }
53
52
  end
54
53
 
@@ -79,19 +78,17 @@ module Metanorma
79
78
  yr = norm_year(match[:year])
80
79
  hasyr = !yr.nil? && yr != "--"
81
80
  { code: match[:code], match: match, yr: yr, hasyr: hasyr,
82
- year: hasyr ? yr : nil,
81
+ year: hasyr ? yr : nil, lang: (@lang || :all),
83
82
  all_parts: true, no_year: yr == "--",
84
- title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel],
85
- lang: (@lang || :all) }
83
+ title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel] }
86
84
  end
87
85
 
88
86
  def isorefmatches3out(item, xml)
89
87
  if item[:doc] then use_retrieved_relaton(item, xml)
90
- else
91
- isorefmatches3_1(xml, item[:ref][:match],
92
- item[:ref][:analyse_code],
93
- item[:ref][:yr],
94
- item[:ref][:hasyr], item[:doc])
88
+ else isorefmatches3_1(
89
+ xml, item[:ref][:match], item[:ref][:analyse_code],
90
+ item[:ref][:yr], item[:ref][:hasyr], item[:doc]
91
+ )
95
92
  end
96
93
  end
97
94
 
@@ -126,9 +123,9 @@ module Metanorma
126
123
  end
127
124
 
128
125
  def refitem_render(xml, match, code)
129
- xml.bibitem **attr_code(id: match[:anchor],
130
- suppress_identifier: code[:dropid],
131
- hidden: code[:hidden]) do |t|
126
+ xml.bibitem **attr_code(
127
+ id: match[:anchor], suppress_identifier: code[:dropid], hidden: code[:hidden],
128
+ ) do |t|
132
129
  t.formattedref format: "application/x-isodoc+xml" do |i|
133
130
  i << ref_normalise_no_format(match[:text])
134
131
  end
@@ -240,7 +237,7 @@ module Metanorma
240
237
  def reference_normalise(refs)
241
238
  refs.each do |r|
242
239
  r[:code] = @c.decode(r[:code])
243
- .gsub(/\u2009\u2014\u2009/, " -- ").strip
240
+ .gsub("\u2009\u2014\u2009", " -- ").strip
244
241
  end
245
242
  end
246
243
 
@@ -53,7 +53,7 @@ module Metanorma
53
53
  end
54
54
 
55
55
  PREFACE_CLAUSE_NAMES =
56
- %w(abstract foreword introduction metanorma-extension
56
+ %w(abstract foreword introduction metanorma-extension termdocsource
57
57
  misc-container acknowledgements).freeze
58
58
 
59
59
  MAIN_CLAUSE_NAMES =
@@ -8,12 +8,12 @@ module Metanorma
8
8
  EXISTING_TERM_REGEXP = /\Aterm-/.freeze
9
9
  EXISTING_SYMBOL_REGEXP = /\Asymbol-/.freeze
10
10
 
11
- attr_reader :xmldoc, :termlookup, :log
11
+ attr_reader :xmldoc, :lookup, :log
12
12
 
13
13
  def initialize(xmldoc, log)
14
14
  @xmldoc = xmldoc
15
15
  @log = log
16
- @termlookup = { term: {}, symbol: {}, secondary2primary: {} }
16
+ @lookup = { term: {}, symbol: {}, sec2prim: {} }
17
17
  @idhash = {}
18
18
  @unique_designs = {}
19
19
  @c = HTMLEntities.new
@@ -25,7 +25,7 @@ module Metanorma
25
25
  def call
26
26
  @idhash = populate_idhash
27
27
  @unique_designs = unique_designators
28
- @termlookup = replace_automatic_generated_ids_terms
28
+ @lookup = replace_automatic_generated_ids_terms
29
29
  set_termxref_tags_target
30
30
  concept_cleanup
31
31
  related_cleanup
@@ -49,9 +49,8 @@ module Metanorma
49
49
  def concept_cleanup
50
50
  xmldoc.xpath("//concept").each do |n|
51
51
  refterm = n.at("./refterm") or next
52
- lookup = normalize_ref_id_text(refterm.text.strip)
53
- p = @termlookup[:secondary2primary][lookup] and
54
- refterm.children = @c.encode(p)
52
+ lookup = norm_ref_id_text(refterm.text.strip)
53
+ p = @lookup[:sec2prim][lookup] and refterm.children = @c.encode(p)
55
54
  end
56
55
  end
57
56
 
@@ -62,10 +61,9 @@ module Metanorma
62
61
  def related_cleanup
63
62
  xmldoc.xpath("//related").each do |n|
64
63
  refterm = n.at("./refterm") or next
65
- lookup = normalize_ref_id_text(refterm.text.strip)
66
- p = @termlookup[:secondary2primary][lookup] and
67
- refterm.children = @c.encode(p)
68
- p || @termlookup[:term][lookup] and
64
+ lookup = norm_ref_id_text(refterm.text.strip)
65
+ p = @lookup[:sec2prim][lookup] and refterm.children = @c.encode(p)
66
+ p || @lookup[:term][lookup] and
69
67
  refterm.replace("<preferred><expression>" \
70
68
  "<name>#{refterm.children.to_xml}" \
71
69
  "</name></expression></preferred>")
@@ -81,7 +79,7 @@ module Metanorma
81
79
 
82
80
  def set_termxref_tags_target
83
81
  xmldoc.xpath("//termxref").each do |node|
84
- target = normalize_ref_id1(node)
82
+ target = norm_ref_id1(node)
85
83
  x = node.at("../xrefrender") and modify_ref_node(x, target)
86
84
  node.name = "refterm"
87
85
  end
@@ -103,8 +101,8 @@ module Metanorma
103
101
  end
104
102
 
105
103
  def lookup_refterm(node)
106
- target = normalize_ref_id1(node)
107
- if termlookup[:term][target].nil? && termlookup[:symbol][target].nil?
104
+ target = norm_ref_id1(node)
105
+ if @lookup[:term][target].nil? && @lookup[:symbol][target].nil?
108
106
  remove_missing_ref(node, target)
109
107
  else
110
108
  x = node.at("../xrefrender") and x.name = "xref"
@@ -154,8 +152,9 @@ module Metanorma
154
152
 
155
153
  def modify_ref_node(node, target)
156
154
  node.name = "xref"
157
- s = termlookup[:symbol][target]
158
- t = termlookup[:term][target]
155
+ s = @lookup[:symbol][target]
156
+ t1 = @lookup[:sec2prim][target] and target = norm_ref_id1(t1)
157
+ t = @lookup[:term][target]
159
158
  type = node.parent["type"]
160
159
  if type == "term" || ((!type || node.parent.name == "related") && t)
161
160
  node["target"] = t
@@ -173,7 +172,7 @@ module Metanorma
173
172
  s = xmldoc.xpath("//definitions//dt").each.with_object({}) do |n, res|
174
173
  norm_id_memorize(n, res, ".", "symbol", false)
175
174
  end
176
- { term: r, symbol: s, secondary2primary: pref_secondary2primary }
175
+ { term: r, symbol: s, sec2prim: pref_secondary2primary }
177
176
  end
178
177
 
179
178
  def pref_secondary2primary
@@ -188,18 +187,18 @@ module Metanorma
188
187
  term.xpath("./preferred//name").each_with_index do |p, i|
189
188
  t = p.text.strip
190
189
  i.positive? and
191
- res[normalize_ref_id_text(domain_prefix(term, t))] = primary
190
+ res[norm_ref_id_text(domain_prefix(term, t))] = primary
192
191
  @unique_designs[t] && term.at(".//domain") and
193
- res[normalize_ref_id_text(t)] = primary
192
+ res[norm_ref_id_text(t)] = primary
194
193
  end
195
194
  end
196
195
 
197
196
  def pref_secondary2primary_admitted(term, res, primary)
198
197
  term.xpath("./admitted//name").each do |p|
199
198
  t = p.text.strip
200
- res[normalize_ref_id_text(domain_prefix(term, t))] = primary
199
+ res[norm_ref_id_text(domain_prefix(term, t))] = primary
201
200
  @unique_designs[t] && term.at(".//domain") and
202
- res[normalize_ref_id_text(t)] = primary
201
+ res[norm_ref_id_text(t)] = primary
203
202
  end
204
203
  end
205
204
 
@@ -209,7 +208,7 @@ module Metanorma
209
208
  end
210
209
 
211
210
  def norm_id_memorize_init(node, res_table, selector, prefix, use_domain)
212
- term_text = normalize_ref_id(node, selector, use_domain) or return
211
+ term_text = norm_ref_id(node, selector, use_domain) or return
213
212
  unless AUTO_GEN_ID_REGEXP.match(node["id"]).nil? && !node["id"].nil?
214
213
  id = unique_text_id(term_text, prefix)
215
214
  node["id"] = id
@@ -221,7 +220,7 @@ module Metanorma
221
220
  def memorize_other_pref_terms(node, res_table, text_selector, use_domain)
222
221
  node.xpath(text_selector).each_with_index do |p, i|
223
222
  i.positive? or next
224
- res_table[normalize_ref_id1(p, use_domain ? node : nil)] = node["id"]
223
+ res_table[norm_ref_id1(p, use_domain ? node : nil)] = node["id"]
225
224
  end
226
225
  end
227
226
 
@@ -230,20 +229,23 @@ module Metanorma
230
229
  "<#{d.text}> #{term}"
231
230
  end
232
231
 
233
- def normalize_ref_id(node, selector, use_domain)
232
+ def norm_ref_id(node, selector, use_domain)
234
233
  term = node.at(selector) or return nil
235
- normalize_ref_id1(term, use_domain ? node : nil)
234
+ norm_ref_id1(term, use_domain ? node : nil)
236
235
  end
237
236
 
238
- def normalize_ref_id1(term, node = nil)
237
+ def norm_ref_id1(term, node = nil)
239
238
  t = term.dup
240
- t.xpath(".//index").map(&:remove)
241
- ret = asciimath_key(t).text.strip
239
+ if t.is_a?(String) then ret = t
240
+ else
241
+ t.xpath(".//index").map(&:remove)
242
+ ret = asciimath_key(t).text.strip
243
+ end
242
244
  node and ret = domain_prefix(node, ret)
243
- normalize_ref_id_text(ret)
245
+ norm_ref_id_text(ret)
244
246
  end
245
247
 
246
- def normalize_ref_id_text(text)
248
+ def norm_ref_id_text(text)
247
249
  Metanorma::Utils::to_ncname(text.gsub(/[[:space:]]+/, "-"))
248
250
  end
249
251
 
@@ -175,7 +175,7 @@ module Metanorma
175
175
 
176
176
  def termdefinition(node)
177
177
  noko do |xml|
178
- xml.definition do |d|
178
+ xml.definition **attr_code(type: node.attr("type")) do |d|
179
179
  d << node.content
180
180
  end
181
181
  end.join("\n")
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.5.2".freeze
22
+ VERSION = "2.5.3".freeze
23
23
  end
24
24
  end
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_dependency "addressable", "~> 2.8.0"
32
32
  spec.add_dependency "asciidoctor", "~> 2.0.0"
33
33
  spec.add_dependency "iev", "~> 0.3.0"
34
- spec.add_dependency "isodoc", "~> 2.6.0"
34
+ spec.add_dependency "isodoc", "~> 2.6.1"
35
35
  spec.add_dependency "metanorma", ">= 1.6.0"
36
36
  spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
37
37
  spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
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.5.2
4
+ version: 2.5.3
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-08-10 00:00:00.000000000 Z
11
+ date: 2023-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.6.0
61
+ version: 2.6.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.6.0
68
+ version: 2.6.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: metanorma
71
71
  requirement: !ruby/object:Gem::Requirement