metanorma-standoc 3.0.6 → 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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/anchor.rb +2 -2
  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 +18 -7
  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 +9 -4
  19. data/lib/metanorma/standoc/cleanup_section_names.rb +1 -0
  20. data/lib/metanorma/standoc/cleanup_table.rb +1 -2
  21. data/lib/metanorma/standoc/cleanup_terms.rb +1 -1
  22. data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -1
  23. data/lib/metanorma/standoc/cleanup_text.rb +9 -8
  24. data/lib/metanorma/standoc/cleanup_toc.rb +1 -1
  25. data/lib/metanorma/standoc/cleanup_xref.rb +1 -1
  26. data/lib/metanorma/standoc/converter.rb +1 -0
  27. data/lib/metanorma/standoc/front_organisation.rb +13 -4
  28. data/lib/metanorma/standoc/init.rb +15 -7
  29. data/lib/metanorma/standoc/inline.rb +10 -8
  30. data/lib/metanorma/standoc/isodoc.rng +147 -5
  31. data/lib/metanorma/standoc/localbib.rb +1 -2
  32. data/lib/metanorma/standoc/macros_form.rb +21 -3
  33. data/lib/metanorma/standoc/macros_inline.rb +1 -1
  34. data/lib/metanorma/standoc/macros_link.rb +4 -5
  35. data/lib/metanorma/standoc/ref.rb +2 -2
  36. data/lib/metanorma/standoc/ref_sect.rb +1 -1
  37. data/lib/metanorma/standoc/ref_utility.rb +4 -3
  38. data/lib/metanorma/standoc/section.rb +43 -85
  39. data/lib/metanorma/standoc/sectiontype.rb +76 -0
  40. data/lib/metanorma/standoc/table.rb +9 -13
  41. data/lib/metanorma/standoc/term_lookup_cleanup.rb +26 -9
  42. data/lib/metanorma/standoc/terms.rb +1 -1
  43. data/lib/metanorma/standoc/utils.rb +5 -1
  44. data/lib/metanorma/standoc/validate.rb +79 -13
  45. data/lib/metanorma/standoc/validate_schema.rb +2 -0
  46. data/lib/metanorma/standoc/validate_section.rb +5 -6
  47. data/lib/metanorma/standoc/validate_term.rb +8 -7
  48. data/lib/metanorma/standoc/version.rb +1 -1
  49. data/metanorma-standoc.gemspec +1 -1
  50. metadata +5 -4
@@ -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
@@ -5,12 +5,13 @@ module Metanorma
5
5
  module Cleanup
6
6
  def make_preface(xml, sect)
7
7
  if xml.at("//foreword | //introduction | //acknowledgements | " \
8
- "//*[@preface]")
8
+ "//executivesummary | //*[@preface]")
9
9
  preface = sect.add_previous_sibling("<preface/>").first
10
10
  f = xml.at("//foreword") and to_preface(preface, f)
11
11
  f = xml.at("//introduction") and to_preface(preface, f)
12
12
  move_clauses_into_preface(xml, preface)
13
13
  f = xml.at("//acknowledgements") and to_preface(preface, f)
14
+ f = xml.at("//executivesummary") and to_preface(preface, f)
14
15
  end
15
16
  make_abstract(xml, sect)
16
17
  end
@@ -45,7 +46,10 @@ module Metanorma
45
46
  end
46
47
 
47
48
  def clean_abstract(dupabstract)
48
- dupabstract.traverse { |n| n.remove_attribute("id") }
49
+ dupabstract.traverse do |n|
50
+ n.remove_attribute("id")
51
+ n.remove_attribute("anchor")
52
+ end
49
53
  %w(language script unnumbered).each do |w|
50
54
  dupabstract.remove_attribute(w)
51
55
  end
@@ -95,7 +99,7 @@ module Metanorma
95
99
  y.delete("annex")
96
100
  y.name == "annex" || !y.ancestors("annex").empty? and next
97
101
  y.wrap("<annex/>")
98
- y.parent["id"] = "_#{UUIDTools::UUID.random_create}"
102
+ add_id(y.parent)
99
103
  %w(obligation language script).each { |w| y.parent[w] = y[w] }
100
104
  end
101
105
  end
@@ -148,7 +152,8 @@ module Metanorma
148
152
 
149
153
  def obligations_cleanup_info(xml)
150
154
  xml.xpath("//foreword | //introduction | //acknowledgements | " \
151
- "//references | //preface//clause").each do |r|
155
+ "//executivesummary | //references | //preface//clause")
156
+ .each do |r|
152
157
  r["obligation"] = "informative"
