metanorma-standoc 1.10.8 → 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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/asciidoctor/standoc/base.rb +5 -4
  4. data/lib/asciidoctor/standoc/blocks.rb +1 -1
  5. data/lib/asciidoctor/standoc/cleanup.rb +20 -11
  6. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +28 -20
  7. data/lib/asciidoctor/standoc/cleanup_inline.rb +20 -7
  8. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  9. data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +25 -15
  10. data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
  11. data/lib/asciidoctor/standoc/cleanup_section_names.rb +2 -2
  12. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  13. data/lib/asciidoctor/standoc/cleanup_terms.rb +54 -79
  14. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +179 -0
  15. data/lib/asciidoctor/standoc/cleanup_text.rb +23 -0
  16. data/lib/asciidoctor/standoc/converter.rb +2 -0
  17. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +6 -6
  18. data/lib/asciidoctor/standoc/inline.rb +20 -16
  19. data/lib/asciidoctor/standoc/isodoc.rng +254 -27
  20. data/lib/asciidoctor/standoc/lists.rb +1 -3
  21. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  22. data/lib/asciidoctor/standoc/macros_terms.rb +49 -5
  23. data/lib/asciidoctor/standoc/ref.rb +101 -75
  24. data/lib/asciidoctor/standoc/ref_date_id.rb +30 -1
  25. data/lib/asciidoctor/standoc/ref_sect.rb +42 -24
  26. data/lib/asciidoctor/standoc/reqt.rb +1 -1
  27. data/lib/asciidoctor/standoc/section.rb +14 -13
  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 +25 -16
  32. data/lib/isodoc/html/htmlstyle.css +1 -1
  33. data/lib/isodoc/html/htmlstyle.scss +1 -1
  34. data/lib/metanorma/standoc/version.rb +1 -1
  35. data/metanorma-standoc.gemspec +3 -3
  36. data/spec/asciidoctor/base_spec.rb +4 -3
  37. data/spec/asciidoctor/blocks_spec.rb +202 -21
  38. data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
  39. data/spec/asciidoctor/cleanup_spec.rb +23 -197
  40. data/spec/asciidoctor/cleanup_terms_spec.rb +1205 -0
  41. data/spec/asciidoctor/datamodel/attributes_table_preprocessor_spec.rb +21 -21
  42. data/spec/asciidoctor/datamodel/diagram_preprocessor_spec.rb +16 -16
  43. data/spec/asciidoctor/inline_spec.rb +7 -7
  44. data/spec/asciidoctor/isobib_cache_spec.rb +4 -8
  45. data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
  46. data/spec/asciidoctor/macros_spec.rb +189 -112
  47. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  48. data/spec/asciidoctor/refs_spec.rb +860 -522
  49. data/spec/asciidoctor/section_spec.rb +18 -18
  50. data/spec/asciidoctor/validate_spec.rb +59 -2
  51. data/spec/spec_helper.rb +3 -2
  52. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +180 -180
  53. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  54. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  55. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
  56. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  57. data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
  58. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  59. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  60. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -65
  61. metadata +11 -8
@@ -1,66 +1,81 @@
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
- prev = a.parent.previous
9
+ parent = a.parent
10
+ prev = parent.previous
20
11
  prev.next = a.remove
12
+ parent.text.strip.empty? and parent.remove
21
13
  end
22
14
  end
23
15
 
24
16
  def termdomain1_cleanup(xmldoc)
25
- xmldoc.xpath("//domain").each do |d|
26
- defn = d.at("../definition") and
27
- defn.previous = d.remove
17
+ xmldoc.xpath("//term").each do |t|
18
+ d = t.xpath("./domain | ./subject").last or next
19
+ defn = d.at("../definition") and defn.previous = d.remove
28
20
  end
29
21
  end
30
22
 
31
23
  def termdefinition_cleanup(xmldoc)
24
+ generate_termdefinitions(xmldoc)
25
+ split_termdefinitions(xmldoc)
26
+ alternate_termdefinitions(xmldoc)
27
+ end
28
+
29
+ TERMDEF_BLOCKS =
30
+ "./p | ./ol | ./dl | ./ul | ./figure | ./formula | ./table".freeze
31
+
32
+ def generate_termdefinitions(xmldoc)
32
33
  xmldoc.xpath("//term[not(definition)]").each do |d|
33
- first_child = d.at("./p | ./figure | ./formula") || next
34
+ first_child = d.at(TERMDEF_BLOCKS) || next
34
35
  t = Nokogiri::XML::Element.new("definition", xmldoc)
35
36
  first_child.replace(t)
36
37
  t << first_child.remove
37
- d.xpath("./p | ./figure | ./formula").each { |n| t << n.remove }
38
+ d.xpath(TERMDEF_BLOCKS).each do |n|
39
+ t << n.remove
40
+ end
38
41
  end
39
42
  end
