metanorma-standoc 2.7.1 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/lib/metanorma/standoc/base.rb +2 -3
  3. data/lib/metanorma/standoc/biblio.rng +13 -0
  4. data/lib/metanorma/standoc/cleanup_asciibib.rb +5 -3
  5. data/lib/metanorma/standoc/cleanup_bibitem.rb +144 -0
  6. data/lib/metanorma/standoc/cleanup_block.rb +1 -1
  7. data/lib/metanorma/standoc/cleanup_boilerplate.rb +1 -1
  8. data/lib/metanorma/standoc/cleanup_footnotes.rb +1 -1
  9. data/lib/metanorma/standoc/cleanup_inline.rb +1 -3
  10. data/lib/metanorma/standoc/cleanup_maths.rb +1 -3
  11. data/lib/metanorma/standoc/cleanup_ref.rb +18 -142
  12. data/lib/metanorma/standoc/cleanup_terms_designations.rb +6 -6
  13. data/lib/metanorma/standoc/cleanup_text.rb +6 -6
  14. data/lib/metanorma/standoc/converter.rb +1 -1
  15. data/lib/metanorma/standoc/front.rb +3 -5
  16. data/lib/metanorma/standoc/front_contributor.rb +1 -159
  17. data/lib/metanorma/standoc/front_organisation.rb +163 -0
  18. data/lib/metanorma/standoc/inline.rb +8 -7
  19. data/lib/metanorma/standoc/isodoc.rng +11 -1
  20. data/lib/metanorma/standoc/localbib.rb +3 -6
  21. data/lib/metanorma/standoc/macros.rb +7 -0
  22. data/lib/metanorma/standoc/ref.rb +1 -1
  23. data/lib/metanorma/standoc/ref_queue.rb +2 -2
  24. data/lib/metanorma/standoc/render.rb +2 -1
  25. data/lib/metanorma/standoc/term_lookup_cleanup.rb +3 -4
  26. data/lib/metanorma/standoc/terms.rb +1 -1
  27. data/lib/metanorma/standoc/validate.rb +12 -12
  28. data/lib/metanorma/standoc/validate_section.rb +2 -6
  29. data/lib/metanorma/standoc/validate_table.rb +2 -5
  30. data/lib/metanorma/standoc/validate_term.rb +4 -8
  31. data/lib/metanorma/standoc/version.rb +1 -1
  32. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f97ecd18866405cdb9d6b66001a4e36d2fbd8a54fdbf1b3c9158ea86a0b9bb18
4
- data.tar.gz: 91d500390673aee641a3f909e43f618c657c5441ce97e315f5cbcdbfd3e9b346
3
+ metadata.gz: 22383a78927c434e7f982f01118ce27f61d0f55d1a31b09b1b6af67602df204f
4
+ data.tar.gz: 7c9b2043c8c862dac50bac349fd432020c9e40d08cba1c1efa57519137a65d2a
5
5
  SHA512:
6
- metadata.gz: 3747b45da1d18b643ac4a5475057543765333cfee4d2f9a840045c7f86125b8c687499ceebe2f6bc4c97c0d11cfa6c6852fc2a550b40244d69d1b5880c9163ac
7
- data.tar.gz: 6ccc6bd35186eb717929cac051d85c1ac13bd42ddd97a22ee3cd6ac59259a8fbfaeff4e3e90a381f87ccf873b279c0cf2c27db3fdc88571805ca546d86068cfb
6
+ metadata.gz: cc525a7aea4c9efac2351a7b0983f82c62a3f19602a811ec80206fcb5855b9611a6e3b0aceb2c516e6ce450c182b88c4c477272e926f0dabb61e31bf72b4d327
7
+ data.tar.gz: aeef26d6f58f7f9d3d188b716d3bd4f8298e09fd9eaea3461aa3f74c3efd204d920bc7e86afe7a2d5073234e8675e1a38d66934c9e27b4fa67f244a36ed5bf37
@@ -19,7 +19,7 @@ module Metanorma
19
19
  XML_NAMESPACE = "https://www.metanorma.org/ns/standoc".freeze
