metanorma-standoc 1.9.2 → 1.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -13
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -6
  5. data/lib/asciidoctor/standoc/base.rb +3 -1
  6. data/lib/asciidoctor/standoc/biblio.rng +1 -0
  7. data/lib/asciidoctor/standoc/blocks.rb +1 -1
  8. data/lib/asciidoctor/standoc/cleanup.rb +34 -15
  9. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -1
  10. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +2 -2
  11. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +0 -1
  12. data/lib/asciidoctor/standoc/cleanup_inline.rb +117 -77
  13. data/lib/asciidoctor/standoc/cleanup_maths.rb +0 -1
  14. data/lib/asciidoctor/standoc/cleanup_ref.rb +7 -0
  15. data/lib/asciidoctor/standoc/cleanup_section.rb +73 -137
  16. data/lib/asciidoctor/standoc/cleanup_section_names.rb +75 -0
  17. data/lib/asciidoctor/standoc/cleanup_terms.rb +19 -18
  18. data/lib/asciidoctor/standoc/converter.rb +1 -0
  19. data/lib/asciidoctor/standoc/front.rb +1 -2
  20. data/lib/asciidoctor/standoc/front_contributor.rb +66 -42
  21. data/lib/asciidoctor/standoc/inline.rb +45 -34
  22. data/lib/asciidoctor/standoc/isodoc.rng +66 -10
  23. data/lib/asciidoctor/standoc/macros.rb +7 -5
  24. data/lib/asciidoctor/standoc/macros_plantuml.rb +21 -23
  25. data/lib/asciidoctor/standoc/macros_terms.rb +60 -23
  26. data/lib/asciidoctor/standoc/section.rb +19 -12
  27. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +87 -33
  28. data/lib/asciidoctor/standoc/terms.rb +1 -1
  29. data/lib/asciidoctor/standoc/utils.rb +0 -1
  30. data/lib/asciidoctor/standoc/validate.rb +22 -8
  31. data/lib/isodoc/html/html_titlepage.html +81 -0
  32. data/lib/isodoc/html/htmlstyle.css +983 -0
  33. data/lib/isodoc/html/htmlstyle.scss +714 -0
  34. data/lib/isodoc/html/scripts.html +71 -0
  35. data/lib/metanorma/standoc/processor.rb +16 -7
  36. data/lib/metanorma/standoc/version.rb +1 -1
  37. data/metanorma-standoc.gemspec +3 -3
  38. data/spec/asciidoctor/base_spec.rb +697 -557
  39. data/spec/asciidoctor/blocks_spec.rb +6 -8
  40. data/spec/asciidoctor/cleanup_sections_spec.rb +14 -14
  41. data/spec/asciidoctor/cleanup_spec.rb +899 -688
  42. data/spec/asciidoctor/inline_spec.rb +62 -14
  43. data/spec/asciidoctor/isobib_cache_spec.rb +4 -6
  44. data/spec/asciidoctor/lists_spec.rb +149 -137
  45. data/spec/asciidoctor/macros_json2text_spec.rb +1 -1
  46. data/spec/asciidoctor/macros_plantuml_spec.rb +8 -8
  47. data/spec/asciidoctor/macros_spec.rb +646 -169
  48. data/spec/asciidoctor/refs_dl_spec.rb +4 -4
  49. data/spec/asciidoctor/refs_spec.rb +1527 -1532
  50. data/spec/asciidoctor/section_spec.rb +58 -22
  51. data/spec/asciidoctor/table_spec.rb +6 -6
  52. data/spec/asciidoctor/validate_spec.rb +352 -304
  53. data/spec/spec_helper.rb +2 -0
  54. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +49 -49
  55. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  56. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
  57. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  58. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -14
  59. data/spec/vcr_cassettes/isobib_get_124.yml +14 -14
  60. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  61. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +44 -44
  62. metadata +12 -11
  63. data/lib/liquid/custom_blocks/key_iterator.rb +0 -21
  64. data/lib/liquid/custom_blocks/with_json_nested_context.rb +0 -18
  65. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +0 -19
  66. data/lib/liquid/custom_filters/values.rb +0 -7
