metanorma-standoc 3.0.7 → 3.0.9

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/html/htmlstyle.css +0 -2
  3. data/lib/metanorma/standoc/anchor.rb +1 -1
  4. data/lib/metanorma/standoc/base.rb +1 -1
  5. data/lib/metanorma/standoc/basicdoc.rng +9 -5
  6. data/lib/metanorma/standoc/blocks.rb +8 -5
  7. data/lib/metanorma/standoc/blocks_image.rb +2 -6
  8. data/lib/metanorma/standoc/blocks_notes.rb +2 -6
  9. data/lib/metanorma/standoc/cleanup.rb +5 -1
  10. data/lib/metanorma/standoc/cleanup_amend.rb +6 -8
  11. data/lib/metanorma/standoc/cleanup_asciibib.rb +17 -13
  12. data/lib/metanorma/standoc/cleanup_bibdata.rb +19 -13
  13. data/lib/metanorma/standoc/cleanup_bibitem.rb +9 -6
  14. data/lib/metanorma/standoc/cleanup_block.rb +6 -6
  15. data/lib/metanorma/standoc/cleanup_boilerplate.rb +5 -4
  16. data/lib/metanorma/standoc/cleanup_footnotes.rb +2 -4
  17. data/lib/metanorma/standoc/cleanup_image.rb +3 -3
  18. data/lib/metanorma/standoc/cleanup_inline.rb +22 -47
  19. data/lib/metanorma/standoc/cleanup_review.rb +7 -5
  20. data/lib/metanorma/standoc/cleanup_section.rb +30 -5
  21. data/lib/metanorma/standoc/cleanup_table.rb +1 -2
  22. data/lib/metanorma/standoc/cleanup_terms.rb +1 -1
  23. data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -1
  24. data/lib/metanorma/standoc/cleanup_text.rb +5 -3
  25. data/lib/metanorma/standoc/cleanup_toc.rb +1 -1
  26. data/lib/metanorma/standoc/cleanup_xref.rb +1 -1
  27. data/lib/metanorma/standoc/converter.rb +15 -7
  28. data/lib/metanorma/standoc/init.rb +15 -7
  29. data/lib/metanorma/standoc/inline.rb +12 -7
  30. data/lib/metanorma/standoc/isodoc.rng +145 -5
  31. data/lib/metanorma/standoc/localbib.rb +1 -2
  32. data/lib/metanorma/standoc/macros.rb +0 -1
  33. data/lib/metanorma/standoc/macros_form.rb +21 -3
  34. data/lib/metanorma/standoc/macros_inline.rb +24 -1
  35. data/lib/metanorma/standoc/macros_link.rb +13 -5
  36. data/lib/metanorma/standoc/macros_plantuml.rb +28 -14
  37. data/lib/metanorma/standoc/ref.rb +2 -2
  38. data/lib/metanorma/standoc/ref_sect.rb +1 -1
  39. data/lib/metanorma/standoc/ref_utility.rb +4 -3
  40. data/lib/metanorma/standoc/section.rb +9 -10
  41. data/lib/metanorma/standoc/sectiontype.rb +28 -20
  42. data/lib/metanorma/standoc/table.rb +9 -13
  43. data/lib/metanorma/standoc/term_lookup_cleanup.rb +17 -9
  44. data/lib/metanorma/standoc/terms.rb +1 -1
  45. data/lib/metanorma/standoc/utils.rb +4 -0
  46. data/lib/metanorma/standoc/validate.rb +50 -23
  47. data/lib/metanorma/standoc/validate_schema.rb +2 -0
  48. data/lib/metanorma/standoc/validate_term.rb +8 -7
  49. data/lib/metanorma/standoc/version.rb +1 -1
  50. data/metanorma-standoc.gemspec +2 -3
  51. metadata +6 -20
@@ -33,7 +33,7 @@ module Metanorma
33
33
  xmldoc.xpath("//bookmark").each do |b|
34
34
  p = b
35
35
  while !p.xml? && p = p.parent
36
- p["id"] == b["id"] or next
36
+ p["anchor"] == b["anchor"] or next
37
37
  b.remove
38
38
  break
39
39
  end
@@ -43,6 +43,7 @@ module Metanorma
43
43
  def bookmark_to_id(elem, bookmark)
44
44
  parent = bookmark.parent
45
45
  elem["id"] = bookmark.remove["id"]