20
20
  FONTS_MANIFEST = "fonts-manifest".freeze
21
21
 
22
- attr_accessor :log, :fatalerror
22
+ attr_accessor :log
23
23
 
24
24
  def xml_root_tag
25
25
  self.class::XML_ROOT_TAG
@@ -110,7 +110,6 @@ module Metanorma
110
110
  end
111
111
  @localdir = Metanorma::Utils::localdir(node)
112
112
  @output_dir = outputdir node
113
- @fatalerror = []
114
113
  end
115
114
 
116
115
  def init_i18n(node)
@@ -141,7 +140,7 @@ module Metanorma
141
140
  clean_exit
142
141
  ret
143
142
  rescue StandardError => e
144
- @log.add("Fatal Error", nil, e.message)
143
+ @log.add("Fatal Error", nil, e.message, severity: 0)
145
144
  clean_exit
146
145
  raise e
147
146
  end
@@ -374,6 +374,16 @@
374
374
  <ref name="image"/>
375
375
  </element>
376
376
  </define>
377
+ <define name="depiction">
378
+ <element name="depiction">
379
+ <optional>
380
+ <attribute name="scope"/>
381
+ </optional>
382
+ <zeroOrMore>
383
+ <ref name="image"/>
384
+ </zeroOrMore>
385
+ </element>
386
+ </define>
377
387
  <define name="NameWithVariants">
378
388
  <element name="primary">
379
389
  <ref name="LocalizedString"/>
@@ -760,6 +770,9 @@
760
770
  <optional>
761
771
  <ref name="validity"/>
762
772
  </optional>
773
+ <optional>
774
+ <ref name="depiction"/>
775
+ </optional>
763
776
  </define>
764
777
  <define name="ReducedBibliographicItem">
765
778
  <optional>
@@ -22,7 +22,7 @@ module Metanorma
22
22
  unless id
23
23
  @log.add("Anchors", clause,
24
24
  "The following reference is missing an anchor:\n" \
25
- "#{clause.to_xml}")
25
+ "#{clause.to_xml}", severity: 1)
26
26
  return
27
27
  end
28
28
  @refids << id
@@ -31,10 +31,12 @@ module Metanorma
31
31
 
32
32
  def validate_ref_dl1(bib, id, clause)
33
33
  bib["title"] or
34
- @log.add("Bibliography", clause, "Reference #{id} is missing a title")
34
+ @log.add("Bibliography", clause, "Reference #{id} is missing a title",
35
+ severity: 1)
35
36
  bib["docid"] or
36
37
  @log.add("Bibliography", clause,
37
- "Reference #{id} is missing a document identifier (docid)")
38
+ "Reference #{id} is missing a document identifier (docid)",
39
+ severity: 1)
38
40
  end
39
41
 
40
42
  def extract_from_p(tag, bib, key)