@@ -1,6 +1,5 @@
1
1
  require "nokogiri"
2
2
  require "pathname"
3
- require "open-uri"
4
3
  require "html2doc"
5
4
  require "asciimath2unitsml"
6
5
  require_relative "./cleanup_block"
@@ -149,7 +149,14 @@ module Asciidoctor
149
149
  end
150
150
  end
151
151
 
152
+ def bibitem_nested_id(xmldoc)
153
+ xmldoc.xpath("//bibitem//bibitem").each do |b|
154
+ b.delete("id")
155
+ end
156
+ end
157
+
152
158
  def bibitem_cleanup(xmldoc)
159
+ bibitem_nested_id(xmldoc)
153
160
  ref_dl_cleanup(xmldoc)
154
161
  fetch_local_bibitem(xmldoc)
155
162
  end
@@ -1,38 +1,38 @@
1
1
  require "date"
2
2
  require "htmlentities"
3
3
  require "json"
4
- require "open-uri"
5
4
  require "mathml2asciimath"
5
+ require_relative "cleanup_section_names"
6
6
 
7
7
  module Asciidoctor
8
8
  module Standoc
9
9
  module Cleanup
10
- def make_preface(x, s)
11
- if x.at("//foreword | //introduction | //acknowledgements | "\
10
+ def make_preface(xml, sect)
11
+ if xml.at("//foreword | //introduction | //acknowledgements | "\
12
12
  "//*[@preface]")
13
- preface = s.add_previous_sibling("<preface/>").first
14
- f = x.at("//foreword") and preface.add_child f.remove
15
- f = x.at("//introduction") and preface.add_child f.remove
16
- move_clauses_into_preface(x, preface)
17
- f = x.at("//acknowledgements") and preface.add_child f.remove
13
+ preface = sect.add_previous_sibling("<preface/>").first
14
+ f = xml.at("//foreword") and preface.add_child f.remove
15
+ f = xml.at("//introduction") and preface.add_child f.remove
16
+ move_clauses_into_preface(xml, preface)
17
+ f = xml.at("//acknowledgements") and preface.add_child f.remove
18
18
  end
19
- make_abstract(x, s)
19
+ make_abstract(xml, sect)
20
20
  end
21
21
 
22
- def move_clauses_into_preface(x, preface)
23
- x.xpath("//*[@preface]").each do |c|
22
+ def move_clauses_into_preface(xml, preface)
23
+ xml.xpath("//*[@preface]").each do |c|
24
24
  c.delete("preface")
25
25
  preface.add_child c.remove
26
26
  end
27
27
  end
28
28
 
29
- def make_abstract(x, s)
30
- if x.at("//abstract[not(ancestor::bibitem)]")
31
- preface = s.at("//preface") ||
32
- s.add_previous_sibling("<preface/>").first
33
- abstract = x.at("//abstract[not(ancestor::bibitem)]").remove
29
+ def make_abstract(xml, sect)
30
+ if xml.at("//abstract[not(ancestor::bibitem)]")
31
+ preface = sect.at("//preface") ||
32
+ sect.add_previous_sibling("<preface/>").first
33
+ abstract = xml.at("//abstract[not(ancestor::bibitem)]").remove
34
34
  preface.prepend_child abstract.remove
35
- bibabstract = bibabstract_location(x)
35
+ bibabstract = bibabstract_location(xml)
36
36
  dupabstract = abstract.dup
37
37
  dupabstract.traverse { |n| n.remove_attribute("id") }
38
38
  dupabstract.remove_attribute("language")
@@ -42,40 +42,43 @@ module Asciidoctor
42
42
  end
43
43
  end
44
44
 
45
- def bibabstract_location(x)
46
- x.at("//bibdata/script") || x.at("//bibdata/language") ||
47
- x.at("//bibdata/contributor[not(following-sibling::contributor)]") ||
48
- x.at("//bibdata/date[not(following-sibling::date)]") ||
49
- x.at("//docnumber") ||
50
- x.at("//bibdata/docidentifier"\
51
- "[not(following-sibling::docidentifier)]") ||
52
- x.at("//bibdata/uri[not(following-sibling::uri)]") ||
53
- x.at("//bibdata/title[not(following-sibling::title)]")
45
+ def bibabstract_location(xml)
46
+ xml.at("//bibdata/script") || xml.at("//bibdata/language") ||
47
+ xml.at("//bibdata/contributor[not(following-sibling::contributor)]") ||
48
+ xml.at("//bibdata/date[not(following-sibling::date)]") ||
49
+ xml.at("//docnumber") ||
50
+ xml.at("//bibdata/docidentifier"\
51
+ "[not(following-sibling::docidentifier)]") ||
52
+ xml.at("//bibdata/uri[not(following-sibling::uri)]") ||
53
+ xml.at("//bibdata/title[not(following-sibling::title)]")
54
54
  end
55
55
 
56
- def make_bibliography(x, s)
57
- if x.at("//sections/references")
58
- biblio = s.add_next_sibling("<bibliography/>").first
59
- x.xpath("//sections/references").each do |r|
56
+ def make_bibliography(xml, sect)
57
+ if xml.at("//sections/references")
58
+ biblio = sect.add_next_sibling("<bibliography/>").first
59
+ xml.xpath("//sections/references").each do |r|
60
60
  biblio.add_child r.remove
61
61
  end
62
62
  end
63
63
  end
64
64
 
65
- def make_indexsect(x, s)
66
- x.xpath("//sections/indexsect").reverse_each { |r| s.next = r.remove }
65
+ def make_indexsect(xml, sect)
66
+ xml.xpath("//sections/indexsect").reverse_each do |r|
67
+ sect.next = r.remove
68
+ end
67
69
  end
68
70
 
69
- def sections_order_cleanup(x)
70
- s = x.at("//sections")
71
- make_preface(x, s)
72
- make_annexes(x)
73
- make_indexsect(x, s)
74
- make_bibliography(x, s)
75
- x.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
71
+ def sections_order_cleanup(xml)
72
+ s = xml.at("//sections")
73
+ make_preface(xml, s)
74
+ make_annexes(xml)
75
+ make_indexsect(xml, s)
76
+ make_bibliography(xml, s)
77
+ xml.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
76
78
  end
77
- def make_annexes(x)
78
- x.xpath("//*[@annex]").each do |y|
79
+
80
+ def make_annexes(xml)
81
+ xml.xpath("//*[@annex]").each do |y|
79
82
  y.delete("annex")
80
83
  next if y.name == "annex" || !y.ancestors("annex").empty?
81
84
 
@@ -87,60 +90,61 @@ module Asciidoctor
87
90
  end
88
91
  end
89
92
 
90
- def maxlevel(x)
93
+ def maxlevel(xml)
91
94
  max = 5
92
- x.xpath("//clause[@level]").each do |c|
95
+ xml.xpath("//clause[@level]").each do |c|
93
96
  max = c["level"].to_i if max < c["level"].to_i
94
97
  end
95
98
  max
96
99
  end
97
100
 
98
- def sections_level_cleanup(x)
99
- m = maxlevel(x)
101
+ def sections_level_cleanup(xml)
102
+ m = maxlevel(xml)
100
103
  return if m < 6
101
104
 
102
105
  m.downto(6).each do |l|
103
- x.xpath("//clause[@level = '#{l}']").each do |c|
106
+ xml.xpath("//clause[@level = '#{l}']").each do |c|
104
107
  c.delete("level")
105
108
  c.previous_element << c.remove
106
109
  end
107
110
  end
108
111
  end
109
112
 
110
- def sections_cleanup(x)
111
- sections_order_cleanup(x)
112
- sections_level_cleanup(x)
113
- sections_names_cleanup(x)
114
- change_clauses(x)
113
+ def sections_cleanup(xml)
114
+ sections_order_cleanup(xml)
115
+ sections_level_cleanup(xml)
116
+ sections_names_cleanup(xml)
117
+ change_clauses(xml)
115
118
  end
116
119
 
117
- def obligations_cleanup(x)
118
- obligations_cleanup_info(x)
119
- obligations_cleanup_norm(x)
120
- obligations_cleanup_inherit(x)
120
+ def obligations_cleanup(xml)
121
+ obligations_cleanup_info(xml)
122
+ obligations_cleanup_norm(xml)
123
+ obligations_cleanup_inherit(xml)
121
124
  end
122
125
 
123
- def obligations_cleanup_info(x)
124
- (s = x.at("//foreword")) && s["obligation"] = "informative"
125
- (s = x.at("//introduction")) && s["obligation"] = "informative"
126
- (s = x.at("//acknowledgements")) && s["obligation"] = "informative"
127
- x.xpath("//references").each { |r| r["obligation"] = "informative" }
128
- x.xpath("//preface//clause").each do |r|
126
+ def obligations_cleanup_info(xml)
127
+ s = xml.at("//foreword") and s["obligation"] = "informative"
128
+ s = xml.at("//introduction") and s["obligation"] = "informative"
129
+ s = xml.at("//acknowledgements") and s["obligation"] = "informative"
130
+ xml.xpath("//references").each { |r| r["obligation"] = "informative" }
131
+ xml.xpath("//preface//clause").each do |r|
129
132
  r["obligation"] = "informative"
130
133
  end
131
134
  end
132
135
 
133
- def obligations_cleanup_norm(x)
134
- (s = x.at("//clause[@type = 'scope']")) && s["obligation"] = "normative"
135
- x.xpath("//terms").each { |r| r["obligation"] = "normative" }
136
- x.xpath("//definitions").each { |r| r["obligation"] = "normative" }
136
+ def obligations_cleanup_norm(xml)
137
+ s = xml.at("//clause[@type = 'scope']") and
138
+ s["obligation"] = "normative"
139
+ xml.xpath("//terms").each { |r| r["obligation"] = "normative" }
140
+ xml.xpath("//definitions").each { |r| r["obligation"] = "normative" }
137
141
  end
138
142
 
139
- def obligations_cleanup_inherit(x)
140
- x.xpath("//annex | //clause[not(ancestor::boilerplate)]").each do |r|
143
+ def obligations_cleanup_inherit(xml)
144
+ xml.xpath("//annex | //clause[not(ancestor::boilerplate)]").each do |r|
141
145
  r["obligation"] = "normative" unless r["obligation"]
142
146
  end
143
- x.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
147
+ xml.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
144
148
  o = r&.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
145
149
  end
146
150
  end
@@ -150,7 +154,7 @@ module Asciidoctor
150
154
  sections_clausebefore_cleanup(xmldoc)
151
155
  end
152
156
 
153
- def preface_clausebefore_cleanup(xmldoc)
157
+ def preface_clausebefore_cleanup(xmldoc)
154
158
  return unless xmldoc.at("//preface")
155
159
 
156
160
  unless ins = xmldoc.at("//preface").children.first
@@ -175,74 +179,6 @@ module Asciidoctor
175
179
  ins.previous = x.remove
176
180
  end
177
181
  end
178
-
179
- def get_or_make_title(node)
180
- unless node.at("./title")
181
- if node.children.empty?
182
- node << "<title/>"
183
- else
184
- node.children.first.previous = "<title/>"
185
- end
186
- end
187
- node.at("./title")
188
- end
189
-
190
- def replace_title(doc, xpath, text, first = false)
191
- return unless text
192
-
193
- doc.xpath(xpath).each_with_index do |node, i|
194
- next if first && !i.zero?
195
-
196
- title = get_or_make_title(node)
197
- fn = title.xpath("./fn")
198
- fn.each { |n| n.remove }
199
- title.content = text
200
- fn.each { |n| title << n }
201
- end
202
- end
203
-
204
- def sections_names_cleanup(xml)
205
- replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
206
- replace_title(xml, "//preface//abstract", @i18n&.abstract)
207
- replace_title(xml, "//foreword", @i18n&.foreword)
208
- replace_title(xml, "//introduction", @i18n&.introduction)
209
- replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
210
- section_names_refs_cleanup(xml)
211
- section_names_terms_cleanup(xml)
212
- end
213
-
214
- def section_names_refs_cleanup(xml)
215
- replace_title(xml, "//references[@normative = 'true']",
216
- @i18n&.normref, true)
217
- replace_title(xml, "//references[@normative = 'false']",
218
- @i18n&.bibliography, true)
219
- end
220
-
221
- NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
222
- SYMABBR = "[.//definitions[@type = 'symbols']"\
223
- "[@type = 'abbreviated_terms']]".freeze
224
- SYMnoABBR = "[.//definitions[@type = 'symbols']"\
225
- "[not(@type = 'abbreviated_terms')]]".freeze
226
- ABBRnoSYM = "[.//definitions[not(@type = 'symbols')]"\
227
- "[@type = 'abbreviated_terms']]".freeze
228
-
229
- def section_names_terms_cleanup(x)
230
- replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
231
- replace_title(x, "//definitions[@type = 'abbreviated_terms']",
232
- @i18n&.abbrev)
233
- replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
234
- replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
235
- @i18n&.termsdefsymbols, true)
236
- replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
237
- @i18n&.termsdefabbrev, true)
238
- replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
239
- @i18n&.termsdefsymbolsabbrev, true)
240
- replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
241
- @i18n&.termsdefsymbolsabbrev, true)
242
- replace_title(
243
- x, "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
244
- @i18n&.termsdef, true)
245
- end
246
182
  end
