metanorma-standoc 1.11.1 → 1.11.2

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/asciidoctor/standoc/blocks.rb +1 -1
  3. data/lib/asciidoctor/standoc/cleanup.rb +1 -1
  4. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -20
  5. data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +25 -15
  6. data/lib/asciidoctor/standoc/cleanup_section_names.rb +2 -2
  7. data/lib/asciidoctor/standoc/cleanup_terms.rb +23 -19
  8. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +31 -14
  9. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +6 -6
  10. data/lib/asciidoctor/standoc/inline.rb +13 -11
  11. data/lib/asciidoctor/standoc/isodoc.rng +42 -17
  12. data/lib/asciidoctor/standoc/ref.rb +101 -75
  13. data/lib/asciidoctor/standoc/ref_date_id.rb +30 -1
  14. data/lib/asciidoctor/standoc/ref_sect.rb +16 -6
  15. data/lib/asciidoctor/standoc/reqt.rb +1 -1
  16. data/lib/asciidoctor/standoc/section.rb +1 -1
  17. data/lib/asciidoctor/standoc/validate.rb +1 -1
  18. data/lib/isodoc/html/htmlstyle.css +1 -1
  19. data/lib/isodoc/html/htmlstyle.scss +1 -1
  20. data/lib/metanorma/standoc/version.rb +1 -1
  21. data/metanorma-standoc.gemspec +2 -2
  22. data/spec/asciidoctor/blocks_spec.rb +15 -15
  23. data/spec/asciidoctor/cleanup_sections_spec.rb +1 -1
  24. data/spec/asciidoctor/cleanup_spec.rb +4 -4
  25. data/spec/asciidoctor/cleanup_terms_spec.rb +248 -63
  26. data/spec/asciidoctor/datamodel/attributes_table_preprocessor_spec.rb +21 -21
  27. data/spec/asciidoctor/datamodel/diagram_preprocessor_spec.rb +16 -16
  28. data/spec/asciidoctor/inline_spec.rb +5 -5
  29. data/spec/asciidoctor/isobib_cache_spec.rb +4 -8
  30. data/spec/asciidoctor/macros_spec.rb +2 -2
  31. data/spec/asciidoctor/refs_spec.rb +842 -664
  32. data/spec/asciidoctor/section_spec.rb +2 -2
  33. data/spec/spec_helper.rb +0 -1
  34. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +176 -176
  35. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  36. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  37. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -24
  38. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +34 -34
  39. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  40. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  41. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  42. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +46 -46
  43. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25f4c5a4250a14fb1499512d51f25cf8ea7b1cc6dc7da44560dc442342a54773
4
- data.tar.gz: 10dd5ba69da52963c0e9310834212fc5e74743f660a4cf533efdd721037f5f5d
3
+ metadata.gz: 6a5cc91caf1f8d674aeff3b46209557d7be11087bf59728df07a73b26cec880a
4
+ data.tar.gz: 7b674d7c013a3e5aee09394c085ee40dbbed6e241ffb14a14b363ca5956636f5
5
5
  SHA512:
6
- metadata.gz: dbc30f8112130ea49edcfabf97fedc1d3934f41a09163369fb74ba754eb5d11e861e040df17b15e2f865b7f5bb43d8513a76f859bc192eb2f30f23e4dea67232
7
- data.tar.gz: 2ce49c90d894757b2964c4922b702bfb54c24f5e8d53a530a399692f6003042d8c9d44f5ebbc57110d6c56bc3d18fc17650e2511c8b102e38dce2a0d7b85fd41
6
+ metadata.gz: dab0eafeeb100111eecdd7ae0eeb3a23dd1b60acdbf1fc884a7fba6084db22bc816c8255c230a16eb4ab0fc68555378586106145545672a5b39d444e8a3f97c8
7
+ data.tar.gz: 1f6ffc49435ffebec0441fafbf4a6eb629216270d0d8fd38d68ad15a5d99e4e3162f3d685229827e0eb1df2a2c6d43aaf475795cbcdb143b772d5589787248ff
@@ -1,5 +1,5 @@
1
1
  require "htmlentities"
