metanorma-standoc 1.10.5 → 1.11.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +19 -23
  3. data/Rakefile +1 -1
  4. data/lib/asciidoctor/standoc/base.rb +14 -17
  5. data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
  6. data/lib/asciidoctor/standoc/blocks.rb +26 -23
  7. data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
  8. data/lib/asciidoctor/standoc/cleanup.rb +46 -12
  9. data/lib/asciidoctor/standoc/cleanup_block.rb +5 -70
  10. data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
  11. data/lib/asciidoctor/standoc/cleanup_inline.rb +44 -102
  12. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  13. data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
  14. data/lib/asciidoctor/standoc/cleanup_reqt.rb +51 -33
  15. data/lib/asciidoctor/standoc/cleanup_section_names.rb +5 -5
  16. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  17. data/lib/asciidoctor/standoc/cleanup_table.rb +68 -0
  18. data/lib/asciidoctor/standoc/cleanup_terms.rb +38 -78
  19. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
  20. data/lib/asciidoctor/standoc/cleanup_text.rb +5 -2
  21. data/lib/asciidoctor/standoc/cleanup_xref.rb +107 -0
  22. data/lib/asciidoctor/standoc/converter.rb +15 -0
  23. data/lib/asciidoctor/standoc/inline.rb +7 -5
  24. data/lib/asciidoctor/standoc/isodoc.rng +435 -78
  25. data/lib/asciidoctor/standoc/lists.rb +15 -15
  26. data/lib/asciidoctor/standoc/macros.rb +14 -43
  27. data/lib/asciidoctor/standoc/macros_note.rb +45 -0
  28. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  29. data/lib/asciidoctor/standoc/macros_terms.rb +82 -20
  30. data/lib/asciidoctor/standoc/ref_sect.rb +24 -17
  31. data/lib/asciidoctor/standoc/reqt.rb +2 -2
  32. data/lib/asciidoctor/standoc/reqt.rng +23 -2
  33. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
  34. data/lib/asciidoctor/standoc/terms.rb +21 -3
  35. data/lib/asciidoctor/standoc/utils.rb +36 -23
  36. data/lib/asciidoctor/standoc/validate.rb +45 -27
  37. data/lib/asciidoctor/standoc/validate_section.rb +5 -2
  38. data/lib/metanorma/standoc/version.rb +1 -1
  39. data/metanorma-standoc.gemspec +1 -1
  40. data/spec/asciidoctor/base_spec.rb +4 -36
  41. data/spec/asciidoctor/blank_spec.rb +37 -0
  42. data/spec/asciidoctor/blocks_spec.rb +296 -47
  43. data/spec/asciidoctor/cleanup_blocks_spec.rb +1018 -0
  44. data/spec/asciidoctor/cleanup_sections_spec.rb +153 -12
  45. data/spec/asciidoctor/cleanup_spec.rb +179 -1265
  46. data/spec/asciidoctor/cleanup_terms_spec.rb +990 -0
  47. data/spec/asciidoctor/inline_spec.rb +38 -2
  48. data/spec/asciidoctor/lists_spec.rb +6 -6
  49. data/spec/asciidoctor/macros_plantuml_spec.rb +37 -2
  50. data/spec/asciidoctor/macros_spec.rb +226 -138
  51. data/spec/asciidoctor/refs_spec.rb +4 -26
  52. data/spec/asciidoctor/section_spec.rb +18 -18
  53. data/spec/asciidoctor/validate_spec.rb +109 -1
  54. data/spec/assets/xref_error.adoc +1 -0
  55. data/spec/fixtures/datamodel_description_sections_tree.xml +327 -326
  56. data/spec/spec_helper.rb +6 -7
  57. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +51 -51
  58. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
  59. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  60. data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
  61. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +34 -34
  62. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  63. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  64. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +16 -16
  65. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +51 -49
  66. metadata +13 -5