@@ -0,0 +1,144 @@
1
+ module Metanorma
2
+ module Standoc
3
+ module Cleanup
4
+ def formattedref_spans(xmldoc)
5
+ xmldoc.xpath("//bibitem[formattedref//span]").each do |b|
6
+ ret = new_bibitem_from_formattedref_spans(b)
7
+ merge_bibitem_from_formattedref_spans(b, ret)
8
+ end
9
+ end
10
+
11
+ def new_bibitem_from_formattedref_spans(bib)
12
+ ret = SpansToBibitem.new(bib).convert
13
+ ret.err.each do |e|
14
+ @log.add("Bibliography", bib, e[:msg], severity: e[:fatal] ? 0 : 1)
15
+ end
16
+ ret.out
17
+ end
18
+
19
+ def merge_bibitem_from_formattedref_spans(bib, new)
20
+ new["type"] and bib["type"] = new["type"]
21
+ if bib.at("./title") # there already is a fetched record here: merge
22
+ bib.children = MergeBibitems
23
+ .new(bib.to_xml, new.to_xml).merge.to_noko.children
24
+ else bib << new.children.to_xml
25
+ end
26
+ end
27
+
28
+ def fold_notes_into_biblio(refs)
29
+ refs.xpath("./bibitem").each do |r|
30
+ while r&.next_element&.name == "note"
31
+ r.next_element["appended"] = true
32
+ r << r.next_element.remove
33
+ end
34
+ end
35
+ end
36
+
37
+ def extract_notes_from_biblio(refs)
38
+ refs.xpath("./bibitem").each do |r|
39
+ r.xpath("./note[@appended]").reverse.each do |n|
40
+ n.delete("appended")
41
+ r.next = n
42
+ end
43
+ end
44
+ end
45
+
46
+ def biblio_hidden_inherit(xmldoc)
47
+ xmldoc.xpath("//references[@hidden = 'true']").each do |r|
48
+ r.xpath("./bibitem").each { |b| b["hidden"] = true }
49
+ end
50
+ end
51
+
52
+ def biblio_no_ext(xmldoc)
53
+ xmldoc.xpath("//bibitem/ext").each(&:remove)
54
+ end
55
+
56
+ def format_ref(ref, type)
57
+ ret = Nokogiri::XML.fragment(ref)
58
+ ret.traverse { |x| x.remove if x.name == "fn" }
59
+ ref = to_xml(ret)
60
+ type != "metanorma" and return @isodoc.docid_prefix(type, ref)
61
+ /^\d+$/.match(ref) && !/^\[.*\]$/.match(ref) and return "[#{ref}]"
62
+ ref
63
+ end
64
+
65
+ def reference_names(xmldoc)
66
+ xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
67
+ @anchors[ref["id"]] =
68
+ if docid = select_docid(ref)
69
+ reference = format_ref(docid.children.to_xml, docid["type"])
70
+ { xref: reference, id: idtype2cit(ref) }
71
+ else { xref: ref["id"], id: { "" => ref["id"] } }
72
+ end
73
+ end
74
+ end
75
+
76
+ def idtype2cit(ref)
77
+ ref.xpath("./docidentifier/@type").each_with_object({}) do |t, m|
78
+ m[t.text] and next
79
+ docid = select_docid(ref, t.text) or next
80
+ m[t.text] = format_ref(docid.children.to_xml, docid["type"])
81
+ end
82
+ end
83
+
84
+ def select_docid(ref, type = nil)
85
+ type and t = "[@type = '#{type}']"
86
+ ref.at("./docidentifier[@type = 'metanorma']#{t}") ||
87
+ ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']#{t}") ||
88
+ ref.at("./docidentifier[@primary = 'true'][not(@language)]#{t}") ||
89
+ ref.at("./docidentifier[@primary = 'true']#{t}") ||
90
+ ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']#{t}") ||
91
+ ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]#{t}") ||
92
+ ref.at("./docidentifier[not(@type = 'DOI')]#{t}")
93
+ end
94
+
95
+ def fetch_termbase(_termbase, _id)
96
+ ""
97
+ end
98
+
99
+ def read_local_bibitem(uri)
100
+ xml = read_local_bibitem_file(uri) or return nil
101
+ ret = xml.at("//*[local-name() = 'bibdata']") or return nil
102
+ ret = Nokogiri::XML(ret.to_xml
103
+ .sub(%r{(<bibdata[^>]*?) xmlns=("[^"]+"|'[^']+')}, "\\1")).root
104
+ ret.name = "bibitem"
105
+ ins = ret.at("./*[local-name() = 'docidentifier']") or return nil
106
+ ins.previous = %{<uri type="citation">#{uri}</uri>}
107
+ ret&.at("./*[local-name() = 'ext']")&.remove
108
+ ret
109
+ end
110
+
111
+ def read_local_bibitem_file(uri)
112
+ %r{^https?://}.match?(uri) and return nil
113
+ file = "#{@localdir}#{uri}.rxl"
114
+ File.file?(file) or file = "#{@localdir}#{uri}.xml"
115
+ File.file?(file) or return nil
116
+ Nokogiri::XML(File.read(file, encoding: "utf-8"))
117
+ end
118
+
119
+ # if citation uri points to local file, get bibitem from it
120
+ def fetch_local_bibitem(xmldoc)
121
+ xmldoc.xpath("//bibitem[formattedref][uri[@type = 'citation']]")
122
+ .each do |b|
123
+ uri = b&.at("./uri[@type = 'citation']")&.text
124
+ bibitem = read_local_bibitem(uri) or next
125
+ bibitem["id"] = b["id"]
126
+ b.replace(bibitem)
127
+ end
128
+ end
129
+
130
+ def bibitem_nested_id(xmldoc)
131
+ xmldoc.xpath("//bibitem//bibitem").each do |b|
132
+ b.delete("id")
133
+ end
134
+ end
135
+
136
+ def bibitem_cleanup(xmldoc)
137
+ bibitem_nested_id(xmldoc)
138
+ ref_dl_cleanup(xmldoc)
139
+ formattedref_spans(xmldoc)
140
+ fetch_local_bibitem(xmldoc)
141
+ end
142
+ end
143
+ end
144
+ end
@@ -218,7 +218,7 @@ module Metanorma
218
218
  def ol_cleanup(doc)
219
219
  doc.xpath("//ol[@explicit-type]").each do |x|
220
220
  x.delete("explicit-type")
221
- @log.add("Bibliography", x,
221
+ @log.add("Style", x,
222
222
  "Style override set for ordered list")
223
223
  end
224
224
  end
@@ -20,7 +20,7 @@ module Metanorma
20
20
  source.each do |s|
21
21
  @anchors[s["bibitemid"]] or
22
22
  @log.add("Crossreferences", nil,
23
- "term source #{s['bibitemid']} not referenced")
23
+ "term source #{s['bibitemid']} not referenced", severity: 1)
24
24
  end
25
25
  a = if source.empty? && term.nil? then @i18n.no_terms_boilerplate
26
26
  else term_defs_boilerplate_cont(source, term, isodoc)
@@ -114,7 +114,7 @@ module Metanorma
114
114
 
115
115
  def footnote_block_error(fnote)
116
116
  @log.add("Crossreferences", fnote,
117
- "Could not resolve footnoteblock:[#{fnote.text}]")
117
+ "Could not resolve footnoteblock:[#{fnote.text}]", severity: 1)
118
118
  fnote.children = "[ERROR]"
119
119
  end
120
120
 
@@ -212,9 +212,7 @@ module Metanorma
212
212
  l["target"] = Addressable::URI.parse(l["target"]).to_s
213
213
  rescue Addressable::URI::InvalidURIError
214
214
  err = "Malformed URI: #{l['target']}"
215
- @log.add("Anchors", l, err)
216
- @fatalerror << err
217
- warn err
215
+ @log.add("Anchors", l, err, severity: 0)
218
216
  end
219
217
  end
220
218
 
@@ -29,9 +29,7 @@ module Metanorma
29
29
 
30
30
  def asciimath2mathml_err(text, expr)
31
31
  err = "Malformed MathML: #{expr}\n#{text}"
32
- @log.add("Maths", nil, err)
33
- @fatalerror << err
34
- warn err
32
+ @log.add("Maths", nil, err, severity: 0)
35
33
  end
36
34
 
37
35
  def asciimath2mathml_wrap(xml)
@@ -2,35 +2,11 @@ require "set"
2
2
  require "relaton_bib"
3
3
  require_relative "merge_bibitems"
4
4
  require_relative "spans_to_bibitem"
5
+ require_relative "cleanup_bibitem"
5
6
 
6
7
  module Metanorma
7
8
  module Standoc
8
9
  module Cleanup
9
- def formattedref_spans(xmldoc)
10
- xmldoc.xpath("//bibitem[formattedref//span]").each do |b|
11
- ret = new_bibitem_from_formattedref_spans(b)
12
- merge_bibitem_from_formattedref_spans(b, ret)
13
- end
14
- end
15
-
16
- def new_bibitem_from_formattedref_spans(bib)
17
- ret = SpansToBibitem.new(bib).convert
18
- ret.err.each do |e|
19
- @log.add("Bibliography", bib, e[:msg])
20
- e[:fatal] and @fatalerror << e[:msg]
21
- end
22
- ret.out
23
- end
24
-
25
- def merge_bibitem_from_formattedref_spans(bib, new)
26
- new["type"] and bib["type"] = new["type"]
27
- if bib.at("./title") # there already is a fetched record here: merge
28
- bib.children = MergeBibitems
29
- .new(bib.to_xml, new.to_xml).merge.to_noko.children
30
- else bib << new.children.to_xml
31
- end
32
- end
33
-
34
10
  def biblio_reorder(xmldoc)
35
11
  xmldoc.xpath("//references[@normative = 'false']").each do |r|
36
12
  biblio_reorder1(r)
@@ -40,7 +16,7 @@ module Metanorma
40
16
  def biblio_reorder1(refs)
41
17
  fold_notes_into_biblio(refs)
42
18
  bib = sort_biblio(refs.xpath("./bibitem"))
43
- insert = refs&.at("./bibitem")&.previous_element
19
+ insert = refs.at("./bibitem")&.previous_element
44
20
  refs.xpath("./bibitem").each(&:remove)
45
21
  bib.reverse.each do |b|
46
22
  (insert and insert.next = b.to_xml) or
@@ -50,24 +26,6 @@ module Metanorma
50
26
  refs.xpath("./references").each { |r| biblio_reorder1(r) }
51
27
  end
52
28
 
53
- def fold_notes_into_biblio(refs)
54
- refs.xpath("./bibitem").each do |r|
55
- while r&.next_element&.name == "note"
56
- r.next_element["appended"] = true
57
- r << r.next_element.remove
58
- end
59
- end
60
- end
61
-
62
- def extract_notes_from_biblio(refs)
63
- refs.xpath("./bibitem").each do |r|
64
- r.xpath("./note[@appended]").reverse.each do |n|
65
- n.delete("appended")
66
- r.next = n
67
- end
68
- end
69
- end
70
-
71
29
  def sort_biblio(bib)
72
30
  bib
73
31
  end
@@ -114,12 +72,6 @@ module Metanorma
114
72
  biblio_no_ext(xmldoc)
115
73
  end
116
74
 
117
- def biblio_hidden_inherit(xmldoc)
118
- xmldoc.xpath("//references[@hidden = 'true']").each do |r|
119
- r.xpath("./bibitem").each { |b| b["hidden"] = true }
120
- end
121
- end
122
-
123
75
  def biblio_linkonly(xmldoc)
124
76
  xmldoc.at("//xref[@hidden]") or return
125
77
  ins = xmldoc.at("//bibliography")
@@ -139,10 +91,6 @@ module Metanorma
139
91
  reference_populate(refs)
140
92
  end
141
93
 
142
- def biblio_no_ext(xmldoc)
143
- xmldoc.xpath("//bibitem/ext").each(&:remove)
144
- end
145
-
146
94
  def biblio_annex(xmldoc)
147
95
  xmldoc.xpath("//annex[references/references]").each do |t|
148
96
  t.xpath("./clause | ./references | ./terms").size == 1 or next
@@ -153,101 +101,29 @@ module Metanorma
153
101
  end
154
102
 
155
103
  def biblio_nested(xmldoc)
156
- xmldoc.xpath("//references[references]").each do |t|
157
- t.name = "clause"
158
- t.xpath("./references").each { |r| r["normative"] = t["normative"] }
159
- t.delete("normative")
160
- end
161
- end
162
-
163
- def format_ref(ref, type)
164
- ret = Nokogiri::XML.fragment(ref)
165
- ret.traverse { |x| x.remove if x.name == "fn" }
166
- ref = to_xml(ret)
167
- return @isodoc.docid_prefix(type, ref) if type != "metanorma"
168
- return "[#{ref}]" if /^\d+$/.match(ref) && !/^\[.*\]$/.match(ref)
169
-
170
- ref
171
- end
172
-
173
- def reference_names(xmldoc)
174
- xmldoc.xpath("//bibitem[not(ancestor::bibitem)]").each do |ref|
175
- @anchors[ref["id"]] = if docid = select_docid(ref)
176
- reference = format_ref(docid.children.to_xml,
177
- docid["type"])
178
- { xref: reference, id: idtype2cit(ref) }
179
- else
180
- { xref: ref["id"], id: { "" => ref["id"] } }
181
- end
182
- end
183
- end
184
-
185
- def idtype2cit(ref)
186
- ref.xpath("./docidentifier/@type").each_with_object({}) do |t, m|
187
- m[t.text] and next
188
- docid = select_docid(ref, t.text) or next
189
- m[t.text] = format_ref(docid.children.to_xml, docid["type"])
190
- end
191
- end
192
-
193
- def select_docid(ref, type = nil)
194
- type and t = "[@type = '#{type}']"
195
- ref.at("./docidentifier[@type = 'metanorma']#{t}") ||
196
- ref.at("./docidentifier[@primary = 'true'][@language = '#{@lang}']#{t}") ||
197
- ref.at("./docidentifier[@primary = 'true'][not(@language)]#{t}") ||
198
- ref.at("./docidentifier[@primary = 'true']#{t}") ||
199
- ref.at("./docidentifier[not(@type = 'DOI')][@language = '#{@lang}']#{t}") ||
200
- ref.at("./docidentifier[not(@type = 'DOI')][not(@language)]#{t}") ||
201
- ref.at("./docidentifier[not(@type = 'DOI')]#{t}")
202
- end
203
-
204
- def fetch_termbase(_termbase, _id)
205
- ""
206
- end
207
-
208
- def read_local_bibitem(uri)
209
- xml = read_local_bibitem_file(uri) or return nil
210
- ret = xml.at("//*[local-name() = 'bibdata']") or return nil
211
- ret = Nokogiri::XML(ret.to_xml
212
- .sub(%r{(<bibdata[^>]*?) xmlns=("[^"]+"|'[^']+')}, "\\1")).root
213
- ret.name = "bibitem"
214
- ins = ret.at("./*[local-name() = 'docidentifier']") or return nil
215
- ins.previous = %{<uri type="citation">#{uri}</uri>}
216
- ret&.at("./*[local-name() = 'ext']")&.remove
217
- ret
104
+ biblio_nested_initial_items(xmldoc)
105
+ biblio_nested_sections(xmldoc)
218
106
  end
219
107
 
220
- def read_local_bibitem_file(uri)
221
- %r{^https?://}.match?(uri) and return nil
222
- file = "#{@localdir}#{uri}.rxl"
223
- File.file?(file) or file = "#{@localdir}#{uri}.xml"
224
- File.file?(file) or return nil
225
- Nokogiri::XML(File.read(file, encoding: "utf-8"))
226
- end
227
-
228
- # if citation uri points to local file, get bibitem from it
229
- def fetch_local_bibitem(xmldoc)
230
- xmldoc.xpath("//bibitem[formattedref][uri[@type = 'citation']]")
231
- .each do |b|
232
- uri = b&.at("./uri[@type = 'citation']")&.text
233
- bibitem = read_local_bibitem(uri) or next
234
- bibitem["id"] = b["id"]
235
- b.replace(bibitem)
108
+ def biblio_nested_initial_items(xmldoc)
109
+ xmldoc.xpath("//references[references][bibitem]").each do |t|
110
+ r = t.at("./references")
111
+ ref = t.at("./bibitem")
112
+ .before("<references unnumbered='true'></references>").previous
113
+ (ref.xpath("./following-sibling::*") &
114
+ r.xpath("./preceding-sibling::*")).each do |x|
115
+ ref << x
116
+ end
236
117
  end
237
118
  end
238
119
 
239
- def bibitem_nested_id(xmldoc)
240
- xmldoc.xpath("//bibitem//bibitem").each do |b|
241
- b.delete("id")
120
+ def biblio_nested_sections(xmldoc)
121
+ xmldoc.xpath("//references[references]").each do |t|
122
+ t.name = "clause"
123
+ t.xpath("./references").each { |r| r["normative"] = t["normative"] }
124
+ t.delete("normative")
242
125
  end
243
126
  end
244
-
245
- def bibitem_cleanup(xmldoc)
246
- bibitem_nested_id(xmldoc)
247
- ref_dl_cleanup(xmldoc)
248
- formattedref_spans(xmldoc)
249
- fetch_local_bibitem(xmldoc)
250
- end
251
127
  end
252
128
  end
253
129
  end
@@ -5,8 +5,7 @@ module Metanorma
5
5
  xmldoc.xpath("//term//expression/name[stem]").each do |n|
6
6
  test = n.dup
7
7
  test.at("./stem").remove
8
- next unless test.text.strip.empty?
9
-
8
+ test.text.strip.empty? or next
10
9
  n.parent.name = "letter-symbol"
11
10
  end
12
11
  end
@@ -107,10 +106,11 @@ module Metanorma
107
106
  end
108
107
 
109
108
  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"
109
+ ls = dlist.at("./dt[text()='letter-symbol']/following::dd/p")&.text
110
+ !ls || ls == "false" and return
111
+ e = prev.at(".//expression")
112
+ e.name = "letter-symbol"
113
+ ls != "true" and e["type"] = ls
114
114
  end
115
115
 
116
116
  def dl_to_designation(dlist)
@@ -39,8 +39,8 @@ module Metanorma
39
39
 
40
40
  def uninterrupt_quotes_around_xml_skip(elem)
41
41
  !(/\A['"]/.match?(elem.text) &&
42
- elem.previous.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2].
43
- intersection(IGNORE_QUOTES_ELEMENTS).empty? &&
42
+ elem.previous.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
43
+ .intersection(IGNORE_QUOTES_ELEMENTS).empty? &&
44
44
  ((elem.previous.text.strip.empty? &&
45
45
  !empty_tag_with_text_content?(elem.previous)) ||
46
46
  ignoretext?(elem.previous)))
@@ -50,8 +50,8 @@ module Metanorma
50
50
  prev = elem.at(".//preceding::text()[1]") or return
51
51
  /\S\Z/.match?(prev.text) or return
52
52
  foll = elem.at(".//following::text()[1]")
53
- m = /\A(["'][[:punct:]]*)(\s|\Z)/.
54
- match(@c.decode(foll&.text)) or return
53
+ m = /\A(["'][[:punct:]]*)(\s|\Z)/
54
+ .match(@c.decode(foll&.text)) or return
55
55
  foll.content = foll.text.sub(/\A(["'][[:punct:]]*)/, "")
56
56
  prev.content = "#{prev.text}#{m[1]}"
57
57
  end
@@ -103,8 +103,8 @@ module Metanorma
103
103
  next unless n.text? && /\u2019/.match?(n.text)
104
104
 
105
105
  n.replace(@c.encode(
106
- @c.decode(n.text).
107
- gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"),
106
+ @c.decode(n.text)
107
+ .gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"),
108
108
  :basic, :hexadecimal
109
109
  ))
110
110
  end
@@ -114,7 +114,7 @@ module Metanorma
114
114
  def skip(node, name = nil)
115
115
  name = name || node.node_name
116
116
  w = "converter missing for #{name} node in Metanorma backend"
117
- @log.add("AsciiDoc Input", node, w)
117
+ @log.add("AsciiDoc Input", node, w, severity: 1)
118
118
  nil
119
119
  end
120
120
 
@@ -149,8 +149,7 @@ module Metanorma
149
149
  end
150
150
 
151
151
  def metadata_keywords(node, xml)
152
- return unless node.attr("keywords")
153
-
152
+ node.attr("keywords") or return
154
153
  node.attr("keywords").split(/,\s*/).each do |kw|
155
154
  xml.keyword kw
156
155
  end
@@ -225,9 +224,8 @@ module Metanorma
225
224
 
226
225
  def title_otherlangs(node, xml)
227
226
  node.attributes.each do |k, v|
228
- next unless /^title-(?<titlelang>.+)$/ =~ k
229
- next if titlelang == "en"
230
-
227
+ /^title-(?<titlelang>.+)$/ =~ k or next
228
+ titlelang == "en" and next
231
229
  xml.title v, { language: titlelang, format: "text/plain" }
232
230
  end
233
231
  end