2
- require "uri"
2
+ require "uri" if /^2\./.match?(RUBY_VERSION)
3
3
  require_relative "./blocks_notes"
4
4
 
5
5
  module Asciidoctor
@@ -76,7 +76,7 @@ module Asciidoctor
76
76
  street city state country postcode identifier referenceFrom surname
77
77
  referenceTo docidentifier docnumber prefix initial addition forename
78
78
  title draft secretariat title-main title-intro title-part
79
- verbaldefinition nonverbalrepresentation}.freeze
79
+ verbal-definition non-verbal-representation}.freeze
80
80
 
81
81
  # it seems Nokogiri::XML is treating the content of <script> as cdata,
82
82
  # because of its use in HTML. Bad nokogiri. Undoing that, since we use
@@ -15,15 +15,18 @@ module Asciidoctor
15
15
  )
16
16
  end
17
17
 
18
- def term_defs_boilerplate(div, source, term, preface, isodoc)
18
+ def term_defs_boilerplate(div, source, term, _preface, isodoc)
19
19
  a = @i18n.term_def_boilerplate and div.next = a
20
20
  source.each do |s|
21
21
  @anchors[s["bibitemid"]] or
22
22
  @log.add("Crossreferences", nil,
23
23
  "term source #{s['bibitemid']} not referenced")
24
24
  end
25
- a = source.empty? && term.nil? ? @i18n.no_terms_boilerplate :
26
- term_defs_boilerplate_cont(source, term, isodoc)
25
+ a = if source.empty? && term.nil?
26
+ @i18n.no_terms_boilerplate
27
+ else
28
+ term_defs_boilerplate_cont(source, term, isodoc)
29
+ end
27
30
  a and div.next = a
28
31
  end
29
32
 
@@ -51,10 +54,11 @@ module Asciidoctor
51
54
  end
52
55
 
53
56
  TERM_CLAUSE = "//sections/terms | "\
54
- "//sections/clause[descendant::terms]".freeze
57
+ "//sections/clause[descendant::terms]".freeze
55
58
 
56
59
  NORM_REF = "//bibliography/references[@normative = 'true'] | "\
57
- "//bibliography/clause[.//references[@normative = 'true']]".freeze
60
+ "//bibliography/clause[.//references[@normative = 'true']]"
61
+ .freeze
58
62
 
59
63
  def boilerplate_isodoc(xmldoc)
60
64
  x = xmldoc.dup
@@ -118,8 +122,11 @@ module Asciidoctor
118
122
 
119
123
  def boilerplate(xml, conv)
120
124
  file = boilerplate_file(xml)
121
- file = File.join(@localdir, @boilerplateauthority) if @boilerplateauthority
122
- !file.nil? and File.exists?(file) or return
125
+ if @boilerplateauthority
126
+ file = File.join(@localdir,
127
+ @boilerplateauthority)
128
+ end
129
+ (!file.nil? and File.exists?(file)) or return
123
130
  conv.populate_template(File.read(file, encoding: "UTF-8"), nil)
124
131
  end
125
132
 
@@ -166,28 +173,29 @@ module Asciidoctor
166
173
  end
167
174
  end
168
175
 