@@ -1,19 +1,9 @@
1
1
  require_relative "term_lookup_cleanup"
2
+ require_relative "cleanup_terms_designations"
2
3
 
3
4
  module Asciidoctor
4
5
  module Standoc
5
6
  module Cleanup
6
- def termdef_stem_cleanup(xmldoc)
7
- xmldoc.xpath("//term/p/stem").each do |a|
8
- if a.parent.elements.size == 1 # para contains just a stem expression
9
- t = Nokogiri::XML::Element.new("admitted", xmldoc)
10
- parent = a.parent
11
- t.children = a.remove
12
- parent.replace(t)
13
- end
14
- end
15
- end
16
-
17
7
  def termdomain_cleanup(xmldoc)
18
8
  xmldoc.xpath("//p/domain").each do |a|
19
9
  prev = a.parent.previous
@@ -22,43 +12,53 @@ module Asciidoctor
22
12
  end
23
13
 
24
14
  def termdomain1_cleanup(xmldoc)
25
- xmldoc.xpath("//domain").each do |d|
26
- defn = d.at("../definition") and
27
- defn.previous = d.remove
15
+ xmldoc.xpath("//term").each do |t|
16
+ d = t.xpath("./domain | ./subject | ./usageinfo").last or next
17
+ defn = d.at("../definition") and defn.previous = d.remove
28
18
  end
29
19
  end
30
20
 
31
21
  def termdefinition_cleanup(xmldoc)
32
- xmldoc.xpath("//term").each do |d|
33
- first_child = d.at("./p | ./figure | ./formula") || next
22
+ generate_termdefinitions(xmldoc)
23
+ split_termdefinitions(xmldoc)
24
+ end
25
+
26
+ def generate_termdefinitions(xmldoc)
27
+ xmldoc.xpath("//term[not(definition)]").each do |d|
28
+ first_child = d.at("./p | ./figure | ./formula | ./table") || next
34
29
  t = Nokogiri::XML::Element.new("definition", xmldoc)
35
30
  first_child.replace(t)
36
31
  t << first_child.remove
37
- d.xpath("./p | ./figure | ./formula").each { |n| t << n.remove }
32
+ d.xpath("./p | ./figure | ./formula | ./table").each { |n| t << n.remove }
38
33
  end
39
34
  end
40
35
 
41
- def termdef_unnest_cleanup(xmldoc)
42
- # release termdef tags from surrounding paras
43
- nodes = xmldoc.xpath("//p/admitted | //p/deprecates")
44
- while !nodes.empty?
45
- nodes[0].parent.replace(nodes[0].parent.children)
46
- nodes = xmldoc.xpath("//p/admitted | //p/deprecates")
36
+ def split_termdefinitions(xmldoc)
37
+ xmldoc.xpath("//definition").each do |d|
38
+ n = d.children.first.add_previous_sibling("<nonverbalrepresentation/>").first
39
+ v = d.children.first.add_previous_sibling("<verbaldefinition/>").first
40
+ nonverb = false
41
+ d.elements.each do |e|
42
+ case e.name
43
+ when "nonverbalrepresentation", "verbaldefinition" then next
44
+ when "figure", "table", "formula"
45
+ n << e.remove
46
+ nonverb = true
47
+ when "termsource"
48
+ (nonverb ? n : v) << e.remove
49
+ else v << e.remove
50
+ end
51
+ end
47
52
  end
48
53
  end
49
54
 
50
- def termdef_subclause_cleanup(xmldoc)
51
- xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
52
- end
53
-
54
55
  def termdocsource_cleanup(xmldoc)
55
56
  f = xmldoc.at("//preface | //sections")
56
- xmldoc.xpath("//termdocsource").each do |s|
57
- f.previous = s.remove
58
- end
57
+ xmldoc.xpath("//termdocsource").each { |s| f.previous = s.remove }
59
58
  end
60
59
 
61
60
  def term_children_cleanup(xmldoc)