153
158
  end
154
159
  end
@@ -42,6 +42,7 @@ module Metanorma
42
42
  replace_title(xml, "//foreword", @i18n&.foreword)
43
43
  replace_title(xml, "//introduction", @i18n&.introduction)
44
44
  replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
45
+ replace_title(xml, "//executivesummary", @i18n&.executivesummary)
45
46
  end
46
47
 
47
48
  def section_names_refs_cleanup(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,16 +32,16 @@ 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
36
  e[:elem].replace(out.join)
37
37
  end
38
38
  end
39
39
 
40
- def lines_strip_textspan(span, nextspan)
40
+ def lines_strip_textspan(span, _nextspan)
41
41
  lines = span[:text].lines[0..-2].map(&:rstrip) <<
42
42
  span[:text].lines[-1]&.sub(/\n$/, "")
43
43
  # no final line rstrip: can be space linking to next line
44
- span[:last] or lines << nextspan[:text].lines.first # next token context
44
+ # span[:last] or lines << nextspan[:text].lines.first # next token context
45
45
  lines
46
46
  end
47
47
 
@@ -137,11 +137,12 @@ module Metanorma
137
137
 
138
138
  def block?(elem)
139
139
  %w(title name variant-title clause figure annex example introduction
140
- foreword acknowledgements note li th td dt dd p quote label
141
- abstract preferred admitted related deprecates field-of-application
142
- usage-info expression pronunciation grammar-value domain
143
- definition termnote termexample modification description
144
- newcontent floating-title tab review admonition annotation).include? elem.name
140
+ foreword acknowledgements executivesummary note li th td dt dd p
141
+ quote label abstract preferred admitted related deprecates
142
+ field-of-application usage-info expression pronunciation
143
+ grammar-value domain definition termnote termexample modification
144
+ description newcontent floating-title tab review admonition
145
+ annotation).include? elem.name
145
146
  end
146
147
 
147
148
  def empty_tag_with_text_content?(elem)
@@ -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|
@@ -39,6 +39,7 @@ module Metanorma
39
39
  preprocessor Metanorma::Standoc::Datamodel::DiagramPreprocessor
40
40
  preprocessor Metanorma::Plugin::Datastruct::Json2TextPreprocessor
41
41
  preprocessor Metanorma::Plugin::Datastruct::Yaml2TextPreprocessor
42
+ preprocessor Metanorma::Plugin::Datastruct::Data2TextPreprocessor
42
43
  preprocessor Metanorma::Plugin::Glossarist::DatasetPreprocessor
43
44
  preprocessor Metanorma::Standoc::NamedEscapePreprocessor
44
45
  inline_macro Metanorma::Standoc::PreferredTermInlineMacro
@@ -14,16 +14,24 @@ module Metanorma
14
14
  end
15
15
 
16
16
  def organization(org, orgname, node = nil, default_org = nil, attrs = {})
17
- abbrevs = org_abbrev
18
- n = abbrevs.invert[orgname] and orgname = n
17
+ orgname, abbr = org_name_and_abbrev(attrs, orgname)
19
18
  org.name orgname
20
19
  default_org && (a = node&.attr("subdivision")) && !attrs[:subdiv] and
21
20
  subdivision(a, node&.attr("subdivision-abbr"), org)
22
21
  a = attrs[:subdiv] and subdivision(a, nil, org)
23
- abbr = org_abbrev[orgname]
24
22
  abbr and org.abbreviation abbr
25
23
  end
26
24
 
25
+ def org_name_and_abbrev(org, orgname)
26
+ if org[:abbrev]
27
+ [orgname, org[:abbrev]]
28
+ else
29
+ abbrevs = org_abbrev
30
+ n = abbrevs.invert[orgname] and orgname = n
31
+ [orgname, org_abbrev[orgname]]
32
+ end
33
+ end
34
+
27
35
  def subdivision(attr, abbr, org)
28
36
  abbrs = csv_split(abbr) || []
29
37
  subdivs = csv_split(attr, ";")
@@ -50,7 +58,7 @@ module Metanorma
50
58
  list.empty? and return
51
59
  org.subdivision **attr_code(type: list[0][:type]) do |s|
52
60
  s.name { |n| n << list[0][:value] }
53
- subdiv_build(list[1..-1], s)
61
+ subdiv_build(list[1..], s)
54
62
  a = list[0][:abbr] and s.abbreviation { |n| n << a }