169
- def indirect_eref_to_xref(e, id)
170
- loc = e&.at("./localityStack[locality[@type = 'anchor']]")&.remove&.text ||
171
- e&.at("./locality[@type = 'anchor']")&.remove&.text || id
172
- e.name = "xref"
173
- e.delete("bibitemid")
174
- e.delete("citeas")
175
- e["target"] = loc
176
- unless e.document.at("//*[@id = '#{loc}']")
177
- e.children = %(** Missing target #{loc})
178
- e["target"] = id
176
+ def indirect_eref_to_xref(eref, ident)
177
+ loc = eref&.at("./localityStack[locality[@type = 'anchor']]")
178
+ &.remove&.text ||
179
+ eref&.at("./locality[@type = 'anchor']")&.remove&.text || ident
180
+ eref.name = "xref"
181
+ eref.delete("bibitemid")
182
+ eref.delete("citeas")
183
+ eref["target"] = loc
184
+ unless eref.document.at("//*[@id = '#{loc}']")
185
+ eref.children = %(** Missing target #{loc})
186
+ eref["target"] = ident
179
187
  end
180
188
  end
181
189
 
182
190
  def resolve_local_indirect_erefs(xmldoc, refs, prefix)
183
191
  refs.each_with_object([]) do |r, m|
184
192
  id = r.sub(/^#{prefix}_/, "")
185
- if n = xmldoc.at("//*[@id = '#{id}']") and n.at("./ancestor-or-self::*[@type = '#{prefix}']")
193
+ if n = xmldoc.at("//*[@id = '#{id}']") and
194
+ n.at("./ancestor-or-self::*[@type = '#{prefix}']")
186
195
  xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
187
196
  indirect_eref_to_xref(e, id)
188
197
  end
189
- else
190
- m << r
198
+ else m << r
191
199
  end
192
200
  end
193
201
  end
@@ -17,45 +17,53 @@ module Asciidoctor
17
17
 
18
18
  def validate_ref_dl(bib, c)
19
19
  id = bib["id"]
20
- id ||= c["id"] unless /^_/.match(c["id"]) # do not accept implicit id
20
+ id ||= c["id"] unless /^_/.match?(c["id"]) # do not accept implicit id
21
21
  unless id
22
- @log.add("Anchors", c, "The following reference is missing an anchor:\n" + c.to_xml)
22
+ @log.add("Anchors", c,
23
+ "The following reference is missing an anchor:\n" + c.to_xml)
23
24
  return
24
25
  end
25
26
  @refids << id
26
- bib["title"] or @log.add("Bibliography", c, "Reference #{id} is missing a title")
27
- bib["docid"] or @log.add("Bibliography", c, "Reference #{id} is missing a document identifier (docid)")
27
+ bib["title"] or
28
+ @log.add("Bibliography", c, "Reference #{id} is missing a title")
29
+ bib["docid"] or
30
+ @log.add("Bibliography", c,
31
+ "Reference #{id} is missing a document identifier (docid)")
28
32
  end
29
33
 
30
34
  def extract_from_p(tag, bib, key)
31
35
  return unless bib[tag]
36
+
32
37
  "<#{key}>#{bib[tag].at('p').children}</#{key}>"
33
38
  end
34
39
 
35
40
  # if the content is a single paragraph, replace it with its children
36
41
  # single links replaced with uri
37
- def p_unwrap(p)
38
- elems = p.elements
42
+ def p_unwrap(para)
43
+ elems = para.elements
39
44
  if elems.size == 1 && elems[0].name == "p"
40
45
  link_unwrap(elems[0]).children.to_xml.strip
41
46
  else
42
- p.to_xml.strip
47
+ para.to_xml.strip
43
48
  end
44
49
  end
45
50
 
46
- def link_unwrap(p)
47
- elems = p.elements
51
+ def link_unwrap(para)
52
+ elems = para.elements
48
53
  if elems.size == 1 && elems[0].name == "link"
49
- p.at("./link").replace(elems[0]["target"].strip)
54
+ para.at("./link").replace(elems[0]["target"].strip)
50
55
  end
51
- p
56
+ para
52
57
  end
53
58
 
54
59
  def dd_bib_extract(dtd)
55
60
  return nil if dtd.children.empty?
61
+
56
62
  dtd.at("./dl") and return dl_bib_extract(dtd)
57
63
  elems = dtd.remove.elements
58
- return p_unwrap(dtd) unless elems.size == 1 && %w(ol ul).include?(elems[0].name)
64
+ return p_unwrap(dtd) unless elems.size == 1 &&
65
+ %w(ol ul).include?(elems[0].name)
66
+
59
67
  ret = []
60
68
  elems[0].xpath("./li").each do |li|
61
69
  ret << p_unwrap(li)
@@ -64,7 +72,7 @@ module Asciidoctor
64
72
  end
65
73
 
66
74
  def add_to_hash(bib, key, val)
67
- Metanorma::Utils::set_nested_value(bib, key.split(/\./), val)
75
+ Metanorma::Utils::set_nested_value(bib, key.split("."), val)
68
76
  end
69
77
 
70
78
  # definition list, with at most one level of unordered lists
@@ -73,14 +81,16 @@ module Asciidoctor
73
81
  bib = {}
74
82
  key = ""
75
83
  dl.xpath("./dt | ./dd").each do |dtd|
76
- dtd.name == "dt" and key = dtd.text.sub(/:+$/, "") or add_to_hash(bib, key, dd_bib_extract(dtd))
84
+ (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) or
85
+ add_to_hash(bib, key, dd_bib_extract(dtd))
77
86
  end
78
87
  c.xpath("./clause").each do |c1|
79
88
  key = c1&.at("./title")&.text&.downcase&.strip
80
89
  next unless %w(contributor relation series).include? key
90
+
81
91
  add_to_hash(bib, key, dl_bib_extract(c1, true))
82
92
  end
83
- if !nested and c.at("./title")
93
+ if !nested && c.at("./title")
84
94
  title = c.at("./title").remove.children.to_xml
85
95
  bib["title"] = [bib["title"]] if bib["title"].is_a? Hash
86
96
  bib["title"] = [bib["title"]] if bib["title"].is_a? String
@@ -21,7 +21,7 @@ module Asciidoctor
21
21
  title = get_or_make_title(node)
22
22
  fn = title.xpath("./fn")
23
23
  fn.each(&:remove)
24
- title.content = text
24
+ title.children = text
25
25
  fn.each { |n| title << n }
26
26
  end
27
27
  end
@@ -82,7 +82,7 @@ module Asciidoctor
82
82
  p.delete("id")
83
83
  p.delete("variant_title")
84
84
  p.xpath("(#{path})[last()]").each do |sect|
85
- ins = sect.at("./title") and ins.next = p or
85
+ (ins = sect.at("./title") and ins.next = p) or
86
86
  sect.children.first.previous = p
87
87
  end
88
88
  end
@@ -6,14 +6,16 @@ module Asciidoctor
6
6
  module Cleanup
7
7
  def termdomain_cleanup(xmldoc)
8
8
  xmldoc.xpath("//p/domain").each do |a|
9
- prev = a.parent.previous
9
+ parent = a.parent
10
+ prev = parent.previous
10
11
  prev.next = a.remove
12
+ parent.text.strip.empty? and parent.remove
11
13
  end
12
14
  end
13
15
 
14
16
  def termdomain1_cleanup(xmldoc)
15
17
  xmldoc.xpath("//term").each do |t|
16
- d = t.xpath("./domain | ./subject | ./usageinfo").last or next
18
+ d = t.xpath("./domain | ./subject").last or next
17
19
  defn = d.at("../definition") and defn.previous = d.remove
18
20
  end
19
21
  end
@@ -21,6 +23,7 @@ module Asciidoctor
21
23
  def termdefinition_cleanup(xmldoc)
22
24
  generate_termdefinitions(xmldoc)
23
25
  split_termdefinitions(xmldoc)
26
+ alternate_termdefinitions(xmldoc)
24
27
  end
25
28
 
26
29
  TERMDEF_BLOCKS =
@@ -40,27 +43,28 @@ module Asciidoctor
40
43
 
41
44
  def split_termdefinitions(xmldoc)
42
45
  xmldoc.xpath("//definition").each do |d|
43
- n = d.children.first
44
- .add_previous_sibling("<nonverbalrepresentation/>").first
45
- v = d.children.first.add_previous_sibling("<verbaldefinition/>").first
46
- nonverb = false
47
- d.elements.each do |e|
48
- nonverb = split_termdefinitions1(e, n, v, nonverb)
46
+ if d.at("./p | ./ol | ./dl | ./ul")
47
+ d.children = "<verbal-definition>#{d.children}</verbal-definition>"
48
+ else
49
+ d.children = "<non-verbal-representation>"\
50
+ "#{d.children}</non-verbal-representation>"
49
51
  end
50
52
  end
51
53
  end
52
54
 
53
- def split_termdefinitions1(elem, nonverbal, verbal, nonverb)
54
- case elem.name
55
- when "nonverbalrepresentation", "verbaldefinition" then return nonverb
56
- when "figure", "table", "formula"
57
- nonverbal << elem.remove
58
- nonverb = true
59
- when "termsource"
60
- (nonverb ? nonverbal : verbal) << elem.remove
61
- else verbal << elem.remove
55
+ def alternate_termdefinitions(xmldoc)
56
+ xmldoc.xpath("//term").each do |t|
57
+ t.xpath("./definition").each do |d|
58
+ d1 = d.next_element or next
59
+ if (v = d.at("./verbal-definition")) &&
60
+ !d.at("./non-verbal-representation") &&
61
+ !d1.at("./verbal-definition") &&
62
+ nv = d1.at("./non-verbal-representation")
63
+ v.next = nv.remove
64
+ d1.remove
65
+ end
66
+ end
62
67
  end
63
- nonverb
64
68
  end
65
69
 
66
70
  def termdocsource_cleanup(xmldoc)
@@ -101,8 +105,8 @@ module Asciidoctor
101
105
  term_termsource_to_designation(xmldoc)
102
106
  term_designation_reorder(xmldoc)
103
107
  termdef_from_termbase(xmldoc)
104
- termdef_stem_cleanup(xmldoc)
105
108
  termdomain_cleanup(xmldoc)
109
+ termdef_stem_cleanup(xmldoc)
106
110
  termdefinition_cleanup(xmldoc)
107
111
  termdomain1_cleanup(xmldoc)
108
112
  termnote_example_cleanup(xmldoc)
@@ -3,16 +3,27 @@ module Asciidoctor
3
3
  module Cleanup
4
4
  def termdef_stem_cleanup(xmldoc)
5
5
  xmldoc.xpath("//term/p/stem").each do |a|
6
- if a.parent.elements.size == 1 # para contains just a stem expression
6
+ if initial_formula(a.parent)
7
7
  parent = a.parent
8
8
  parent.replace("<admitted>#{term_expr(a.to_xml)}</admitted>")
9
9
  end
10
10
  end
11
+ xmldoc.xpath("//term/formula").each do |a|
12
+ if initial_formula(a)
13
+ a.replace("<admitted>#{term_expr(a.children.to_xml)}</admitted>")
14
+ end
15
+ end
11
16
  xmldoc.xpath("//term//expression/name[stem]").each do |n|
12
17
  n.parent.name = "letter-symbol"
13
18
  end
14
19
  end
15
20
 
21
+ def initial_formula(elem)
22
+ elem.elements.size == 1 && # para contains just stem expression
23
+ !elem.at("./preceding-sibling::p | ./preceding-sibling::dl | "\
24
+ "./preceding-sibling::ol | ./preceding-sibling::ul")
25
+ end
26
+
16
27
  # release termdef tags from surrounding paras
17
28
  def termdef_unnest_cleanup(xmldoc)
18
29
  desgn = "//p/admitted | //p/deprecates | //p/preferred | //p//related"
@@ -40,13 +51,18 @@ module Asciidoctor
40
51
  prev.at("./preceding-sibling::preferred").nil?
41
52
 
42
53
  ins = term_element_insert_point(prev)
43
- %w(domain subject usageinfo).each do |a|
54
+ %w(domain subject).each do |a|
44
55
  ins = dl_to_elems(ins, prev.parent, dlist, a)
45
56
  end
46
57
  end
47
58
 
48
59
  def term_dl_to_designation_metadata(prev, dlist)
49
- %w(absent geographicArea).each { |a| dl_to_attrs(related2pref(prev), dlist, a) }
60
+ %w(absent geographic-area).each do |a|
61
+ dl_to_attrs(related2pref(prev), dlist, a)
62
+ end
63
+ %w(field-of-application usage-info).reverse.each do |a|
64
+ dl_to_elems(prev.at("./expression"), prev, dlist, a)
65
+ end
50
66
  end
51
67
 
52
68
  def term_element_insert_point(prev)
@@ -62,7 +78,7 @@ module Asciidoctor
62
78
  %w(language script type isInternational).each do |a|
63
79
  dl_to_attrs(prev, dlist, a)
64
80
  end
65
- %w(abbreviationType pronunciation).reverse.each do |a|
81
+ %w(abbreviation-type pronunciation).reverse.each do |a|
66
82
  dl_to_elems(prev.at("./expression/name"), prev, dlist, a)
67
83
  end
68
84
  g = dlist.at("./dt[text()='grammar']/following::dd//dl") and
@@ -73,20 +89,21 @@ module Asciidoctor
73
89
  def term_dl_to_expression_grammar(prev, dlist)
74
90
  prev.at(".//expression") or return
75
91
  prev.at(".//expression") << "<grammar><sentinel/></grammar>"
76
- %w(gender isPreposition isParticiple isAdjective isAdverb isNoun
77
- grammarValue).reverse.each do |a|
92
+ %w(gender number isPreposition isParticiple isAdjective isAdverb isNoun
93
+ grammar-value).reverse.each do |a|
78
94
  dl_to_elems(prev.at(".//expression/grammar/*"), prev.elements.last,
79
95
  dlist, a)
80
96
  end
81
- term_dl_to_designation_gender(prev)
97
+ term_dl_to_designation_category(prev, "gender")
98
+ term_dl_to_designation_category(prev, "number")
99
+ prev.at(".//expression/grammar/sentinel").remove
82
100
  end
83
101
 
84
- def term_dl_to_designation_gender(prev)
85
- gender = prev.at(".//expression/grammar/gender")
86
- /,/.match?(gender&.text) and
87
- gender.replace(gender.text.split(/,\s*/)
88
- .map { |x| "<gender>#{x}</gender>" }.join)
89
- prev.at(".//expression/grammar/sentinel").remove
102
+ def term_dl_to_designation_category(prev, category)
103
+ cat = prev.at(".//expression/grammar/#{category}")
104
+ /,/.match?(cat&.text) and
105
+ cat.replace(cat.text.split(/,\s*/)
106
+ .map { |x| "<#{category}>#{x}</#{category}>" }.join)
90
107
  end
91
108
 
92
109
  def term_to_letter_symbol(prev, dlist)
@@ -134,7 +151,7 @@ module Asciidoctor
134
151
  def term_termsource_to_designation(xmldoc)
135
152
  xmldoc.xpath("//term/termsource").each do |t|
136
153
  p = t.previous_element
137
- while %w(domain subject usageinfo).include? p&.name
154
+ while %w(domain subject).include? p&.name
138
155
  p = p.previous_element
139
156
  end
140
157
  %w(preferred admitted deprecates related).include?(p&.name) or
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'erb'
3
+ require "erb"
4
4
 
5
5
  module Asciidoctor
6
6
  module Standoc
@@ -9,7 +9,7 @@ module Asciidoctor
9
9
  BLOCK_START_REGEXP = /\{(.+?)\.\*,(.+),(.+)\}/
10
10
  BLOCK_END_REGEXP = /\A\{[A-Z]+\}\z/
11
11
  MARCO_REGEXP = /\[datamodel_attributes_table,([^,]+),?(.+)?\]/
12
- TEMPLATES_PATH = File.expand_path('../views/datamodel', __dir__).freeze
12
+ TEMPLATES_PATH = File.expand_path("../views/datamodel", __dir__).freeze
13
13
  # search document for block `datamodel_attributes_table`
14
14
  # read include derectives that goes after that in block and transform
15
15
  # into yaml2text blocks
@@ -39,16 +39,16 @@ module Asciidoctor
39
39
  def model_representation(model_path)
40
40
  template = File.read(File.join(
41
41
  TEMPLATES_PATH,
42
- 'model_representation.adoc.erb'
43
- ))
44
- file_name = File.basename(model_path).gsub(/\.ya?ml/, '')
42
+ "model_representation.adoc.erb",
43
+ ))
44
+ file_name = File.basename(model_path).gsub(/\.ya?ml/, "")
45
45
  ERB
46
46
  .new(template)
47
47
  .result(binding)
48
48
  end
49
49
 
50
50
  def yaml_relative_path(file_path, document)
51
- directory = File.dirname(document.attributes['docfile'] || '.')
51
+ directory = File.dirname(document.attributes["docfile"] || ".")
52
52
  document.path_resolver.system_path(file_path, directory)
53
53
  end
54
54
  end
@@ -15,14 +15,10 @@ module Asciidoctor
15
15
 
16
16
  def inline_anchor(node)
17
17
  case node.type
18
- when :ref
19
- inline_anchor_ref node
20
- when :xref
21
- inline_anchor_xref node
22
- when :link
23
- inline_anchor_link node
24
- when :bibref
25
- inline_anchor_bibref node
18
+ when :ref then inline_anchor_ref node
19
+ when :xref then inline_anchor_xref node
20
+ when :link then inline_anchor_link node
21
+ when :bibref then inline_anchor_bibref node
26
22
  end
27
23
  end
28
24
 
@@ -50,7 +46,12 @@ module Asciidoctor
50
46
  m.nil? and return { target: t, type: "inline", text: node.text }
51
47
  droploc = m[:drop].nil? && m[:drop2].nil? ? nil : true
52
48
  f = m[:fn].nil? ? "inline" : "footnote"
53
- c = %i[case fn drop drop2].any? { |x| !m[x].nil? } ? m[:text] : node.text
49
+ c = if %i[case fn drop drop2].any? do |x|
50
+ !m[x].nil?
51
+ end
52
+ m[:text]
53
+ else node.text
54
+ end
54
55
  { target: t, type: f, case: m[:case]&.sub(/%$/, ""), droploc: droploc,
55
56
  text: c }
56
57
  end
@@ -58,8 +59,9 @@ module Asciidoctor
58
59
  def inline_anchor_link(node)
59
60
  contents = node.text
60
61
  contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
61
- attributes = { "target": node.target, "alt": node.attr("title"),
62
- "updatetype": node.attr("updatetype") }
62
+ attributes = { target: node.target, alt: node.attr("title"),
63
+ "update-type": node.attr("updatetype") ||
64
+ node.attr("update-type") }
63
65
  noko do |xml|
64
66
  xml.link **attr_code(attributes) do |l|
65
67
  l << contents
@@ -58,7 +58,7 @@
58
58
  <attribute name="alt"/>
59
59
  </optional>
60
60
  <optional>
61
- <attribute name="updatetype">
61
+ <attribute name="update-type">
62
62
  <data type="boolean"/>
63
63
  </attribute>
64
64
  </optional>
@@ -1814,9 +1814,6 @@
1814
1814
  <optional>
1815
1815
  <ref name="termsubject"/>
1816
1816
  </optional>
1817
- <optional>
1818
- <ref name="termusage"/>
1819
- </optional>
1820
1817
  <oneOrMore>
1821
1818
  <ref name="termdefinition"/>
1822
1819
  </oneOrMore>
@@ -1880,17 +1877,37 @@
1880
1877
  </attribute>
1881
1878
  </optional>
1882
1879
  <optional>
1883
- <attribute name="geographicArea"/>
1880
+ <attribute name="geographic-area"/>
1884
1881
  </optional>
1885
1882
  <choice>
1886
1883
  <ref name="expression_designation"/>
1887
1884
  <ref name="letter_symbol_designation"/>
1888
1885
  <ref name="graphical_symbol_designation"/>
1889
1886
  </choice>
1887
+ <optional>
1888
+ <ref name="fieldofapplication"/>
1889
+ </optional>
1890
+ <optional>
1891
+ <ref name="usageinfo"/>
1892
+ </optional>
1890
1893
  <zeroOrMore>
1891
1894
  <ref name="termsource"/>
1892
1895
  </zeroOrMore>
1893
1896
  </define>
1897
+ <define name="fieldofapplication">
1898
+ <element name="field-of-application">
1899
+ <oneOrMore>
1900
+ <ref name="PureTextElement"/>
1901
+ </oneOrMore>
1902
+ </element>
1903
+ </define>
1904
+ <define name="usageinfo">
1905
+ <element name="usage-info">
1906
+ <oneOrMore>
1907
+ <ref name="PureTextElement"/>
1908
+ </oneOrMore>
1909
+ </element>
1910
+ </define>
1894
1911
  <define name="letter_symbol_designation">
1895
1912
  <element name="letter-symbol">
1896
1913
  <optional>
@@ -1946,7 +1963,7 @@
1946
1963
  </zeroOrMore>
1947
1964
  </element>
1948
1965
  <optional>
1949
- <element name="abbreviationType">
1966
+ <element name="abbreviation-type">
1950
1967
  <ref name="AbbreviationType"/>
1951
1968
  </element>
1952
1969
  </optional>
@@ -1956,7 +1973,7 @@
1956
1973
  </element>
1957
1974
  </optional>
1958
1975
  <optional>
1959
- <element name="grammarInfo">
1976
+ <element name="grammar-info">
1960
1977
  <ref name="Grammar"/>
1961
1978
  </element>
1962
1979
  </optional>
@@ -1983,6 +2000,11 @@
1983
2000
  <ref name="GrammarGender"/>
1984
2001
  </element>
1985
2002
  </zeroOrMore>
2003
+ <zeroOrMore>
2004
+ <element name="number">
2005
+ <ref name="GrammarNumber"/>
2006
+ </element>
2007
+ </zeroOrMore>
1986
2008
  <optional>
1987
2009
  <element name="isPreposition">
1988
2010
  <data type="boolean"/>
@@ -2014,7 +2036,7 @@
2014
2036
  </element>
2015
2037
  </optional>
2016
2038
  <zeroOrMore>
2017
- <element name="grammarvalue">
2039
+ <element name="grammar-value">
2018
2040
  <text/>
2019
2041
  </element>
2020
2042
  </zeroOrMore>
@@ -2027,6 +2049,13 @@
2027
2049
  <value>common</value>
2028
2050
  </choice>
2029
2051
  </define>
2052
+ <define name="GrammarNumber">
2053
+ <choice>
2054
+ <value>singular</value>
2055
+ <value>dual</value>
2056
+ <value>plural</value>
2057
+ </choice>
2058
+ </define>
2030
2059
  <define name="termdomain">
2031
2060
  <element name="domain">
2032
2061
  <oneOrMore>
@@ -2041,13 +2070,6 @@
2041
2070
  </oneOrMore>
2042
2071
  </element>
2043
2072
  </define>
2044
- <define name="termusage">
2045
- <element name="usageinfo">
2046
- <oneOrMore>
2047
- <ref name="BasicBlock"/>
2048
- </oneOrMore>
2049
- </element>
2050
- </define>
2051
2073
  <define name="termdefinition">
2052
2074
  <element name="definition">
2053
2075
  <choice>
@@ -2061,13 +2083,16 @@
2061
2083
  </element>
2062
2084
  </define>
2063
2085
  <define name="verbaldefinition">
2064
- <element name="verbaldefinition">
2086
+ <element name="verbal-definition">
2065
2087
  <oneOrMore>
2066
2088
  <choice>
2067
2089
  <ref name="paragraph"/>
2068
2090
  <ref name="dl"/>
2069
2091
  <ref name="ol"/>
2070
2092
  <ref name="ul"/>
2093
+ <ref name="table"/>
2094
+ <ref name="figure"/>
2095
+ <ref name="formula"/>
2071
2096
  </choice>
2072
2097
  </oneOrMore>
2073
2098
  <zeroOrMore>
@@ -2076,7 +2101,7 @@
2076
2101
  </element>
2077
2102
  </define>
2078
2103
  <define name="nonverbalrep">
2079
- <element name="nonverbalrepresentation">
2104
+ <element name="non-verbal-representation">
2080
2105
  <oneOrMore>
2081
2106
  <choice>
2082
2107
  <ref name="table"/>