61
+ xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
62
62
  xmldoc.xpath("//term").each do |t|
63
63
  %w(termnote termexample termsource).each do |w|
64
64
  t.xpath("./#{w}").each { |n| t << n.remove }
@@ -75,69 +75,29 @@ module Asciidoctor
75
75
  end
76
76
 
77
77
  def termnote_example_cleanup(xmldoc)
78
- xmldoc.xpath("//termnote[not(ancestor::term)]").each do |x|
79
- x.name = "note"
78
+ %w(note example).each do |w|
79
+ xmldoc.xpath("//term#{w}[not(ancestor::term)]").each do |x|
80
+ x.name = w
80
81
  end
81
- xmldoc.xpath("//termexample[not(ancestor::term)]").each do |x|
82
- x.name = "example"
83
82
  end
84
83
  end
85
84
 
86
85
  def termdef_cleanup(xmldoc)
86
+ termdef_unnest_cleanup(xmldoc)
87
87
  Asciidoctor::Standoc::TermLookupCleanup.new(xmldoc, @log).call
88
+ term_nonverbal_designations(xmldoc)
89
+ term_dl_to_metadata(xmldoc)
90
+ term_termsource_to_designation(xmldoc)
91
+ term_designation_reorder(xmldoc)
88
92
  termdef_from_termbase(xmldoc)
89
- termdef_unnest_cleanup(xmldoc)
90
93
  termdef_stem_cleanup(xmldoc)
91
94
  termdomain_cleanup(xmldoc)
92
95
  termdefinition_cleanup(xmldoc)
93
96
  termdomain1_cleanup(xmldoc)
94
97
  termnote_example_cleanup(xmldoc)
95
- termdef_subclause_cleanup(xmldoc)
96
98
  term_children_cleanup(xmldoc)
97
99
  termdocsource_cleanup(xmldoc)
98
100
  end