55
63
  end
56
64
  end
@@ -180,6 +188,7 @@ module Metanorma
180
188
 
181
189
  def extract_org_attrs_complex(node, opts, source, suffix)
182
190
  { name: node.attr(source + suffix),
191
+ abbrev: node.attr("#{source}_abbr#{suffix}"),
183
192
  role: opts[:role], desc: opts[:desc],
184
193
  subdiv: node.attr("#{source}_subdivision#{suffix}"),
185
194
  logo: node.attr("#{source}_logo#{suffix}") }.compact
@@ -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
@@ -77,7 +77,9 @@ module Metanorma
77
77
  end
78
78
 
79
79
  def highlight_parse(text, xml)
80
- xml << text
80
+ xml.span **{ class: "fmt-hi" } do |s|
81
+ s << text
82
+ end
81
83
  end
82
84
 
83
85
  def inline_quoted(node)
@@ -146,13 +148,13 @@ module Metanorma
146
148
  end
147
149
 
148
150
  def image_attributes1(node, uri, type)
149
- attr_code(src: uri, mimetype: type,
150
- id: Metanorma::Utils::anchor_or_uuid,
151
- height: node.attr("height") || "auto",
152
- width: node.attr("width") || "auto",
153
- filename: node.attr("filename"),
154
- title: node.attr("titleattr"),
155
- 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))
156
158
  end
157
159
 
158
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.3 -->
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"/>
@@ -1328,6 +1450,7 @@ numbers</a:documentation>
1328
1450
  <ref name="foreword"/>
1329
1451
  <ref name="introduction"/>
1330
1452
  <ref name="acknowledgements"/>
1453
+ <ref name="executivesummary"/>
1331
1454
  </choice>
1332
1455
  </oneOrMore>
1333
1456
  </element>
@@ -1351,6 +1474,11 @@ numbers</a:documentation>
1351
1474
  <ref name="Content-Section"/>
1352
1475
  </element>
1353
1476
  </define>
1477
+ <define name="executivesummary">
1478
+ <element name="executivesummary">
1479
+ <ref name="Content-Section"/>
1480
+ </element>
1481
+ </define>
1354
1482
  <define name="indexsect">
1355
1483
  <element name="indexsect">
1356
1484
  <ref name="Content-Section"/>
@@ -1576,6 +1704,15 @@ used in document amendments</a:documentation>
1576
1704
  <define name="annex">
1577
1705
  <element name="annex">
1578
1706
  <ref name="Annex-Section"/>
1707
+ <zeroOrMore>
1708
+ <ref name="annex-appendix"/>
1709
+ </zeroOrMore>
1710
+ </element>
1711
+ </define>
1712
+ <define name="annex-appendix">
1713
+ <a:documentation>Appendix, distinct subclause type for annexes (annex to annex, rather than subclause to annex)</a:documentation>
1714
+ <element name="appendix">
1715
+ <ref name="Clause-Section"/>
1579
1716
  </element>
1580
1717
  </define>
1581
1718
  <define name="terms">
@@ -2106,7 +2243,7 @@ used in document amendments</a:documentation>
2106
2243
  </define>
2107
2244
  <define name="termsource">
2108
2245
  <a:documentation>The bibliographic source where a term is defined in the sense applicable in this standardisation document</a:documentation>
2109
- <element name="termsource">
2246
+ <element name="source">
2110
2247
  <attribute name="status">
2111
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>
2112
2249
  <ref name="SourceStatusType"/>
@@ -2488,6 +2625,11 @@ Normative References contents contain normative references, but as a clause in t
2488
2625
  <ref name="termsource"/>
2489
2626
  </zeroOrMore>
2490
2627
  </define>
2628
+ <define name="BlockSource">
2629
+ <zeroOrMore>
2630
+ <ref name="source"/>
2631
+ </zeroOrMore>
2632
+ </define>
2491
2633
  <start>
2492
2634
  <ref name="standard-document"/>
2493
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
@@ -208,7 +208,7 @@ module Metanorma
208
208
  fmt = format(out, target)
209
209
  fmt.empty? and fmt = "default"
210
210
  fmt = %( number-format="#{fmt}")
211
- <<~OUTPUT
211
+ <<~OUTPUT.strip
212
212
  <stem type="MathML"#{fmt}><math xmlns='#{MATHML_NS}'><mn>#{number(target)}</mn></math></stem>
213
213
  OUTPUT
214
214
  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