40
43
 
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")
44
+ def split_termdefinitions(xmldoc)
45
+ xmldoc.xpath("//definition").each do |d|
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>"
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" }
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
67
+ end
52
68
  end
53
69
 
54
70
  def termdocsource_cleanup(xmldoc)
55
71
  f = xmldoc.at("//preface | //sections")
56
- xmldoc.xpath("//termdocsource").each do |s|
57
- f.previous = s.remove
58
- end
72
+ xmldoc.xpath("//termdocsource").each { |s| f.previous = s.remove }
59
73
  end
60
74
 
61
75
  def term_children_cleanup(xmldoc)
76
+ xmldoc.xpath("//terms[terms]").each { |t| t.name = "clause" }
62
77
  xmldoc.xpath("//term").each do |t|
63
- %w(termnote termexample termsource).each do |w|
78
+ %w(termnote termexample termsource term).each do |w|
64
79
  t.xpath("./#{w}").each { |n| t << n.remove }
65
80
  end
66
81
  end
@@ -75,69 +90,29 @@ module Asciidoctor
75
90
  end
76
91
 
77
92
  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"
93
+ %w(note example).each do |w|
94
+ xmldoc.xpath("//term#{w}[not(ancestor::term)]").each do |x|
95
+ x.name = w
96
+ end
83
97
  end
84
98
  end
85
99
 
86
100
  def termdef_cleanup(xmldoc)
101
+ termdef_unnest_cleanup(xmldoc)
87
102
  Asciidoctor::Standoc::TermLookupCleanup.new(xmldoc, @log).call
103
+ term_nonverbal_designations(xmldoc)
104
+ term_dl_to_metadata(xmldoc)
105
+ term_termsource_to_designation(xmldoc)
106
+ term_designation_reorder(xmldoc)
88
107
  termdef_from_termbase(xmldoc)
89
- termdef_unnest_cleanup(xmldoc)
90
- termdef_stem_cleanup(xmldoc)
91
108
  termdomain_cleanup(xmldoc)
109
+ termdef_stem_cleanup(xmldoc)
92
110
  termdefinition_cleanup(xmldoc)
93
111
  termdomain1_cleanup(xmldoc)
94
112
  termnote_example_cleanup(xmldoc)
95
- termdef_subclause_cleanup(xmldoc)
96
113
  term_children_cleanup(xmldoc)
97
114
  termdocsource_cleanup(xmldoc)
98
115
  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
116
  end
142
117
  end
143
118
  end