247
183
  end
248
184
  end
@@ -0,0 +1,75 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ def get_or_make_title(node)
5
+ unless node.at("./title")
6
+ if node.children.empty?
7
+ node << "<title/>"
8
+ else
9
+ node.children.first.previous = "<title/>"
10
+ end
11
+ end
12
+ node.at("./title")
13
+ end
14
+
15
+ def replace_title(doc, xpath, text, first = false)
16
+ return unless text
17
+
18
+ doc.xpath(xpath).each_with_index do |node, i|
19
+ next if first && !i.zero?
20
+
21
+ title = get_or_make_title(node)
22
+ fn = title.xpath("./fn")
23
+ fn.each(&:remove)
24
+ title.content = text
25
+ fn.each { |n| title << n }
26
+ end
27
+ end
28
+
29
+ def sections_names_cleanup(xml)
30
+ replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
31
+ replace_title(xml, "//preface//abstract", @i18n&.abstract)
32
+ replace_title(xml, "//foreword", @i18n&.foreword)
33
+ replace_title(xml, "//introduction", @i18n&.introduction)
34
+ replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
35
+ section_names_refs_cleanup(xml)
36
+ section_names_terms_cleanup(xml)
37
+ end
38
+
39
+ def section_names_refs_cleanup(xml)
40
+ replace_title(xml, "//references[@normative = 'true']",
41
+ @i18n&.normref, true)
42
+ replace_title(xml, "//references[@normative = 'false']",
43
+ @i18n&.bibliography, true)
44
+ end
45
+
46
+ NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
47
+ SYMABBR = "[.//definitions[@type = 'symbols']]"\
48
+ "[.//definitions[@type = 'abbreviated_terms']]".freeze
49
+ SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
50
+ "[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
51
+ ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
52
+ "[not(.//definitions[@type = 'symbols'])]".freeze
53
+
54
+ def section_names_terms_cleanup(x)
55
+ replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
56
+ replace_title(x, "//definitions[@type = 'abbreviated_terms']",
57
+ @i18n&.abbrev)
58
+ replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
59
+ replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
60
+ @i18n&.termsdefsymbols, true)
61
+ replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
62
+ @i18n&.termsdefabbrev, true)
63
+ replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
64
+ @i18n&.termsdefsymbolsabbrev, true)
65
+ replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
66
+ @i18n&.termsdefsymbolsabbrev, true)
67
+ replace_title(
68
+ x,
69
+ "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
70
+ @i18n&.termsdef, true
71
+ )
72
+ end
73
+ end
74
+ end
75
+ end
@@ -60,15 +60,15 @@ module Asciidoctor
60
60
 
