metanorma-standoc 1.10.7 → 1.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) 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 +7 -4
  5. data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
  6. data/lib/asciidoctor/standoc/blocks.rb +23 -23
  7. data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
  8. data/lib/asciidoctor/standoc/cleanup.rb +20 -11
  9. data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +45 -7
  11. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  12. data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
  13. data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
  14. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  15. data/lib/asciidoctor/standoc/cleanup_terms.rb +48 -77
  16. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
  17. data/lib/asciidoctor/standoc/cleanup_text.rb +23 -0
  18. data/lib/asciidoctor/standoc/converter.rb +2 -0
  19. data/lib/asciidoctor/standoc/inline.rb +7 -5
  20. data/lib/asciidoctor/standoc/isodoc.rng +420 -76
  21. data/lib/asciidoctor/standoc/lists.rb +14 -16
  22. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  23. data/lib/asciidoctor/standoc/macros_terms.rb +55 -8
  24. data/lib/asciidoctor/standoc/ref.rb +1 -1
  25. data/lib/asciidoctor/standoc/ref_sect.rb +26 -18
  26. data/lib/asciidoctor/standoc/reqt.rng +23 -2
  27. data/lib/asciidoctor/standoc/section.rb +13 -12
  28. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
  29. data/lib/asciidoctor/standoc/terms.rb +12 -2
  30. data/lib/asciidoctor/standoc/utils.rb +36 -23
  31. data/lib/asciidoctor/standoc/validate.rb +45 -27
  32. data/lib/asciidoctor/standoc/validate_section.rb +5 -2
  33. data/lib/metanorma/standoc/version.rb +1 -1
  34. data/metanorma-standoc.gemspec +1 -1
  35. data/spec/asciidoctor/base_spec.rb +4 -3
  36. data/spec/asciidoctor/blocks_spec.rb +230 -49
  37. data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
  38. data/spec/asciidoctor/cleanup_spec.rb +105 -286
  39. data/spec/asciidoctor/cleanup_terms_spec.rb +1020 -0
  40. data/spec/asciidoctor/inline_spec.rb +2 -2
  41. data/spec/asciidoctor/lists_spec.rb +6 -6
  42. data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
  43. data/spec/asciidoctor/macros_spec.rb +190 -113
  44. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  45. data/spec/asciidoctor/refs_spec.rb +268 -108
  46. data/spec/asciidoctor/section_spec.rb +18 -18
  47. data/spec/asciidoctor/validate_spec.rb +87 -2
  48. data/spec/spec_helper.rb +8 -8
  49. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -50
  50. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  51. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  52. data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
  53. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +31 -31
  54. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  55. data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
  56. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  57. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
  58. metadata +8 -5
@@ -0,0 +1,48 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ # Indices sort after letter but before any following
5
+ # letter (x, x_m, x_1, xa); we use colon to force that sort order.
6
+ # Numbers sort *after* letters; we use thorn to force that sort order.
7
+ def symbol_key(sym)
8
+ key = sym.dup
9
+ key.traverse do |n|
10
+ n.name == "math" and
11
+ n.replace(grkletters(MathML2AsciiMath.m2a(n.to_xml)))
12
+ end
13
+ ret = Nokogiri::XML(key.to_xml)
14
+ HTMLEntities.new.decode(ret.text.downcase)
15
+ .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
16
+ .gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
17
+ .gsub(/[0-9]+/, "þ\\0")
18
+ end
19
+
20
+ def grkletters(text)
21
+ text.gsub(/\b(alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|
22
+ lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|
23
+ psi|omega)\b/xi, "&\\1;")
24
+ end
25
+
26
+ def extract_symbols_list(dlist)
27
+ dl_out = []
28
+ dlist.xpath("./dt | ./dd").each do |dtd|
29
+ if dtd.name == "dt"
30
+ dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
31
+ else
32
+ dl_out.last[:dd] = dtd.remove
33
+ end
34
+ end
35
+ dl_out
36
+ end
37
+
38
+ def symbols_cleanup(docxml)
39
+ docxml.xpath("//definitions/dl").each do |dl|
40
+ dl_out = extract_symbols_list(dl)
41
+ dl_out.sort! { |a, b| a[:key] <=> b[:key] || a[:dt] <=> b[:dt] }
42
+ dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
43
+ end
44
+ docxml
45
+ end
46
+ end
47
+ end
48
+ end
@@ -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,45 +12,66 @@ 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)
22
+ generate_termdefinitions(xmldoc)
23
+ split_termdefinitions(xmldoc)
24
+ end
25
+
26
+ TERMDEF_BLOCKS =
27
+ "./p | ./ol | ./dl | ./ul | ./figure | ./formula | ./table".freeze
28
+
29
+ def generate_termdefinitions(xmldoc)
32
30
  xmldoc.xpath("//term[not(definition)]").each do |d|