@@ -0,0 +1,179 @@
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 initial_formula(a.parent)
7
+ parent = a.parent
8
+ parent.replace("<admitted>#{term_expr(a.to_xml)}</admitted>")
9
+ end
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
16
+ xmldoc.xpath("//term//expression/name[stem]").each do |n|
17
+ n.parent.name = "letter-symbol"
18
+ end
19
+ end
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
+
27
+ # release termdef tags from surrounding paras
28
+ def termdef_unnest_cleanup(xmldoc)
29
+ desgn = "//p/admitted | //p/deprecates | //p/preferred | //p//related"
30
+ nodes = xmldoc.xpath(desgn)
31
+ while !nodes.empty?
32
+ nodes[0].parent.replace(nodes[0].parent.children)
33
+ nodes = xmldoc.xpath(desgn)
34
+ end
35
+ end
36
+
37
+ def term_dl_to_metadata(xmldoc)
38
+ xmldoc.xpath("//term[dl[@metadata = 'true']]").each do |t|
39
+ t.xpath("./dl[@metadata = 'true']").each do |dl|
40
+ prev = dl_to_designation(dl) or next
41
+ term_dl_to_designation_metadata(prev, dl)
42
+ term_dl_to_term_metadata(prev, dl)
43
+ term_dl_to_expression_metadata(prev, dl)
44
+ dl.remove
45
+ end
46
+ end
47
+ end
48
+
49
+ def term_dl_to_term_metadata(prev, dlist)
50
+ return unless prev.name == "preferred" &&
51
+ prev.at("./preceding-sibling::preferred").nil?
52
+
53
+ ins = term_element_insert_point(prev)
54
+ %w(domain subject).each do |a|
55
+ ins = dl_to_elems(ins, prev.parent, dlist, a)
56
+ end
57
+ end
58
+
59
+ def term_dl_to_designation_metadata(prev, dlist)
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
66
+ end
67
+
68
+ def term_element_insert_point(prev)
69
+ ins = prev
70
+ while %w(preferred admitted deprecates related domain dl)
71
+ .include? ins&.next_element&.name
72
+ ins = ins.next_element
73
+ end
74
+ ins
75
+ end
76
+
77
+ def term_dl_to_expression_metadata(prev, dlist)
78
+ %w(language script type isInternational).each do |a|
79
+ dl_to_attrs(prev, dlist, a)
80
+ end
81
+ %w(abbreviation-type pronunciation).reverse.each do |a|
82
+ dl_to_elems(prev.at("./expression/name"), prev, dlist, a)
83
+ end
84
+ g = dlist.at("./dt[text()='grammar']/following::dd//dl") and
85
+ term_dl_to_expression_grammar(prev, g)
86
+ term_to_letter_symbol(prev, dlist)
87
+ end
88
+
89
+ def term_dl_to_expression_grammar(prev, dlist)
90
+ prev.at(".//expression") or return
91
+ prev.at(".//expression") << "<grammar><sentinel/></grammar>"
92
+ %w(gender number isPreposition isParticiple isAdjective isAdverb isNoun
93
+ grammar-value).reverse.each do |a|
94
+ dl_to_elems(prev.at(".//expression/grammar/*"), prev.elements.last,
95
+ dlist, a)
96
+ end
97
+ term_dl_to_designation_category(prev, "gender")
98
+ term_dl_to_designation_category(prev, "number")
99
+ prev.at(".//expression/grammar/sentinel").remove
100
+ end
101
+
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)
107
+ end
108
+
109
+ def term_to_letter_symbol(prev, dlist)
110
+ ls = dlist.at("./dt[text()='letter-symbol']/following::dd/p")
111
+ return unless ls&.text == "true"
112
+
113
+ prev.at(".//expression").name = "letter-symbol"
114
+ end
115
+
116
+ def dl_to_designation(dlist)
117
+ prev = dlist.previous_element
118
+ unless %w(preferred admitted deprecates related).include? prev&.name
119
+ @log.add("AsciiDoc Input", dlist, "Metadata definition list does "\
120
+ "not follow a term designation")
121
+ return nil
122
+ end
123
+ prev
124
+ end
125
+
126
+ def term_nonverbal_designations(xmldoc)
127
+ xmldoc.xpath("//term/preferred | //term/admitted | //term/deprecates")
128
+ .each do |d|
129
+ d.text.strip.empty? or next
130
+ n = d.next_element
131
+ if %w(formula figure).include?(n&.name)
132
+ term_nonverbal_designations1(d, n)
133
+ else d.at("./expression/name") or
134
+ d.children = term_expr("")
135
+ end
136
+ end
137
+ end
138
+
139
+ def term_nonverbal_designations1(desgn, elem)
140
+ desgn = related2pref(desgn)
141
+ if elem.name == "figure"
142
+ elem.at("./name").remove
143
+ desgn.children =
144
+ "<graphical-symbol>#{elem.remove.to_xml}</graphical-symbol>"
145
+ else
146
+ desgn.children = term_expr(elem.at("./stem").to_xml)
147
+ elem.remove
148
+ end
149
+ end
150
+
151
+ def term_termsource_to_designation(xmldoc)
152
+ xmldoc.xpath("//term/termsource").each do |t|
153
+ p = t.previous_element
154
+ while %w(domain subject).include? p&.name
155
+ p = p.previous_element
156
+ end
157
+ %w(preferred admitted deprecates related).include?(p&.name) or
158
+ next
159
+ related2pref(p) << t.remove
160
+ end
161
+ end
162
+
163
+ def term_designation_reorder(xmldoc)
164
+ xmldoc.xpath("//term").each do |t|
165
+ %w(preferred admitted deprecates related)
166
+ .each_with_object([]) do |tag, m|
167
+ t.xpath("./#{tag}").each { |x| m << x.remove }
168
+ end.reverse.each do |x|
169
+ t.children.first.previous = x
170
+ end
171
+ end
172
+ end
173
+
174
+ def related2pref(elem)
175
+ elem.name == "related" ? elem = elem.at("./preferred") : elem
176
+ end
177
+ end
178
+ end
179
+ 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
@@ -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
@@ -170,8 +172,10 @@ module Asciidoctor
170
172
  else
171
173
  case node.role
172
174
  # 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 }
175
+ when "alt"
176
+ term_designation(xml, node, "admitted", node.text)
177
+ when "deprecated"
178
+ term_designation(xml, node, "deprecates", node.text)
175
179
  when "domain" then xml.domain { |a| a << node.text }
176
180
 
177
181
  when "strike" then xml.strike { |s| s << node.text }
@@ -209,7 +213,7 @@ module Asciidoctor
209
213
  def inline_image(node)
210
214
  noko do |xml|
211
215
  xml.image **image_attributes(node)
212
- end.join("")
216
+ end.join
213
217
  end
214
218
 
215
219
  def inline_indexterm(node)
@@ -218,8 +222,8 @@ module Asciidoctor
218
222
  terms = (node.attr("terms") || [node.text]).map { |x| xml_encode(x) }
219
223
  xml.index do |i|
220
224
  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 }
225
+ a = terms[1] and i.secondary { |x| x << a }
226
+ a = terms[2] and i.tertiary { |x| x << a }
223
227
  end
224
228
  end.join
225
229
  end