99
-
100
- # Indices sort after letter but before any following
101
- # letter (x, x_m, x_1, xa); we use colon to force that sort order.
102
- # Numbers sort *after* letters; we use thorn to force that sort order.
103
- def symbol_key(sym)
104
- key = sym.dup
105
- key.traverse do |n|
106
- next unless n.name == "math"
107
-
108
- n.replace(grkletters(MathML2AsciiMath.m2a(n.to_xml)))
109
- end
110
- ret = Nokogiri::XML(key.to_xml)
111
- HTMLEntities.new.decode(ret.text.downcase)
112
- .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
113
- .gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
114
- .gsub(/[0-9]+/, "þ\\0")
115
- end
116
-
117
- def grkletters(x)
118
- x.gsub(/\b(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\b/i, "&\\1;")
119
- end
120
-
121
- def extract_symbols_list(dlist)
122
- dl_out = []
123
- dlist.xpath("./dt | ./dd").each do |dtd|
124
- if dtd.name == "dt"
125
- dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
126
- else
127
- dl_out.last[:dd] = dtd.remove
128
- end
129
- end
130
- dl_out
131
- end
132
-
133
- def symbols_cleanup(docxml)
134
- docxml.xpath("//definitions/dl").each do |dl|
135
- dl_out = extract_symbols_list(dl)
136
- dl_out.sort! { |a, b| a[:key] <=> b[:key] || a[:dt] <=> b[:dt] }
137
- dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
138
- end
139
- docxml
140
- end
141
101
  end
142
102
  end
143
103
  end
@@ -0,0 +1,162 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ def termdef_stem_cleanup(xmldoc)
5
+ xmldoc.xpath("//term/p/stem").each do |a|
6
+ if a.parent.elements.size == 1 # para contains just a stem expression
7
+ parent = a.parent
8
+ parent.replace("<admitted>#{term_expr(a.to_xml)}</admitted>")
9
+ end
10
+ end
11
+ xmldoc.xpath("//term//expression/name[stem]").each do |n|
12
+ n.parent.name = "letter-symbol"
13
+ end
14
+ end
15
+
16
+ # release termdef tags from surrounding paras
17
+ def termdef_unnest_cleanup(xmldoc)
18
+ desgn = "//p/admitted | //p/deprecates | //p/preferred | //p//related"
19
+ nodes = xmldoc.xpath(desgn)
20
+ while !nodes.empty?
21
+ nodes[0].parent.replace(nodes[0].parent.children)
22
+ nodes = xmldoc.xpath(desgn)
23
+ end
24
+ end
25
+
26
+ def term_dl_to_metadata(xmldoc)
27
+ xmldoc.xpath("//term[dl[@metadata = 'true']]").each do |t|
28
+ t.xpath("./dl[@metadata = 'true']").each do |dl|
29
+ prev = dl_to_designation(dl) or next
30
+ term_dl_to_designation_metadata(prev, dl)
31
+ term_dl_to_term_metadata(prev, dl)
32
+ term_dl_to_expression_metadata(prev, dl)
33
+ dl.remove
34
+ end
35
+ end
36
+ end
37
+
38
+ def term_dl_to_term_metadata(prev, dlist)
39
+ return unless prev.name == "preferred" &&
40
+ prev.at("./preceding-sibling::preferred").nil?
41
+
42
+ ins = term_element_insert_point(prev)
43
+ %w(domain subject usageinfo).each do |a|
44
+ ins = dl_to_elems(ins, prev.parent, dlist, a)
45
+ end
46
+ end
47
+
48
+ def term_dl_to_designation_metadata(prev, dlist)
49
+ %w(absent geographicArea).each { |a| dl_to_attrs(related2pref(prev), dlist, a) }
50
+ end
51
+
52
+ def term_element_insert_point(prev)
53
+ ins = prev
54
+ while %w(preferred admitted deprecates related domain dl)
55
+ .include? ins&.next_element&.name
56
+ ins = ins.next_element
57
+ end
58
+ ins
59
+ end
60
+
61
+ def term_dl_to_expression_metadata(prev, dlist)
62
+ %w(language script type isInternational).each do |a|
63
+ dl_to_attrs(prev, dlist, a)
64
+ end
65
+ %w(abbreviationType pronunciation).reverse.each do |a|
66
+ dl_to_elems(prev.at("./expression/name"), prev, dlist, a)
67
+ end
68
+ g = dlist.at("./dt[text()='grammar']/following::dd//dl") and
69
+ term_dl_to_expression_grammar(prev, g)
70
+ term_to_letter_symbol(prev, dlist)
71
+ end
72
+
73
+ def term_dl_to_expression_grammar(prev, dlist)
74
+ prev.at(".//expression") or return
75
+ prev.at(".//expression") << "<grammar><sentinel/></grammar>"
76
+ %w(gender isPreposition isParticiple isAdjective isAdverb isNoun
77
+ grammarValue).reverse.each do |a|
78
+ dl_to_elems(prev.at(".//expression/grammar/*"), prev.elements.last,
79
+ dlist, a)
80
+ end
81
+ term_dl_to_designation_gender(prev)
82
+ end
83
+
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
90
+ end
91
+
92
+ def term_to_letter_symbol(prev, dlist)
93
+ ls = dlist.at("./dt[text()='letter-symbol']/following::dd/p")
94
+ return unless ls&.text == "true"
95
+
96
+ prev.at(".//expression").name = "letter-symbol"
97
+ end
98
+
99
+ def dl_to_designation(dlist)
100
+ prev = dlist.previous_element
101
+ unless %w(preferred admitted deprecates related).include? prev&.name
102
+ @log.add("AsciiDoc Input", dlist, "Metadata definition list does "\
103
+ "not follow a term designation")
104
+ return nil
105
+ end
106
+ prev
107
+ end
108
+
109
+ def term_nonverbal_designations(xmldoc)
110
+ xmldoc.xpath("//term/preferred | //term/admitted | //term/deprecates")
111
+ .each do |d|
112
+ d.text.strip.empty? or next
113
+ n = d.next_element
114
+ if %w(formula figure).include?(n&.name)
115
+ term_nonverbal_designations1(d, n)
116
+ else d.at("./expression/name") or
117
+ d.children = term_expr("")
118
+ end
119
+ end
120
+ end
121
+
122
+ def term_nonverbal_designations1(desgn, elem)
123
+ desgn = related2pref(desgn)
124
+ if elem.name == "figure"
125
+ elem.at("./name").remove
126
+ desgn.children =
127
+ "<graphical-symbol>#{elem.remove.to_xml}</graphical-symbol>"
128
+ else
129
+ desgn.children = term_expr(elem.at("./stem").to_xml)
130
+ elem.remove
131
+ end
132
+ end
133
+
134
+ def term_termsource_to_designation(xmldoc)
135
+ xmldoc.xpath("//term/termsource").each do |t|
136
+ p = t.previous_element
137
+ while %w(domain subject usageinfo).include? p&.name
138
+ p = p.previous_element
139
+ end
140
+ %w(preferred admitted deprecates related).include?(p&.name) or
141
+ next
142
+ related2pref(p) << t.remove
143
+ end
144
+ end
145
+
146
+ def term_designation_reorder(xmldoc)
147
+ xmldoc.xpath("//term").each do |t|
148
+ %w(preferred admitted deprecates related)
149
+ .each_with_object([]) do |tag, m|
150
+ t.xpath("./#{tag}").each { |x| m << x.remove }
151
+ end.reverse.each do |x|
152
+ t.children.first.previous = x
153
+ end
154
+ end
155
+ end
156
+
157
+ def related2pref(elem)
158
+ elem.name == "related" ? elem = elem.at("./preferred") : elem
159
+ end
160
+ end
161
+ end
162
+ end
@@ -9,7 +9,8 @@ module Asciidoctor
9
9
  </passthrough>}mx) { HTMLEntities.new.decode($1) }