61
61
  def term_children_cleanup(xmldoc)
62
62
  xmldoc.xpath("//term").each do |t|
63
- t.xpath("./termnote").each { |n| t << n.remove }
64
- t.xpath("./termexample").each { |n| t << n.remove }
65
- t.xpath("./termsource").each { |n| t << n.remove }
63
+ %w(termnote termexample termsource).each do |w|
64
+ t.xpath("./#{w}").each { |n| t << n.remove }
65
+ end
66
66
  end
67
- end
67
+ end
68
68
 
69
69
  def termdef_from_termbase(xmldoc)
70
70
  xmldoc.xpath("//term").each do |x|
71
- if c = x.at("./origin/termref") and !x.at("./definition")
71
+ if (c = x.at("./origin/termref")) && !x.at("./definition")
72
72
  x.at("./origin").previous = fetch_termbase(c["base"], c.text)
73
73
  end
74
74
  end
@@ -93,33 +93,34 @@ module Asciidoctor
93
93
  termdomain1_cleanup(xmldoc)
94
94
  termnote_example_cleanup(xmldoc)
95
95
  termdef_subclause_cleanup(xmldoc)
96
- term_children_cleanup(xmldoc)
96
+ term_children_cleanup(xmldoc)
97
97
  termdocsource_cleanup(xmldoc)