33
- first_child = d.at("./p | ./figure | ./formula") || next
31
+ first_child = d.at(TERMDEF_BLOCKS) || next
34
32
  t = Nokogiri::XML::Element.new("definition", xmldoc)
35
33
  first_child.replace(t)
36
34
  t << first_child.remove
37
- d.xpath("./p | ./figure | ./formula").each { |n| t << n.remove }
35
+ d.xpath(TERMDEF_BLOCKS).each do |n|
36
+ t << n.remove
37
+ end
38
38
  end
39
39
  end
40
40
 
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")
41
+ def split_termdefinitions(xmldoc)
42
+ 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)
49
+ end
47
50
  end
48
51
  end
49
52
 
50
- def termdef_subclause_cleanup(xmldoc)
51
- xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
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
62
+ end
63
+ nonverb
52
64
  end
53
65
 
54
66
  def termdocsource_cleanup(xmldoc)
55
67
  f = xmldoc.at("//preface | //sections")
56
- xmldoc.xpath("//termdocsource").each do |s|
57
- f.previous = s.remove
58
- end
68
+ xmldoc.xpath("//termdocsource").each { |s| f.previous = s.remove }
59
69
  end
60
70
 
61
71
  def term_children_cleanup(xmldoc)
72
+ xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
62
73
  xmldoc.xpath("//term").each do |t|
63
- %w(termnote termexample termsource).each do |w|
74
+ %w(termnote termexample termsource term).each do |w|
64
75
  t.xpath("./#{w}").each { |n| t << n.remove }
65
76
  end
66
77
  end
@@ -75,69 +86,29 @@ module Asciidoctor
75
86
  end
76
87
 
77
88
  def termnote_example_cleanup(xmldoc)
78
- xmldoc.xpath("//termnote[not(ancestor::term)]").each do |x|
79
- x.name = "note"
80
- end
81
- xmldoc.xpath("//termexample[not(ancestor::term)]").each do |x|
82
- x.name = "example"
89
+ %w(note example).each do |w|
90
+ xmldoc.xpath("//term#{w}[not(ancestor::term)]").each do |x|
91
+ x.name = w
92
+ end
83
93
  end
84
94
  end
85
95
 
86
96
  def termdef_cleanup(xmldoc)
97
+ termdef_unnest_cleanup(xmldoc)
87
98
  Asciidoctor::Standoc::TermLookupCleanup.new(xmldoc, @log).call
99
+ term_nonverbal_designations(xmldoc)
100
+ term_dl_to_metadata(xmldoc)
101
+ term_termsource_to_designation(xmldoc)
102
+ term_designation_reorder(xmldoc)
88
103
  termdef_from_termbase(xmldoc)
89
- termdef_unnest_cleanup(xmldoc)
90
104
  termdef_stem_cleanup(xmldoc)
91
105
  termdomain_cleanup(xmldoc)
92
106
  termdefinition_cleanup(xmldoc)
93
107
  termdomain1_cleanup(xmldoc)
94
108
  termnote_example_cleanup(xmldoc)
95
- termdef_subclause_cleanup(xmldoc)
96
109
  term_children_cleanup(xmldoc)
97
110
  termdocsource_cleanup(xmldoc)
98
111
  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
112
  end
142
113
  end
143
114
  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
@@ -28,6 +28,7 @@ module Asciidoctor
28
28
  end
29
29
 
30
30
  # "abc<tag/>", def => "abc",<tag/> def
31
+ =begin
31
32
  def uninterrupt_quotes_around_xml(xmldoc)
32
33
  xmldoc.xpath("//*[following::text()[1]"\
33
34
  "[starts-with(., '\"') or starts-with(., \"'\")]]")
@@ -37,6 +38,28 @@ module Asciidoctor
37
38
  uninterrupt_quotes_around_xml1(x)
38
39
  end
39
40
  end
41
+ =end
42
+ =begin
43
+ def uninterrupt_quotes_around_xml(xmldoc)
44
+ xmldoc.traverse do |n|
45
+ next unless n.element? && n&.next&.text? &&
46
+ n.ancestors("pre, tt, sourcecode, stem, figure").empty?
47
+ next unless /^['"]/.match?(n.next.text)
48
+
49
+ uninterrupt_quotes_around_xml1(n)
50
+ end
51
+ end
52
+ =end
53
+ def uninterrupt_quotes_around_xml(xmldoc)
54
+ xmldoc.traverse do |n|
55
+ next unless n.text? && n&.previous&.element?
56
+ next unless /^['"]/.match?(n.text)
57
+ next unless n.previous.ancestors("pre, tt, sourcecode, stem, figure")
58
+ .empty?
59
+
60
+ uninterrupt_quotes_around_xml1(n.previous)
61
+ end
62
+ end
40
63
 
41
64
  def uninterrupt_quotes_around_xml1(elem)
42
65
  prev = elem.at(".//preceding::text()[1]") or return
@@ -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
@@ -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