10
10
  end
11
11
 
12
- IGNORE_DUMBQUOTES = "//pre | //pre//* | //tt | //tt//* | "\
12
+ IGNORE_DUMBQUOTES =
13
+ "//pre | //pre//* | //tt | //tt//* | "\
13
14
  "//sourcecode | //sourcecode//* | //bibdata//* | //stem | "\
14
15
  "//stem//* | //figure[@class = 'pseudocode'] | "\
15
16
  "//figure[@class = 'pseudocode']//*".freeze
@@ -32,6 +33,7 @@ module Asciidoctor
32
33
  "[starts-with(., '\"') or starts-with(., \"'\")]]")
33
34
  .each do |x|
34
35
  next if !x.ancestors("pre, tt, sourcecode, stem, figure").empty?
36
+
35
37
  uninterrupt_quotes_around_xml1(x)
36
38
  end
37
39
  end
@@ -40,7 +42,8 @@ module Asciidoctor
40
42
  prev = elem.at(".//preceding::text()[1]") or return
41
43
  /\S$/.match?(prev.text) or return
42
44
  foll = elem.at(".//following::text()[1]")
43
- m = /^(["'][[:punct:]]*)(\s|$)/.match(HTMLEntities.new.decode(foll&.text)) or return
45
+ m = /^(["'][[:punct:]]*)(\s|$)/
46
+ .match(HTMLEntities.new.decode(foll&.text)) or return
44
47
  foll.content = foll.text.sub(/^(["'][[:punct:]]*)/, "")
45
48
  prev.content = "#{prev.text}#{m[1]}"
46
49
  end
@@ -0,0 +1,107 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ # extending localities to cover ISO referencing
5
+ LOCALITY_REGEX_STR = <<~REGEXP.freeze
6
+ ^((?<locality>section|clause|part|paragraph|chapter|page|
7
+ table|annex|figure|example|note|formula|list|time|anchor|
8
+ locality:[^ \\t\\n\\r:,;=]+)(\\s+|=)
9
+ (?<ref>[^"][^ \\t\\n,:-]*|"[^"]+")
10
+ (-(?<to>[^"][^ \\t\\n,:-]*|"[^"]"))?|
11
+ (?<locality2>whole|locality:[^ \\t\\n\\r:,;=]+))(?<punct>[,:;]?)\\s*
12
+ (?<text>.*)$
13
+ REGEXP
14
+ LOCALITY_RE = Regexp.new(LOCALITY_REGEX_STR.gsub(/\s/, ""),
15
+ Regexp::IGNORECASE | Regexp::MULTILINE)
16
+
17
+ def tq(text)
18
+ text.sub(/^"/, "").sub(/"$/, "")
19
+ end
20
+
21
+ def extract_localities(elem)
22
+ f = elem&.children&.first or return
23
+ f.text? or return
24
+ head = f.remove.text
25
+ tail = elem&.children&.remove
26
+ extract_localities1(elem, head)
27
+ tail and elem << tail
28
+ end
29
+
30
+ def extract_localities1(elem, text)
31
+ b = elem.add_child("<localityStack/>").first if LOCALITY_RE.match text
32
+ while (m = LOCALITY_RE.match text)
33
+ ref = m[:ref] ? "<referenceFrom>#{tq m[:ref]}</referenceFrom>" : ""
34
+ refto = m[:to] ? "<referenceTo>#{tq m[:to]}</referenceTo>" : ""
35
+ b.add_child("<locality type='#{locality_label(m)}'>#{ref}#{refto}"\
36
+ "</locality>")
37
+ text = m[:text]
38
+ b = elem.add_child("<localityStack/>").first if m[:punct] == ";"
39
+ end
40
+ elem.add_child(text) if text
41
+ end
42
+
43
+ def locality_label(match)
44
+ loc = match[:locality] || match[:locality2]
45
+ /^locality:/.match?(loc) ? loc : loc&.downcase
46
+ end
47
+
48
+ def xref_to_eref(elem)
49
+ elem["bibitemid"] = elem["target"]
50
+ unless elem["citeas"] = @anchors&.dig(elem["target"], :xref)
51
+ @internal_eref_namespaces.include?(elem["type"]) or
52
+ @log.add("Crossreferences", elem,
53
+ "#{elem['target']} does not have a corresponding "\
54
+ "anchor ID in the bibliography!")
55
+ end
56
+ elem.delete("target")
57
+ extract_localities(elem) unless elem.children.empty?
58
+ end
59
+
60
+ def xref_cleanup(xmldoc)
61
+ xmldoc.xpath("//xref").each do |x|
62
+ /:/.match(x["target"]) and xref_to_internal_eref(x)
63
+ next unless x.name == "xref"
64
+
65
+ if refid? x["target"]
66
+ x.name = "eref"
67
+ xref_to_eref(x)
68
+ else x.delete("type")
69
+ end
70
+ end
71
+ end
72
+
73
+ def xref_to_internal_eref(elem)
74
+ a = elem["target"].split(":", 3)
75
+ unless a.size < 2 || a[0].empty? || a[1].empty?
76
+ elem["target"] = "#{a[0]}_#{a[1]}"
77
+ a.size > 2 and
78
+ elem.children = %{anchor="#{a[2..-1].join}",#{elem&.children&.text}}
79
+ elem["type"] = a[0]
80
+ @internal_eref_namespaces << a[0]
81
+ elem.name = "eref"
82
+ xref_to_eref(elem)
83
+ end
84
+ end
85
+
86
+ def quotesource_cleanup(xmldoc)
87
+ xmldoc.xpath("//quote/source | //terms/source").each do |x|
88
+ xref_to_eref(x)
89
+ end
90
+ end
91
+
92
+ def origin_cleanup(xmldoc)
93
+ xmldoc.xpath("//origin/concept[termref]").each do |x|
94
+ t = x.at("./termref")
95
+ x.replace(t)
96
+ end
97
+ xmldoc.xpath("//origin").each do |x|
98
+ x["citeas"] = @anchors&.dig(x["bibitemid"], :xref) or
99
+ @log.add("Crossreferences", x,
100
+ "#{x['bibitemid']} does not have a corresponding anchor "\
101
+ "ID in the bibliography!")
102
+ extract_localities(x) unless x.children.empty?
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -28,8 +28,10 @@ module Asciidoctor
28
28
  preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
29
29
  preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
30
30
  preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
31
+ inline_macro Asciidoctor::Standoc::PreferredTermInlineMacro
31
32
  inline_macro Asciidoctor::Standoc::AltTermInlineMacro
32
33
  inline_macro Asciidoctor::Standoc::DeprecatedTermInlineMacro
34
+ inline_macro Asciidoctor::Standoc::RelatedTermInlineMacro
33
35
  inline_macro Asciidoctor::Standoc::DomainTermInlineMacro
34
36
  inline_macro Asciidoctor::Standoc::InheritInlineMacro
35
37
  inline_macro Asciidoctor::Standoc::HTML5RubyMacro
@@ -49,7 +51,9 @@ module Asciidoctor
49
51
  inline_macro Asciidoctor::Standoc::FormSelectMacro
50
52
  inline_macro Asciidoctor::Standoc::FormOptionMacro
51
53
  inline_macro Asciidoctor::Standoc::ToCInlineMacro
54
+ inline_macro Asciidoctor::Standoc::PassInlineMacro
52
55
  inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
56
+ inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
53
57
  block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
54
58
  block Asciidoctor::Standoc::ToDoAdmonitionBlock
55
59
  treeprocessor Asciidoctor::Standoc::ToDoInlineAdmonitionBlock
@@ -97,6 +101,17 @@ module Asciidoctor
97
101
  File.join(@libdir, "../../isodoc/html", file)
98
102
  end
99
103
 
104
+ def content(node)
105
+ node.content
106
+ end
107
+
108
+ def skip(node, name = nil)
109
+ name = name || node.node_name
110
+ w = "converter missing for #{name} node in Metanorma backend"
111
+ @log.add("AsciiDoc Input", node, w)
112
+ nil
113
+ end
114
+
100
115
  alias_method :embedded, :content
101
116
  alias_method :verse, :quote
102
117
  alias_method :audio, :skip
@@ -170,8 +170,10 @@ module Asciidoctor
170
170
  else
171
171
  case node.role
172
172
  # the following three are legacy, they are now handled by macros
173
- when "alt" then xml.admitted { |a| a << node.text }
174
- when "deprecated" then xml.deprecates { |a| a << node.text }
173
+ when "alt"
174
+ term_designation(xml, node, "admitted", node.text)
175
+ when "deprecated"
176
+ term_designation(xml, node, "deprecates", node.text)
175
177
  when "domain" then xml.domain { |a| a << node.text }
176
178
 
177
179
  when "strike" then xml.strike { |s| s << node.text }
@@ -209,7 +211,7 @@ module Asciidoctor
209
211
  def inline_image(node)
210
212
  noko do |xml|
211
213
  xml.image **image_attributes(node)
212
- end.join("")
214
+ end.join
213
215
  end
214
216
 
215
217
  def inline_indexterm(node)
@@ -218,8 +220,8 @@ module Asciidoctor
218
220
  terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
219
221
  xml.index do |i|
220
222
  i.primary { |x| x << terms[0] }
221
- a = terms.dig(1) and i.secondary { |x| x << a }
222
- a = terms.dig(2) and i.tertiary { |x| x << a }
223
+ a = terms[1] and i.secondary { |x| x << a }
224
+ a = terms[2] and i.tertiary { |x| x << a }
223
225
  end
224
226
  end.join
225
227
  end