98
- end
98
+ end
99
99
 
100
100
  # Indices sort after letter but before any following
101
101
  # letter (x, x_m, x_1, xa); we use colon to force that sort order.
102
102
  # Numbers sort *after* letters; we use thorn to force that sort order.
103
- def symbol_key(x)
104
- key = x.dup
103
+ def symbol_key(sym)
104
+ key = sym.dup
105
105
  key.traverse do |n|
106
106
  next unless n.name == "math"
107
+
107
108
  n.replace(grkletters(MathML2AsciiMath.m2a(n.to_xml)))
108
109
  end
109
110
  ret = Nokogiri::XML(key.to_xml)
110
- HTMLEntities.new.decode(ret.text.downcase).
111
- gsub(/[\[\]\{\}<>\(\)]/, "").gsub(/\s/m, "").
112
- gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "").
113
- gsub(/[0-9]+/, "þ\\0")
111
+ HTMLEntities.new.decode(ret.text.downcase)
112
+ .gsub(/[\[\]{}<>()]/, "").gsub(/\s/m, "")
113
+ .gsub(/[[:punct:]]|[_^]/, ":\\0").gsub(/`/, "")
114
+ .gsub(/[0-9]+/, "þ\\0")
114
115
  end
115
-
116
+
116
117
  def grkletters(x)
117
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;")
118
119
  end
119
120
 
120
- def extract_symbols_list(dl)
121
+ def extract_symbols_list(dlist)
121
122
  dl_out = []
122
- dl.xpath("./dt | ./dd").each do |dtd|
123
+ dlist.xpath("./dt | ./dd").each do |dtd|
123
124
  if dtd.name == "dt"
124
125
  dl_out << { dt: dtd.remove, key: symbol_key(dtd) }
125
126
  else
@@ -128,7 +129,7 @@ module Asciidoctor
128
129
  end
129
130
  dl_out
130
131
  end
131
-
132
+
132
133
  def symbols_cleanup(docxml)
133
134
  docxml.xpath("//definitions/dl").each do |dl|
134
135
  dl_out = extract_symbols_list(dl)
@@ -136,7 +137,7 @@ module Asciidoctor
136
137
  dl.children = dl_out.map { |d| d[:dt].to_s + d[:dd].to_s }.join("\n")
137
138
  end
138
139
  docxml
139
- end
140
+ end
140
141
  end
141
142
  end
142
143
  end