metanorma-standoc 3.0.7 → 3.0.8

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/anchor.rb +1 -1
  3. data/lib/metanorma/standoc/base.rb +1 -1
  4. data/lib/metanorma/standoc/basicdoc.rng +9 -5
  5. data/lib/metanorma/standoc/blocks.rb +7 -4
  6. data/lib/metanorma/standoc/blocks_image.rb +2 -6
  7. data/lib/metanorma/standoc/blocks_notes.rb +2 -6
  8. data/lib/metanorma/standoc/cleanup_amend.rb +6 -8
  9. data/lib/metanorma/standoc/cleanup_asciibib.rb +17 -13
  10. data/lib/metanorma/standoc/cleanup_bibdata.rb +19 -13
  11. data/lib/metanorma/standoc/cleanup_bibitem.rb +9 -6
  12. data/lib/metanorma/standoc/cleanup_block.rb +6 -6
  13. data/lib/metanorma/standoc/cleanup_boilerplate.rb +5 -4
  14. data/lib/metanorma/standoc/cleanup_footnotes.rb +2 -4
  15. data/lib/metanorma/standoc/cleanup_image.rb +3 -3
  16. data/lib/metanorma/standoc/cleanup_inline.rb +12 -38
  17. data/lib/metanorma/standoc/cleanup_review.rb +7 -5
  18. data/lib/metanorma/standoc/cleanup_section.rb +5 -2
  19. data/lib/metanorma/standoc/cleanup_table.rb +1 -2
  20. data/lib/metanorma/standoc/cleanup_terms.rb +1 -1
  21. data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -1
  22. data/lib/metanorma/standoc/cleanup_toc.rb +1 -1
  23. data/lib/metanorma/standoc/cleanup_xref.rb +1 -1
  24. data/lib/metanorma/standoc/init.rb +15 -7
  25. data/lib/metanorma/standoc/inline.rb +7 -7
  26. data/lib/metanorma/standoc/isodoc.rng +132 -5
  27. data/lib/metanorma/standoc/localbib.rb +1 -2
  28. data/lib/metanorma/standoc/macros_form.rb +21 -3
  29. data/lib/metanorma/standoc/macros_link.rb +4 -5
  30. data/lib/metanorma/standoc/ref.rb +2 -2
  31. data/lib/metanorma/standoc/ref_sect.rb +1 -1
  32. data/lib/metanorma/standoc/ref_utility.rb +4 -3
  33. data/lib/metanorma/standoc/section.rb +5 -6
  34. data/lib/metanorma/standoc/table.rb +9 -13
  35. data/lib/metanorma/standoc/term_lookup_cleanup.rb +26 -9
  36. data/lib/metanorma/standoc/terms.rb +1 -1
  37. data/lib/metanorma/standoc/utils.rb +4 -0
  38. data/lib/metanorma/standoc/validate.rb +50 -23
  39. data/lib/metanorma/standoc/validate_schema.rb +2 -0
  40. data/lib/metanorma/standoc/validate_term.rb +8 -7
  41. data/lib/metanorma/standoc/version.rb +1 -1
  42. data/metanorma-standoc.gemspec +1 -1
  43. metadata +4 -4
@@ -82,7 +82,7 @@ module Metanorma
82
82
 
83
83
  def term_children_cleanup(xmldoc)
84
84
  xmldoc.xpath("//term").each do |t|
85
- %w(termnote termexample termsource term).each do |w|
85
+ %w(termnote termexample source term).each do |w|
86
86
  t.xpath("./#{w}").each { |n| t << n.remove }
87
87
  end
88
88
  end
@@ -151,7 +151,7 @@ module Metanorma
151
151
  DESIGNATOR = %w(preferred admitted deprecates related).freeze
152
152
 
153
153
  def term_termsource_to_designation(xmldoc)
154
- xmldoc.xpath("//term/termsource").each do |t|
154
+ xmldoc.xpath("//term/source").each do |t|
155
155
  p = t.previous_element
156
156
  while %w(domain subject).include? p&.name
157
157
  p = p.previous_element
@@ -71,7 +71,7 @@ module Metanorma
71
71
 
72
72
  def toc_cleanup_clause_entry(xmldoc, list)
73
73
  list.xpath(".//xref[not(text())][not(display-text)]").each do |x|