46
+ elem["anchor"] = bookmark.remove["anchor"]
46
47
  strip_initial_space(parent)
47
48
  end
48
49
 
@@ -123,69 +124,31 @@ module Metanorma
123
124
  end
124
125
 
125
126
  def to_xreftarget(str)
126
- return Metanorma::Utils::to_ncname(str) unless /^[^#]+#.+$/.match?(str)
127
-
127
+ /^[^#]+#.+$/.match?(str) or return Metanorma::Utils::to_ncname(str)
128
128
  /^(?<pref>[^#]+)#(?<suff>.+)$/ =~ str
129
129
  pref = pref.gsub(%r([#{Metanorma::Utils::NAMECHAR}])o, "_")
130
130
  suff = suff.gsub(%r([#{Metanorma::Utils::NAMECHAR}])o, "_")
131
131
  "#{pref}##{suff}"
132
132
  end
133
133
 
134
- IDREF = "//*/@id | //review/@from | //review/@to | " \
135
- "//callout/@target | //citation/@bibitemid | " \
136
- "//eref/@bibitemid".freeze
137
-
138
134
  def anchor_cleanup(elem)
139
- anchor_cleanup1(elem)
140
- xreftarget_cleanup(elem)
141
135
  contenthash_id_cleanup(elem)
142
136
  end
143
137
 
144
- def anchor_cleanup1(elem)
145
- elem.xpath(IDREF).each do |s|
146
- if (ret = Metanorma::Utils::to_ncname(s.value)) != (orig = s.value)
147
- s.value = ret
148
- @log.add("Anchors", s.parent,
149
- "normalised identifier to #{ret} from #{orig}",
150
- display: false)
151
- end
152
- end
153
- end
154
-
155
- def xreftarget_cleanup(elem)
156
- elem.xpath("//xref/@target").each do |s|
157
- if (ret = to_xreftarget(s.value)) != (orig = s.value)
158
- s.value = ret
159
- @log.add("Anchors", s.parent,
160
- "normalised identifier to #{ret} from #{orig}",
161
- display: false)
162
- end
163
- end
164
- end
165
-
166
138
  def contenthash_id_cleanup(doc)
167
- ids = contenthash_id_make(doc)
168
- contenthash_id_update_refs(doc, ids)
139
+ @contenthash_ids = contenthash_id_make(doc)
169
140
  end
170
141
 
171
142
  def contenthash_id_make(doc)
172
143
  doc.xpath("//*[@id]").each_with_object({}) do |x, m|
173
- next unless Metanorma::Utils::guid_anchor?(x["id"])
174
-
144
+ # should always be true
145
+ Metanorma::Utils::guid_anchor?(x["id"]) or next
175
146
  m[x["id"]] = contenthash(x)
147
+ x["anchor"] and m[x["anchor"]] = m[x["id"]]
176
148
  x["id"] = m[x["id"]]
177
149
  end
178
150
  end
179
151
 
180
- def contenthash_id_update_refs(doc, ids)
181
- [%w(review from), %w(review to), %w(callout target), %w(eref bibitemid),
182
- %w(citation bibitemid), %w(xref target), %w(xref to)].each do |a|
183
- doc.xpath("//#{a[0]}").each do |x|
184
- ids[x[a[1]]] and x[a[1]] = ids[x[a[1]]]
185
- end
186
- end
187
- end
188
-
189
152
  def contenthash(elem)
190
153
  Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
191
154
  .sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
@@ -196,14 +159,17 @@ module Metanorma
196
159
  p.name = "passthrough"
197
160
  p.children = select_odd_chars(p.children.to_xml)
198
161
  end
199
- doc.xpath("//passthrough[@format = 'metanorma']").each do |p|
200
- p.replace(p.children)
201
- end
202
162
  doc.xpath("//identifier").each do |p|
203
163
  p.children = select_odd_chars(p.children.to_xml)
204
164
  end
205
165
  end
206
166
 
167
+ def passthrough_metanorma_cleanup(doc)
168
+ doc.xpath("//passthrough[@formats = 'metanorma']").each do |p|
169
+ p.replace(p.children)
170
+ end
171
+ end
172
+
207
173
  def link_cleanup(xmldoc)
208
174
  uri_cleanup(xmldoc)
209
175
  end
@@ -221,12 +187,21 @@ module Metanorma
221
187
  CGI.escape(comp).gsub("+", "%20")
222
188
  end
223
189
 
190
+ def source_id_cleanup(xmldoc)
191
+ xmldoc.xpath("//span[normalize-space(.)=''][@source]").each do |s|
192
+ s.parent["source"] = s["source"]
193
+ s.remove
194
+ end
195
+ end
196
+
224
197
  private
225
198
 
226
199
  # skip ZWNJ inserted to prevent regexes operating in asciidoctor
227
200
  def select_odd_chars(text)
228
201
  text.gsub(/(?!&)([[:punct:]])\u200c/, "\\1")
229
202
  end
203
+
204
+ include ::Metanorma::Standoc::Utils
230
205
  end
231
206
  end
232
207
  end
@@ -11,14 +11,15 @@ module Metanorma
11
11
  end
12
12
  end
13
13
 
14
- def review_insert_bookmark(review, id)
14
+ def review_insert_bookmark(review)
15
15
  parent = review.parent
16
16
  children = parent.children
17
17
  index = children.index(review)
18
18
  x = find_review_sibling(children, index, :previous) ||
19
19
  find_review_sibling(children, index, :following)
20
20
  ins = x || review.before("<p> </p>").previous.at(".//text()")
21
- ins.previous = "<bookmark id='#{id}'/>"
21
+ ins.previous = "<bookmark/>"
22
+ ins.previous
22
23
  end
23
24
 
24
25
  # we know node is a block: dig for a place bookmark can go
@@ -65,9 +66,10 @@ module Metanorma
65
66
 
66
67
  def review_set_location(review)
67
68
  unless review["from"]
68
- id = "_#{UUIDTools::UUID.random_create}"
69
- review_insert_bookmark(review, id)
70
- review["from"] = id
69
+ bookmark = review_insert_bookmark(review)
70
+ add_id(bookmark)
71
+ bookmark["anchor"] = bookmark["id"]
72
+ review["from"] = bookmark["id"]
71
73
  end
72
74
  review["to"] ||= review["from"]
73
75
  end
@@ -46,7 +46,10 @@ module Metanorma
46
46
  end
47
47
 
48
48
  def clean_abstract(dupabstract)
49
- dupabstract.traverse { |n| n.remove_attribute("id") }
49
+ dupabstract.traverse do |n|
50
+ n.remove_attribute("id")
51
+ n.remove_attribute("anchor")
52
+ end
50
53
  %w(language script unnumbered).each do |w|
51
54
  dupabstract.remove_attribute(w)
52
55
  end
@@ -96,7 +99,7 @@ module Metanorma
96
99
  y.delete("annex")
97
100
  y.name == "annex" || !y.ancestors("annex").empty? and next
98
101
  y.wrap("<annex/>")
99
- y.parent["id"] = "_#{UUIDTools::UUID.random_create}"
102
+ add_id(y.parent)
100
103
  %w(obligation language script).each { |w| y.parent[w] = y[w] }
101
104
  end
102
105
  end
@@ -121,7 +124,6 @@ module Metanorma
121
124
  end
122
125
 
123
126
  def sections_cleanup(xml)
124
- misccontainer_cleanup(xml)
125
127
  sections_order_cleanup(xml)
126
128
  sections_level_cleanup(xml)
127
129
  sections_names_cleanup(xml)
@@ -130,9 +132,32 @@ module Metanorma
130
132
  end
131
133
 
132
134
  def misccontainer_cleanup(xml)
133
- m = xml.at("//misc-container-clause") or return
135
+ m = xml.xpath("//metanorma-extension-clause")
136
+ m.empty? and return
134
137
  ins = add_misc_container(xml)
135
- ins << m.remove.children
138
+ m.each do |m1|
139
+ ins << m1.remove.children
140
+ end
141
+ end
142
+
143
+ def source_include_cleanup(xml)
144
+ xml.xpath("//source-include").each do |s|
145
+ f = File.join(@localdir, s["path"])
146
+ s.remove
147
+ r = source_sanitise(File.read(f))
148
+ xml.root << <<~XML
149
+ <metanorma-extension-clause>
150
+ <clause>
151
+ <title>#{s['path']}</title>
152
+ <source>#{r} </source>
153
+ </clause>
154
+ </metanorma-extension-clause>
155
+ XML
156
+ end
157
+ end
158
+
159
+ def source_sanitise(code)
160
+ code
136
161
  end
137
162
 
138
163
  def single_clause_annex(xml)
@@ -56,10 +56,9 @@ module Metanorma
56
56
  until nomatches
57
57
  nomatches = true
58
58
  xmldoc.xpath("//table/following-sibling::*[1]" \
59
- "[self::termsource]").each do |n|
59
+ "[self::source]").each do |n|
60
60
  n.previous_element << n.remove
61
61
  nomatches = false
62
- # will be renamed source from termsource later
63
62
  end
64
63
  end
65
64
  end
@@ -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
@@ -32,19 +32,21 @@ module Metanorma
32
32
  e[:skip] and next
33
33
  lines = lines_strip_textspan(e, block[i + 1])
34
34
  out = Metanorma::Utils.line_sanitise(lines)
35
- # e[:last] or out.pop
35
+ e[:last] or out.pop
36
+ /\s$/.match?(e[:text][-1]) or out[-1].rstrip!
36
37
  e[:elem].replace(out.join)
37
38
  end
38
39
  end
39
40
 
40
- def lines_strip_textspan(span, _nextspan)
41
+ def lines_strip_textspan(span, nextspan)
41
42
  lines = span[:text].lines[0..-2].map(&:rstrip) <<
42
43
  span[:text].lines[-1]&.sub(/\n$/, "")
43
44
  # no final line rstrip: can be space linking to next line
44
- # span[:last] or lines << nextspan[:text].lines.first # next token context
45
+ span[:last] or lines << nextspan[:text].lines.first # next token context
45
46
  lines
46
47
  end
47
48
 
49
+ # TODO: we are not counting empty xref, eref here
48
50
  def gather_text_for_linebreak_cleanup(block)
49
51
  x = block.xpath(".//text()").map do |e|
50
52
  { elem: e, text: e.text, stem: ancestor_include?(e, %w(stem)),
@@ -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|
@@ -37,9 +37,9 @@ module Metanorma
37
37
  preprocessor Metanorma::Standoc::LinkProtectPreprocessor
38
38
  preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
39
39
  preprocessor Metanorma::Standoc::Datamodel::DiagramPreprocessor
40
- preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
41
- preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
42
- preprocessor Metanorma::Plugin::Datastruct::Data2TextPreprocessor
40
+ preprocessor Metanorma::Plugin::Lutaml::Json2TextPreprocessor
41
+ preprocessor Metanorma::Plugin::Lutaml::Yaml2TextPreprocessor
42
+ preprocessor Metanorma::Plugin::Lutaml::Data2TextPreprocessor
43
43
  preprocessor Metanorma::Plugin::Glossarist::DatasetPreprocessor
44
44
  preprocessor Metanorma::Standoc::NamedEscapePreprocessor
45
45
  inline_macro Metanorma::Standoc::PreferredTermInlineMacro
@@ -74,6 +74,9 @@ module Metanorma
74
74
  inline_macro Metanorma::Standoc::NumberInlineMacro
75
75
  inline_macro Metanorma::Standoc::TrStyleInlineMacro
76
76
  inline_macro Metanorma::Standoc::TdStyleInlineMacro
77
+ inline_macro Metanorma::Standoc::AnchorInlineMacro
78
+ inline_macro Metanorma::Standoc::SourceIdInlineMacro
79
+ inline_macro Metanorma::Standoc::SourceIncludeInlineMacro
77
80
  block Metanorma::Standoc::ToDoAdmonitionBlock
78
81
  block Metanorma::Standoc::EditorAdmonitionBlock
79
82
  treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
@@ -103,15 +106,20 @@ module Metanorma
103
106
  $xreftext = {}
104
107
 
105
108
  def initialize(backend, opts)
109
+ doc = opts&.dig(:document)
110
+ doc&.delete_attribute("sectids") # no autoassign sect ids from title
106
111
  super
107
112
  basebackend "html"
108
113
  outfilesuffix ".xml"
109
114
  @libdir = File.dirname(self.class::_file || __FILE__)
110
115
  @c = HTMLEntities.new
111
- unless opts && @log = opts[:document]&.options&.dig(:log)
112
- @log = Metanorma::Utils::Log.new
113
- @local_log = true
114
- end
116
+ local_log(doc)
117
+ end
118
+
119
+ def local_log(doc)
120
+ @log = doc&.options&.dig(:log) and return
121
+ @log = Metanorma::Utils::Log.new
122
+ @local_log = true
115
123
  end
116
124
 
117
125
  class << self
@@ -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
@@ -13,6 +13,11 @@ module Metanorma
13
13
  end
14
14
  end
15
15
 
16
+ def pass(node)
17
+ require "debug"; binding.b
18
+ "<passthrough-inline formats='metanorma'>#{node.content}</passthrough-inline>"
19
+ end
20
+
16
21
  def page_break(node)
17
22
  attrs = {}
18
23
  node.option?("landscape") and attrs[:orientation] = "landscape"
@@ -148,13 +153,13 @@ module Metanorma
148
153
  end
149
154
 
150
155
  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)
156
+ attr_code(id_attr(node)
157
+ .merge(src: uri, mimetype: type,
158
+ height: node.attr("height") || "auto",
159
+ width: node.attr("width") || "auto",
160
+ filename: node.attr("filename"),
161
+ title: node.attr("titleattr"),
162
+ alt: node.alt == node.attr("default-alt") ? nil : node.alt))
158
163
  end
159
164
 
160
165
  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.6 -->
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">
310
+ <a:documentation>A source for the block</a:documentation>
311
+ </ref>
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">
266
353
  <a:documentation>A source for the block</a:documentation>
267
354
  </ref>
268
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,32 @@ 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
+ <optional>
805
+ <attribute name="source">
806
+ <a:documentation>Sourcing of the current element in an external data model</a:documentation>
807
+ <ref name="IdRefType"/>
808
+ </attribute>
809
+ </optional>
810
+ </define>
811
+ <define name="OptionalId" combine="interleave">
812
+ <optional>
813
+ <attribute name="anchor">
814
+ <a:documentation> User-supplied anchor of element; replaced by content-based id, with all references to the anchor updated accordingly</a:documentation>
815
+ </attribute>
816
+ </optional>
817
+ <optional>
818
+ <attribute name="source">
819
+ <a:documentation>Sourcing of the current element in an external data model</a:documentation>
820
+ <ref name="IdRefType"/>
821
+ </attribute>
822
+ </optional>
823
+ </define>
690
824
  <define name="ObligationType">
691
825
  <a:documentation>The force of a clause in a standard document: whether it has normative or informative effect</a:documentation>
692
826
  <choice>
@@ -832,6 +966,7 @@ titlecase, or lowercase</a:documentation>
832
966
  is used in particular to capture mutually agreed definitions of codepoints in Unicode Private Use Area</a:documentation>
833
967
  </attribute>
834
968
  </optional>
969
+ <ref name="OptionalId"/>
835
970
  <oneOrMore>
836
971
  <ref name="TextElement">
837
972
  <a:documentation>Textual content of span</a:documentation>
@@ -1081,7 +1216,7 @@ That concept may be defined as a term within the current document, or it may be
1081
1216
  <element name="label">
1082
1217
  <!-- Identifier of form input element that this element is a label of -->
1083
1218
  <attribute name="for">
1084
- <data type="IDREF"/>
1219
+ <ref name="IdRefType"/>
1085
1220
  </attribute>
1086
1221
  <zeroOrMore>
1087
1222
  <ref name="PureTextElement"/>
@@ -2121,7 +2256,7 @@ used in document amendments</a:documentation>
2121
2256
  </define>
2122
2257
  <define name="termsource">
2123
2258
  <a:documentation>The bibliographic source where a term is defined in the sense applicable in this standardisation document</a:documentation>
2124
- <element name="termsource">
2259
+ <element name="source">
2125
2260
  <attribute name="status">
2126
2261
  <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
2262
  <ref name="SourceStatusType"/>
@@ -2503,6 +2638,11 @@ Normative References contents contain normative references, but as a clause in t
2503
2638
  <ref name="termsource"/>
2504
2639
  </zeroOrMore>
2505
2640
  </define>
2641
+ <define name="BlockSource">
2642
+ <zeroOrMore>
2643
+ <ref name="source"/>
2644
+ </zeroOrMore>
2645
+ </define>
2506
2646
  <start>
2507
2647
  <ref name="standard-document"/>
2508
2648
  </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)
@@ -10,7 +10,6 @@ require_relative "macros_embed"
10
10
  require_relative "macros_link"
11
11
  require_relative "datamodel/attributes_table_preprocessor"
12
12
  require_relative "datamodel/diagram_preprocessor"
13
- require "metanorma-plugin-datastruct"
14
13
  require "metanorma-plugin-glossarist"
15
14
  require "metanorma-plugin-lutaml"
16
15