74
- c1 = xmldoc.at("//*[@id = '#{x['target']}']")
74
+ c1 = xmldoc.at("//*[@anchor = '#{x['target']}']")
75
75
  t = c1.at("./variant-title[@type = 'toc']") || c1.at("./title")
76
76
  x << "<display-text>#{to_xml(t.dup.children)}</display-text>"
77
77
  end
@@ -118,7 +118,7 @@ module Metanorma
118
118
  end
119
119
 
120
120
  def anchor_alias(xmldoc)
121
- t = xmldoc.at("//metanorma-extension/table[@id = " \
121
+ t = xmldoc.at("//metanorma-extension/table[@anchor = " \
122
122
  "'_misccontainer_anchor_aliases']") or return
123
123
  key = ""
124
124
  t.xpath("./tbody/tr").each do |tr|
@@ -139,18 +139,26 @@ module Metanorma
139
139
  def init_math(node)
140
140
  @keepasciimath = node.attr("mn-keep-asciimath") &&
141
141
  node.attr("mn-keep-asciimath") != "false"
142
- @numberfmt_default = kv_parse(@c.decode(node.attr("number-presentation")))
143
- @numberfmt_formula = @c.decode(node.attr("number-presentation-formula"))
144
- @numberfmt_formula == "number-presentation" and
145
- @numberfmt_formula = @c.decode(node.attr("number-presentation"))
146
- @numberfmt_formula == "default" and
147
- @numberfmt_formula = "notation='basic'"
148
- @numberfmt_prof = node.attributes.each_with_object({}) do |(k, v), m|
142
+ @numberfmt_default =
143
+ kv_parse(@c.decode(node.attr("number-presentation")))
144
+ numberfmt_formula(node)
145
+ @numberfmt_prof = node.attributes.each_with_object({}) do |(k, v), m|
149
146
  p = /^number-presentation-profile-(.*)$/.match(k) or next
150
147
  m[p[1]] = kv_parse(@c.decode(v))
151
148
  end
152
149
  end
153
150
 
151
+ def numberfmt_formula(node)
152
+ @numberfmt_formula = node.attr("number-presentation-formula")
153
+ @numberfmt_formula.nil? ||
154
+ @numberfmt_formula == "number-presentation" and
155
+ @numberfmt_formula = @c.decode(node.attr("number-presentation"))
156
+ @numberfmt_formula == "nil" and @numberfmt_formula = nil
157
+ @numberfmt_formula == "default" and
158
+ @numberfmt_formula = "notation='basic'"
159
+ @numberfmt_formula = @c.decode(@numberfmt_formula)
160
+ end
161
+
154
162
  def requirements_processor
155
163
  Metanorma::Requirements
156
164
  end
@@ -148,13 +148,13 @@ module Metanorma
148
148
  end
149
149
 
150
150
  def image_attributes1(node, uri, type)
151
- attr_code(src: uri, mimetype: type,
152
- id: Metanorma::Utils::anchor_or_uuid,
153
- height: node.attr("height") || "auto",
154
- width: node.attr("width") || "auto",
155
- filename: node.attr("filename"),
156
- title: node.attr("titleattr"),
157
- alt: node.alt == node.attr("default-alt") ? nil : node.alt)
151
+ attr_code(id_attr(node)
152
+ .merge(src: uri, mimetype: type,
153
+ height: node.attr("height") || "auto",
154
+ width: node.attr("width") || "auto",
155
+ filename: node.attr("filename"),
156
+ title: node.attr("titleattr"),
157
+ alt: node.alt == node.attr("default-alt") ? nil : node.alt))
158
158
  end
159
159
 
160
160
  def inline_image(node)
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <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">
3
- <!-- VERSION v2.0.4 -->
3
+ <!-- VERSION v2.0.5 -->
4
4
 
5
5
  <!--
6
6
  ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
@@ -36,6 +36,12 @@
36
36
  </zeroOrMore>
37
37
  </element>
38
38
  </define>
39
+ <define name="IdRefType">
40
+ <a:documentation>Cross-references are not normalised to xsd:IDREF in Semantic XML: that is deferred to Presentation XML.
41
+ All IdRefType instances point not to `@id` in Semantic XML, which is the Content GUID for an element,
42
+ but to `@anchor`, the user-supplied cross-reference</a:documentation>
43
+ <text/>
44
+ </define>
39
45
  <define name="index-primary">
40
46
  <element name="primary">
41
47
  <oneOrMore>
@@ -238,7 +244,7 @@
238
244
  <a:documentation>Notes specific to this block</a:documentation>
239
245
  </ref>
240
246
  </zeroOrMore>
241
- <ref name="TermSource">
247
+ <ref name="BlockSource">
242
248
  <a:documentation>A source for the table</a:documentation>
243
249
  </ref>
244
250
  </define>
@@ -262,10 +268,112 @@ and is intended to be referenced by a callout within the source code</a:document
262
268
  <a:documentation>Notes whose scope is the current block</a:documentation>
263
269
  </ref>
264
270
  </zeroOrMore>
265
- <ref name="TermSource">
271
+ <ref name="BlockSource">
272
+ <a:documentation>A source for the block</a:documentation>
273
+ </ref>
274
+ </define>
275
+ <define name="FigureBody">
276
+ <optional>
277
+ <ref name="tname">
278
+ <a:documentation>The caption of the block</a:documentation>
279
+ </ref>
280
+ </optional>
281
+ <choice>
282
+ <a:documentation>Content of the figure</a:documentation>
283
+ <ref name="image"/>
284
+ <ref name="video"/>
285
+ <ref name="audio"/>
286
+ <ref name="pre"/>
287
+ <oneOrMore>
288
+ <ref name="paragraph-with-footnote"/>
289
+ </oneOrMore>
290
+ <zeroOrMore>
291
+ <ref name="figure"/>
292
+ </zeroOrMore>
293
+ </choice>
294
+ <zeroOrMore>
295
+ <ref name="fn">
296
+ <a:documentation>Footnotes specific to the figure</a:documentation>
297
+ </ref>
298
+ </zeroOrMore>
299
+ <optional>
300
+ <ref name="dl">
301
+ <a:documentation>An optional definitions list defining any symbols used in the figure</a:documentation>
302
+ </ref>
303
+ </optional>
304
+ <zeroOrMore>
305
+ <ref name="note">
306
+ <a:documentation>Notes whose scope is the current block</a:documentation>
307
+ </ref>
308
+ </zeroOrMore>
309
+ <ref name="BlockSource">
266
310
  <a:documentation>A source for the block</a:documentation>
267
311
  </ref>
268
312
  </define>
313
+ <define name="FigureNoIdBody">
314
+ <optional>
315
+ <ref name="source">
316
+ <a:documentation>A URI or other reference intended to link to an externally hosted image (or equivalent)</a:documentation>
317
+ </ref>
318
+ </optional>
319
+ <optional>
320
+ <ref name="tname">
321
+ <a:documentation>The caption of the block</a:documentation>
322
+ </ref>
323
+ </optional>
324
+ <choice>
325
+ <a:documentation>Content of the figure</a:documentation>
326
+ <ref name="image-no-id"/>
327
+ <ref name="video-no-id"/>
328
+ <ref name="audio-no-id"/>
329
+ <ref name="pre-no-id"/>
330
+ <oneOrMore>
331
+ <ref name="paragraph-with-footnote-no-id"/>
332
+ </oneOrMore>
333
+ <zeroOrMore>
334
+ <ref name="figure-no-id"/>
335
+ </zeroOrMore>
336
+ </choice>
337
+ <zeroOrMore>
338
+ <ref name="fn">
339
+ <a:documentation>Footnotes specific to the figure</a:documentation>
340
+ </ref>
341
+ </zeroOrMore>
342
+ <optional>
343
+ <ref name="dl-no-id">
344
+ <a:documentation>An optional definitions list defining any symbols used in the figure</a:documentation>
345
+ </ref>
346
+ </optional>
347
+ <zeroOrMore>
348
+ <ref name="note-no-id">
349
+ <a:documentation>Notes whose scope is the current block</a:documentation>
350
+ </ref>
351
+ </zeroOrMore>
352
+ <ref name="BlockSource">
353
+ <a:documentation>A source for the block</a:documentation>
354
+ </ref>
355
+ </define>
356
+ <define name="source">
357
+ <element name="source">
358
+ <attribute name="status">
359
+ <a:documentation>The status of the term as it is used in this document, relative to its definition in the original document</a:documentation>
360
+ <ref name="SourceStatusType"/>
361
+ </attribute>
362
+ <attribute name="type">
363
+ <a:documentation>The type of the managed term in the present context</a:documentation>
364
+ <ref name="SourceTypeType"/>
365
+ </attribute>
366
+ <ref name="origin">
367
+ <a:documentation>The original document and location where the term definition has been obtained from</a:documentation>
368
+ </ref>
369
+ <optional>
370
+ <ref name="modification">
371
+ <a:documentation>Any changes that the definition of the term has undergone relative to the original document,
372
+ in order to be applicable in this standardisation document</a:documentation>
373
+ </ref>
374
+ </optional>
375
+ </element>
376
+ </define>
269
377
  <define name="sourcecodebody">
270
378
  <a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
271
379
  (The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
@@ -687,6 +795,20 @@ titlecase, or lowercase</a:documentation>
687
795
  </attribute>
688
796
  </optional>
689
797
  </define>
798
+ <define name="RequiredId" combine="interleave">
799
+ <optional>
800
+ <attribute name="anchor">
801
+ <a:documentation>User-supplied anchor of element; replaced by content-based id, with all references to the anchor updated accordingly</a:documentation>
802
+ </attribute>
803
+ </optional>
804
+ </define>
805
+ <define name="OptionalId" combine="interleave">
806
+ <optional>
807
+ <attribute name="anchor">
808
+ <a:documentation> User-supplied anchor of element; replaced by content-based id, with all references to the anchor updated accordingly</a:documentation>
809
+ </attribute>
810
+ </optional>
811
+ </define>
690
812
  <define name="ObligationType">
691
813
  <a:documentation>The force of a clause in a standard document: whether it has normative or informative effect</a:documentation>
692
814
  <choice>
@@ -1081,7 +1203,7 @@ That concept may be defined as a term within the current document, or it may be
1081
1203
  <element name="label">
1082
1204
  <!-- Identifier of form input element that this element is a label of -->
1083
1205
  <attribute name="for">
1084
- <data type="IDREF"/>
1206
+ <ref name="IdRefType"/>
1085
1207
  </attribute>
1086
1208
  <zeroOrMore>
1087
1209
  <ref name="PureTextElement"/>
@@ -2121,7 +2243,7 @@ used in document amendments</a:documentation>
2121
2243
  </define>
2122
2244
  <define name="termsource">
2123
2245
  <a:documentation>The bibliographic source where a term is defined in the sense applicable in this standardisation document</a:documentation>
2124
- <element name="termsource">
2246
+ <element name="source">
2125
2247
  <attribute name="status">
2126
2248
  <a:documentation>The status of the term as it is used in this document, relative to its definition in the original document</a:documentation>
2127
2249
  <ref name="SourceStatusType"/>
@@ -2503,6 +2625,11 @@ Normative References contents contain normative references, but as a clause in t
2503
2625
  <ref name="termsource"/>
2504
2626
  </zeroOrMore>
2505
2627
  </define>
2628
+ <define name="BlockSource">
2629
+ <zeroOrMore>
2630
+ <ref name="source"/>
2631
+ </zeroOrMore>
2632
+ </define>
2506
2633
  <start>
2507
2634
  <ref name="standard-document"/>
2508
2635
  </start>
@@ -22,7 +22,7 @@ module Metanorma
22
22
  end
23
23
 
24
24
  def init_file_bibdb_config(defn, key)
25
- /=/.match?(defn) or defn = "file=#{defn}"
25
+ defn.include?("=") or defn = "file=#{defn}"
26
26
  values = defn.split(",").map { |item| item.split /(?<!\s)\s*=\s*/ }.to_h
27
27
  values["key"] = key
28
28
  values["format"] ||= "bibtex" # all we currently suppoort
@@ -63,7 +63,6 @@ module Metanorma
63
63
 
64
64
  def get(id, file = default)
65
65
  ret = @file_bibdb.dig(file, id) and return ret
66
-
67
66
  msg = "Cannot find reference #{id} for local relaton " \
68
67
  "data source #{file}"
69
68
  @parent.log.add("Bibliography", nil, msg, severity: 0)
@@ -4,9 +4,15 @@ module Metanorma
4
4
  use_dsl
5
5
  named :input
6
6
 
7
+ def map_attr_name(attr)
8
+ attr == "id" ? "anchor" : attr
9
+ end
10
+
7
11
  def process(_parent, target, attr)
8
12
  m = %w(id name value disabled readonly checked maxlength minlength)
9
- .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
13
+ .map { |a| attr[a] ? " #{map_attr_name(a)}='#{attr[a]}'" : nil }
14
+ .compact
15
+ m << " id='_#{UUIDTools::UUID.random_create}'"
10
16
  %{<input type='#{target}' #{m.join}/>}
11
17
  end
12
18
  end
@@ -27,9 +33,15 @@ module Metanorma
27
33
  named :textarea
28
34
  using_format :short
29
35
 
36
+ def map_attr_name(attr)
37
+ attr == "id" ? "anchor" : attr
38
+ end
39
+
30
40
  def process(_parent, _target, attr)
31
41
  m = %w(id name rows cols value)
32
- .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
42
+ .map { |a| attr[a] ? " #{map_attr_name(a)}='#{attr[a]}'" : nil }
43
+ .compact
44
+ m << " id='_#{UUIDTools::UUID.random_create}'"
33
45
  %{<textarea #{m.join}/>}
34
46
  end
35
47
  end
@@ -39,9 +51,15 @@ module Metanorma
39
51
  named :select
40
52
  using_format :short
41
53
 
54
+ def map_attr_name(attr)
55
+ attr == "id" ? "anchor" : attr
56
+ end
57
+
42
58
  def process(parent, _target, attr)
43
59
  m = %w(id name size disabled multiple value)
44
- .map { |a| attr[a] ? " #{a}='#{attr[a]}'" : nil }.compact
60
+ .map { |a| attr[a] ? " #{map_attr_name(a)}='#{attr[a]}'" : nil }
61
+ .compact
62
+ m << " id='_#{UUIDTools::UUID.random_create}'"
45
63
  out = Asciidoctor::Inline.new(parent, :quoted, attr["text"]).convert
46
64
  %{<select #{m.join}>#{out}</select>}
47
65
  end
@@ -68,13 +68,12 @@ module Metanorma
68
68
 
69
69
  def process(parent, _target, attrs)
70
70
  t = attrs["text"]
71
- t = if /,/.match?(t)
71
+ t = if t.include?(",")
72
72
  t.sub(/,/, "%")
73
- else
74
- "#{t}%"
73
+ else "#{t}%"
75
74
  end
76
- create_anchor(parent, "hidden=#{t}",
77
- type: :xref, target: "_#{UUIDTools::UUID.random_create}")
75
+ target = attrs["text"].sub(/,.*$/, "").gsub(":", "_") # special char
76
+ create_anchor(parent, "hidden=#{t}", type: :xref, target: target)
78
77
  end
79
78
  end
80
79
  end
@@ -131,8 +131,8 @@ module Metanorma
131
131
 
132
132
  def refitem_render(xml, match, code)
133
133
  xml.bibitem **attr_code(
134
- id: match[:anchor], suppress_identifier: code[:dropid],
135
- hidden: code[:hidden]
134
+ anchor: match[:anchor], suppress_identifier: code[:dropid],
135
+ hidden: code[:hidden], id: "_#{UUIDTools::UUID.random_create}"
136
136
  ) do |t|
137
137
  refitem_render_formattedref(t, match[:text])
138
138
  yr_match = refitem1yr(code[:id])
@@ -76,7 +76,7 @@ module Metanorma
76
76
  @log.add("Bibliography", nil,
77
77
  "ERROR: No title retrieved for #{code}")
78
78
  !fmt and
79
- xml.root << "<title>#{title || '(MISSING TITLE)'}</title>"
79
+ xml.root << "<title>#{title || '(MISSING TITLE)'}</title>"
80
80
  end
81
81
  fmt and xml.root << "<formattedref>#{title}</formattedref>"
82
82
  end
@@ -32,7 +32,8 @@ module Metanorma
32
32
  end
33
33
 
34
34
  def use_my_anchor(ref, id, opt)
35
- ref.parent.elements.last["id"] = id
35
+ ref.parent.elements.last["anchor"] = id
36
+ add_id(ref.parent.elements.last)
36
37
  a = opt[:hidden] and ref.parent.elements.last["hidden"] = a
37
38
  a = opt[:dropid] and
38
39
  ref.parent.elements.last["suppress_identifier"] = a
@@ -195,8 +196,8 @@ module Metanorma
195
196
 
196
197
  def ref_attributes(match)
197
198
  code = analyse_ref_code(match[:code])
198
-
199
- { id: match[:anchor], type: "standard",
199
+ { anchor: match[:anchor], id: "_#{UUIDTools::UUID.random_create}",
200
+ type: "standard",
200
201
  suppress_identifier: code[:dropid] || nil }
201
202
  end
202
203
 
@@ -11,13 +11,12 @@ module Metanorma
11
11
  @norm_ref = false
12
12
 
13
13
  def section_attributes(node)
14
- ret =
15
- { id: Metanorma::Utils::anchor_or_uuid(node),
16
- unnumbered: node.option?("unnumbered") ? "true" : nil,
17
- annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
14
+ ret = id_unnum_attrs(node).merge(
15
+ { annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
18
16
  colophon: role_style(node, "colophon") ? true : nil,
19
- preface: role_style(node, "preface") ? true : nil }
20
- %w(language script number branch-number type tag keeptitle
17
+ preface: role_style(node, "preface") ? true : nil },
18
+ )
19
+ %w(language script branch-number type tag keeptitle
21
20
  multilingual-rendering).each do |k|
22
21
  a = node.attr(k) and ret[k.to_sym] = a
23
22
  end
@@ -3,11 +3,8 @@ module Metanorma
3
3
  module Table
4
4
  def table_attrs(node)
5
5
  keep_attrs(node)
6
- .merge(id: Metanorma::Utils::anchor_or_uuid(node),
7
- headerrows: node.attr("headerrows"),
8
- unnumbered: node.option?("unnumbered") ? "true" : nil,
9
- number: node.attr("number"),
10
- subsequence: node.attr("subsequence"),
6
+ .merge(id_unnum_attrs(node))
7
+ .merge(headerrows: node.attr("headerrows"),
11
8
  alt: node.attr("alt"),
12
9
  summary: node.attr("summary"),
13
10
  width: node.attr("width"))
@@ -28,11 +25,9 @@ module Metanorma
28
25
  private
29
26
 
30
27
  def colgroup(node, xml_table)
31
- return if node.option? "autowidth"
32
-
33
- cols = node&.attr("cols")&.split(/,/) or return
34
- return unless (cols.size > 1) && cols.all? { |c| /\d/.match(c) }
35
-
28
+ node.option? "autowidth" and return
29
+ cols = node.attr("cols")&.split(",") or return
30
+ (cols.size > 1) && cols.all? { |c| /\d/.match(c) } or return
36
31
  xml_table.colgroup do |cg|
37
32
  node.columns.each do |col|
38
33
  cg.col width: "#{col.attr 'colpcwidth'}%"
@@ -57,9 +52,10 @@ module Metanorma
57
52
  end
58
53
 
59
54
  def table_cell(node, xml_tr, tblsec)
60
- cell_attributes =
61
- { id: node.id, colspan: node.colspan, valign: node.attr("valign"),
62
- rowspan: node.rowspan, align: node.attr("halign") }
55
+ cell_attributes = id_attr(node).merge(
56
+ { colspan: node.colspan, valign: node.attr("valign"),
57
+ rowspan: node.rowspan, align: node.attr("halign") },
58
+ )
63
59
  cell_tag = "td"
64
60
  cell_tag = "th" if tblsec == :head || node.style == :header
65
61
  xml_tr.send cell_tag, **attr_code(cell_attributes) do |thd|
@@ -16,11 +16,13 @@ module Metanorma
16
16
  @unique_designs = {}
17
17
  @c = HTMLEntities.new
18
18
  @terms_tags = xmldoc.xpath("//terms").each_with_object({}) do |t, m|
19
- m[t["id"]] = true
19
+ #m[t["id"]] = true
20
+ m[t["anchor"]] = true
20
21
  end
21
22
  end
22
23
 
23
24
  def call
25
+ #require "debug"; binding.b
24
26
  @idhash = populate_idhash
25
27
  @unique_designs = unique_designators
26
28
  @lookup = replace_automatic_generated_ids_terms
@@ -29,6 +31,7 @@ module Metanorma
29
31
  related_cleanup
30
32
  remove_missing_refs
31
33
  concept_cleanup2
34
+ anchor_to_id
32
35
  end
33
36
 
34
37
  private
@@ -36,7 +39,7 @@ module Metanorma
36
39
  def unique_designators
37
40
  ret = xmldoc
38
41
  .xpath("//preferred/expression/name | //admitted/expression/name | " \
39
- "//deprecated/expression/name").each_with_object({}) do |n, m|
42
+ "//deprecates/expression/name").each_with_object({}) do |n, m|
40
43
  m[n.text] ||= 0
41
44
  m[n.text] += 1
42
45
  end
@@ -69,9 +72,12 @@ module Metanorma
69
72
  end
70
73
 
71
74
  def populate_idhash
72
- xmldoc.xpath("//*[@id]").each_with_object({}) do |n, mem|
73
- /^(term|symbol)-/.match?(n["id"]) or next
74
- mem[n["id"]] = true
75
+ #xmldoc.xpath("//*[@id]").each_with_object({}) do |n, mem|
76
+ xmldoc.xpath("//*[@anchor]").each_with_object({}) do |n, mem|
77
+ #/^(term|symbol)-/.match?(n["id"]) or next
78
+ /^(term|symbol)-/.match?(n["anchor"]) or next
79
+ #mem[n["id"]] = true
80
+ mem[n["anchor"]] = true
75
81
  end
76
82
  end
77
83
 
@@ -207,18 +213,22 @@ module Metanorma
207
213
 
208
214
  def norm_id_memorize_init(node, res_table, selector, prefix, use_domain)
209
215
  term_text = norm_ref_id(node, selector, use_domain) or return
210
- unless AUTO_GEN_ID_REGEXP.match(node["id"]).nil? && !node["id"].nil?
216
+ #unless AUTO_GEN_ID_REGEXP.match(node["id"]).nil? && !node["id"].nil?
217
+ unless AUTO_GEN_ID_REGEXP.match(node["anchor"]).nil? && !node["anchor"].nil?
211
218
  id = unique_text_id(term_text, prefix)
212
- node["id"] = id
219
+ #node["id"] = id
220
+ node["anchor"] = id
213
221
  @idhash[id] = true
214
222
  end
215
- res_table[term_text] = node["id"]
223
+ #res_table[term_text] = node["id"]
224
+ res_table[term_text] = node["anchor"]
216
225
  end
217
226
 
218
227
  def memorize_other_pref_terms(node, res_table, text_selector, use_domain)
219
228
  node.xpath(text_selector).each_with_index do |p, i|
220
229
  i.positive? or next
221
- res_table[norm_ref_id1(p, use_domain ? node : nil)] = node["id"]
230
+ #res_table[norm_ref_id1(p, use_domain ? node : nil)] = node["id"]
231
+ res_table[norm_ref_id1(p, use_domain ? node : nil)] = node["anchor"]
222
232
  end
223
233
  end
224
234
 
@@ -255,6 +265,13 @@ module Metanorma
255
265
  end
256
266
  end
257
267
 
268
+ def anchor_to_id
269
+ xmldoc.xpath("//*[@anchor]").each do |n|
270
+ /^(term|symbol)-/.match?(n["anchor"]) or next
271
+ n["id"] or add_id(n)
272
+ end
273
+ end
274
+
258
275
  include ::Metanorma::Standoc::Utils
259
276
  end
260
277
  end
@@ -157,7 +157,7 @@ module Metanorma
157
157
  def termsource(node)
158
158
  matched = extract_termsource_refs(node.content, node) or return
159
159
  noko do |xml|
160
- xml.termsource **termsource_attrs(node, matched) do |xml_t|
160
+ xml.source **termsource_attrs(node, matched) do |xml_t|
161
161
  seen_xref = Nokogiri::XML.fragment(matched[:xref])
162
162
  add_term_source(node, xml_t, seen_xref, matched)
163
163
  end
@@ -35,6 +35,10 @@ module Metanorma
35
35
  Metanorma::Utils::attr_code(attributes)
36
36
  end
37
37
 
38
+ def add_id(node)
39
+ node["id"] = "_#{UUIDTools::UUID.random_create}"
40
+ end
41
+
38
42
  def csv_split(text, delim = ";")
39
43
  Metanorma::Utils::csv_split(@c.decode(text), delim)
40
44
  .map { |x| @c.encode(x, :basic, :hexadecimal) }