metanorma-standoc 1.5.1 → 1.6.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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +62 -0
  3. data/lib/asciidoctor/standoc/base.rb +7 -2
  4. data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
  5. data/lib/asciidoctor/standoc/cleanup.rb +32 -12
  6. data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +0 -2
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -3
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +62 -1
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +6 -5
  12. data/lib/asciidoctor/standoc/cleanup_section.rb +19 -3
  13. data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
  14. data/lib/asciidoctor/standoc/converter.rb +4 -2
  15. data/lib/asciidoctor/standoc/front.rb +9 -3
  16. data/lib/asciidoctor/standoc/front_contributor.rb +58 -18
  17. data/lib/asciidoctor/standoc/inline.rb +21 -31
  18. data/lib/asciidoctor/standoc/isodoc.rng +125 -58
  19. data/lib/asciidoctor/standoc/log.rb +10 -1
  20. data/lib/asciidoctor/standoc/macros.rb +44 -33
  21. data/lib/asciidoctor/standoc/ref.rb +39 -44
  22. data/lib/asciidoctor/standoc/ref_sect.rb +12 -5
  23. data/lib/asciidoctor/standoc/section.rb +11 -10
  24. data/lib/asciidoctor/standoc/table.rb +3 -2
  25. data/lib/asciidoctor/standoc/utils.rb +2 -1
  26. data/lib/asciidoctor/standoc/validate.rb +30 -18
  27. data/lib/asciidoctor/standoc/validate_section.rb +1 -1
  28. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +10 -10
  29. data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
  30. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  31. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  32. data/lib/liquid/custom_filters/values.rb +7 -0
  33. data/lib/metanorma/standoc.rb +0 -5
  34. data/lib/metanorma/standoc/version.rb +20 -1
  35. data/metanorma-standoc.gemspec +4 -4
  36. data/spec/asciidoctor-standoc/base_spec.rb +248 -10
  37. data/spec/asciidoctor-standoc/blocks_spec.rb +263 -144
  38. data/spec/asciidoctor-standoc/cleanup_spec.rb +199 -50
  39. data/spec/asciidoctor-standoc/inline_spec.rb +132 -5
  40. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +13 -27
  41. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
  42. data/spec/asciidoctor-standoc/macros_spec.rb +43 -23
  43. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +6 -561
  44. data/spec/asciidoctor-standoc/refs_dl_spec.rb +5 -3
  45. data/spec/asciidoctor-standoc/refs_spec.rb +268 -57
  46. data/spec/asciidoctor-standoc/section_spec.rb +0 -1
  47. data/spec/asciidoctor-standoc/table_spec.rb +119 -113
  48. data/spec/asciidoctor-standoc/validate_spec.rb +27 -1
  49. data/spec/examples/codes_table.html +1365 -1365
  50. data/spec/fixtures/macros_datamodel/address_class_profile.xml +46 -46
  51. data/spec/fixtures/macros_datamodel/address_component_profile.xml +21 -21
  52. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +21 -21
  53. data/spec/spec_helper.rb +115 -109
  54. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +781 -0
  55. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +54 -238
  56. data/spec/vcr_cassettes/isobib_get_123.yml +14 -60
  57. data/spec/vcr_cassettes/isobib_get_123_1.yml +24 -116
  58. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  59. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  60. data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
  61. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  62. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +39 -37
  63. metadata +42 -11
  64. data/.github/workflows/macos.yml +0 -46
  65. data/.github/workflows/ubuntu.yml +0 -49
  66. data/.github/workflows/windows.yml +0 -53
  67. data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
  68. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  69. data/lib/metanorma/standoc/requirement.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b4ec9dd5050345506b6b416eaad6b57865cb3c0b9e57e00e3b52f625fe87a48
4
- data.tar.gz: 4e53f6a44684a9694104f74c7560040893a47c70c5c8292810e9349a32c1e151
3
+ metadata.gz: 5c641d722b0af5fd2b54cda46fa5a4e463b7f3d48038fac91fa5e80f9cb59181
4
+ data.tar.gz: 65609c5176dcfa928c0b0f685baf0a7d6bb306779fbbc77558d89cb123664bf1
5
5
  SHA512:
6
- metadata.gz: 8d437d0619e0da4931009f2f92db0778bdd0eccb9bd15f81a7e38edc66a89474cecaa4099bd55bf8178a13a9551d533378068730231e2ed13d2ead794da7cb3a
7
- data.tar.gz: c5a606e3c94a341a6ce19bf5e77df8bf49eeae5d68cf6143d7050190a29f7213a34d74ab7743b87f54d7766fd17606cfb05f05b51a63f7a85ae113b9a23e98fd
6
+ metadata.gz: 45440c18061540e5fb09e20cd810dd6125a8f421348b1c2752321c20bfb8a5808c9fac859801e20dcaaa853cfe726284134b0ecc6b48620945ad17fa7cd32daa
7
+ data.tar.gz: b45e2cf75bc072f4bded33de6e37ea5a753191f8f2ec6bb00a46b8eee04d3f1ea7ee650a2947e54fdb0ca7f00f88454ba7a17015d57707c25a3fdf9e9883ac0d
@@ -0,0 +1,62 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master ]
8
+ pull_request:
9
+
10
+ jobs:
11
+ rake:
12
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
13
+ runs-on: ${{ matrix.os }}
14
+ continue-on-error: ${{ matrix.experimental }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ ruby: [ '2.6', '2.5', '2.4' ]
19
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
20
+ experimental: [ false ]
21
+ include:
22
+ - ruby: '2.7'
23
+ os: 'ubuntu-latest'
24
+ experimental: true
25
+ - ruby: '2.7'
26
+ os: 'windows-latest'
27
+ experimental: true
28
+ - ruby: '2.7'
29
+ os: 'macos-latest'
30
+ experimental: true
31
+ steps:
32
+ - uses: actions/checkout@master
33
+
34
+ - name: Use Ruby
35
+ uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
39
+
40
+ - name: Update gems
41
+ run: bundle install --jobs 4 --retry 3
42
+
43
+ - name: Install PlantUML Ubuntu
44
+ if: matrix.os == 'ubuntu-latest'
45
+ uses: nick-invision/retry@v1
46
+ with:
47
+ polling_interval_seconds: 5
48
+ timeout_minutes: 5
49
+ max_attempts: 3
50
+ command: sudo apt-get update -y && sudo bash -c "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
51
+
52
+ - name: Install PlantUML macOS
53
+ if: matrix.os == 'macos-latest'
54
+ run: brew install plantuml
55
+
56
+ - name: Install PlantUML Windows
57
+ if: matrix.os == 'windows-latest'
58
+ run: |
59
+ cinst -y plantuml
60
+
61
+ - name: Run specs
62
+ run: bundle exec rake
@@ -143,6 +143,11 @@ module Asciidoctor
143
143
  ret
144
144
  end
145
145
 
146
+ def version
147
+ flavour = self.class.name.sub(/::Converter$/, "").sub(/^.+::/, "")
148
+ Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
149
+ end
150
+
146
151
  def clean_exit
147
152
  @log.write(@output_dir + @filename + ".err") unless @novalid
148
153
  @files_to_delete.each { |f| FileUtils.rm f }
@@ -150,7 +155,7 @@ module Asciidoctor
150
155
 
151
156
  def makexml1(node)
152
157
  result = ["<?xml version='1.0' encoding='UTF-8'?>",
153
- "<#{xml_root_tag}>"]
158
+ "<#{xml_root_tag} type='semantic' version='#{version}'>"]
154
159
  result << noko { |ixml| front node, ixml }
155
160
  result << noko { |ixml| middle node, ixml }
156
161
  result << "</#{xml_root_tag}>"
@@ -170,7 +175,7 @@ module Asciidoctor
170
175
  end
171
176
 
172
177
  def doctype(node)
173
- node.attr("doctype")
178
+ node.attr("doctype")&.gsub(/\s+/, "-")&.downcase
174
179
  end
175
180
 
176
181
  def front(node, xml)
@@ -402,6 +402,16 @@
402
402
  </choice>
403
403
  </attribute>
404
404
  </optional>
405
+ <optional>
406
+ <attribute name="valign">
407
+ <choice>
408
+ <value>top</value>
409
+ <value>middle</value>
410
+ <value>bottom</value>
411
+ <value>baseline</value>
412
+ </choice>
413
+ </attribute>
414
+ </optional>
405
415
  <choice>
406
416
  <zeroOrMore>
407
417
  <ref name="TextElement"/>
@@ -429,6 +439,16 @@
429
439
  </choice>
430
440
  </attribute>
431
441
  </optional>
442
+ <optional>
443
+ <attribute name="valign">
444
+ <choice>
445
+ <value>top</value>
446
+ <value>middle</value>
447
+ <value>bottom</value>
448
+ <value>baseline</value>
449
+ </choice>
450
+ </attribute>
451
+ </optional>
432
452
  <choice>
433
453
  <zeroOrMore>
434
454
  <ref name="TextElement"/>
@@ -998,6 +1018,9 @@
998
1018
  <value>alphabet_upper</value>
999
1019
  </choice>
1000
1020
  </attribute>
1021
+ <optional>
1022
+ <attribute name="start"/>
1023
+ </optional>
1001
1024
  <oneOrMore>
1002
1025
  <ref name="li"/>
1003
1026
  </oneOrMore>
@@ -9,6 +9,7 @@ require_relative "./cleanup_boilerplate.rb"
9
9
  require_relative "./cleanup_section.rb"
10
10
  require_relative "./cleanup_terms.rb"
11
11
  require_relative "./cleanup_inline.rb"
12
+ require_relative "./cleanup_amend.rb"
12
13
  require "relaton_iev"
13
14
 
14
15
  module Asciidoctor
@@ -71,6 +72,7 @@ module Asciidoctor
71
72
  para_cleanup(xmldoc)
72
73
  empty_element_cleanup(xmldoc)
73
74
  img_cleanup(xmldoc)
75
+ anchor_cleanup(xmldoc)
74
76
  xmldoc
75
77
  end
76
78
 
@@ -79,12 +81,13 @@ module Asciidoctor
79
81
  xmldoc.traverse do |n|
80
82
  next unless n.text?
81
83
  if @smartquotes
82
- next unless /[-'"(<>]|\.\.|\dx/.match(n)
83
- next unless n.ancestors("pre, tt, sourcecode, bibdata, on, "\
84
- "stem, figure[@class = 'pseudocode']").empty?
84
+ /[-'"(<>]|\.\.|\dx/.match(n) or next
85
+ n.ancestors("pre, tt, sourcecode, bibdata, on, "\
86
+ "stem, figure[@class = 'pseudocode']").empty? or next
85
87
  n.replace(Utils::smartformat(n.text))
86
88
  else
87
- n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))
89
+ n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))#.
90
+ #gsub(/</, "&lt;").gsub(/>/, "&gt;"))
88
91
  end
89
92
  end
90
93
  end
@@ -144,16 +147,33 @@ module Asciidoctor
144
147
  align_callouts_to_annotations(xmldoc)
145
148
  end
146
149
 
150
+ def xml_unescape_mathml(x)
151
+ return if x.children.any? { |y| y.element? }
152
+ math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
153
+ gsub(/&apos;/, "'").gsub(/&amp;/, "&").
154
+ gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</")
155
+ x.children = math
156
+ end
157
+
158
+ def mathml_preserve_space(m)
159
+ m.xpath(".//m:mtext",
160
+ "m" => "http://www.w3.org/1998/Math/MathML").each do |x|
161
+ x.children = x.children.to_xml.gsub(/^\s/, "&#xA0;").
162
+ gsub(/\s$/, "&#xA0;")
163
+ end
164
+ end
165
+
166
+ def mathml_namespace(stem)
167
+ stem.xpath("./math", ).each do |x|
168
+ x.default_namespace = "http://www.w3.org/1998/Math/MathML"
169
+ end
170
+ end
171
+
147
172
  def mathml_cleanup(xmldoc)
148
173
  xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
149
- next if x.children.any? { |y| y.element? }
150
- math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
151
- gsub(/&apos;/, "'").gsub(/&amp;/, "&").
152
- gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</").
153
- gsub(/ xmlns[^>"']+/, "").
154
- gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
155
- gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
156
- x.children = math
174
+ xml_unescape_mathml(x)
175
+ mathml_namespace(x)
176
+ mathml_preserve_space(x)
157
177
  end
158
178
  end
159
179
 
@@ -0,0 +1,54 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ def change_clauses(x)
5
+ x.xpath("//clause[@change]").each do |c|
6
+ a = create_amend(c)
7
+ end
8
+ end
9
+
10
+ def create_amend(c)
11
+ a = c.add_child("<amend id='_#{UUIDTools::UUID.random_create}'/>").first
12
+ c.elements.each do |e|
13
+ e.parent = a unless %w(amend title).include? e.name
14
+ end
15
+ create_amend1(c, a)
16
+ end
17
+
18
+ def create_amend1(c, a)
19
+ create_amend2(c, a)
20
+ d = a.at("./description")
21
+ d.xpath(".//autonumber").each { |e| d.previous = e }
22
+ d.xpath(".//p[normalize-space(.)='']").each { |e| e.remove }
23
+ move_attrs_to_amend(c, a)
24
+ a
25
+ end
26
+
27
+ def create_amend2(c, a)
28
+ q = a.at("./quote") and q.name = "newcontent"
29
+ if q.nil?
30
+ a.children = "<description>#{a.children.to_xml}</description>"
31
+ else
32
+ pre = q&.xpath("./preceding-sibling::*")&.remove
33
+ post = q&.xpath("./following-sibling::*")&.remove
34
+ pre.empty? or a << "<description>#{pre.to_xml}</description>"
35
+ a << q.remove
36
+ post.empty? or a << "<description>#{post.to_xml}</description>"
37
+ end
38
+ end
39
+
40
+ def move_attrs_to_amend(c, a)
41
+ %w(change path path_end title).each do |e|
42
+ next unless c[e]
43
+ a[e] = c[e]
44
+ c.delete(e)
45
+ end
46
+ return unless a["locality"]
47
+ loc = a.children.add_previous_sibling("<location/>")
48
+ extract_localities1(loc, a["locality"])
49
+ loc1 = loc.at("./localityStack") and loc.replace(loc1.elements)
50
+ a.delete("locality")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,8 +1,6 @@
1
1
  require "date"
2
- require "nokogiri"
3
2
  require "htmlentities"
4
3
  require "json"
5
- require "pathname"
6
4
  require "open-uri"
7
5
 
8
6
  module Asciidoctor
@@ -91,10 +91,24 @@ module Asciidoctor
91
91
  end
92
92
 
93
93
  def bibdata_cleanup(xmldoc)
94
+ bibdata_anchor_cleanup(xmldoc)
95
+ bibdata_docidentifier_cleanup(xmldoc)
96
+ end
97
+
98
+ def bibdata_anchor_cleanup(xmldoc)
94
99
  xmldoc.xpath("//bibdata//bibitem | //bibdata//note").each do |b|
95
100
  b.delete("id")
96
101
  end
97
102
  end
103
+
104
+ def bibdata_docidentifier_cleanup(xmldoc)
105
+ ins = xmldoc.at("//bibdata/docidentifier")
106
+ xmldoc.xpath("//bibdata/docidentifier").each_with_index do |b, i|
107
+ next if i == 0
108
+ ins.next = b.remove
109
+ ins = ins.next
110
+ end
111
+ end
98
112
  end
99
113
  end
100
114
  end
@@ -1,10 +1,7 @@
1
1
  require "date"
2
- require "nokogiri"
3
2
  require "htmlentities"
4
3
  require "json"
5
- require "pathname"
6
4
  require "open-uri"
7
- require "pp"
8
5
 
9
6
  module Asciidoctor
10
7
  module Standoc
@@ -75,7 +72,18 @@ module Asciidoctor
75
72
  end
76
73
  end
77
74
 
75
+ def title_footnote_move(xmldoc)
76
+ ins = xmldoc.at("//bibdata/language")
77
+ xmldoc.xpath("//bibdata/title//fn").each do |f|
78
+ f.name = "note"
79
+ f["type"] = "title-footnote"
80
+ f.delete("reference")
81
+ ins.previous = f.remove
82
+ end
83
+ end
84
+
78
85
  def footnote_cleanup(xmldoc)
86
+ title_footnote_move(xmldoc)
79
87
  table_footnote_renumber(xmldoc)
80
88
  other_footnote_renumber(xmldoc)
81
89
  xmldoc.xpath("//fn").each do |fn|
@@ -50,6 +50,10 @@ module Asciidoctor
50
50
 
51
51
  def extract_localities(x)
52
52
  text = x&.children&.first&.remove&.text
53
+ extract_localities1(x, text)
54
+ end
55
+
56
+ def extract_localities1(x, text)
53
57
  b = x.add_child("<localityStack/>").first if LOCALITY_RE.match text
54
58
  while (m = LOCALITY_RE.match text)
55
59
  ref = m[:ref] ? "<referenceFrom>#{tq m[:ref]}</referenceFrom>" : ""
@@ -117,7 +121,8 @@ module Asciidoctor
117
121
  def concept_termbase_cleanup(x)
118
122
  text = x&.children&.first&.remove&.text
119
123
  termbase, key = x["key"].split(/:/, 2)
120
- x.add_child(%(<termref base="#{termbase}" target="#{key}">#{text}</termref>))
124
+ x.add_child(%(<termref base="#{termbase}" target="#{key}">) +
125
+ "#{text}</termref>")
121
126
  end
122
127
 
123
128
  def concept_xref_cleanup(x)
@@ -129,6 +134,62 @@ module Asciidoctor
129
134
  x.children = "<eref>#{x.children.to_xml}</eref>"
130
135
  extract_localities(x.first_element_child)
131
136
  end
137
+
138
+ NAMECHAR = "\u0000-\u0022\u0024\u002c\u002f\u003a-\u0040\\u005b-\u005e"\
139
+ "\u0060\u007b-\u00b6\u00b8-\u00bf\u00d7\u00f7\u037e\u2000-\u200b"\
140
+ "\u200e-\u203e\u2041-\u206f\u2190-\u2bff\u2ff0-\u3000".freeze
141
+ #"\ud800-\uf8ff\ufdd0-\ufdef\ufffe-\uffff".freeze
142
+ NAMESTARTCHAR = "\\u002d\u002e\u0030-\u0039\u00b7\u0300-\u036f"\
143
+ "\u203f-\u2040".freeze
144
+
145
+ def to_ncname(s)
146
+ start = s[0]
147
+ ret1 = %r([#{NAMECHAR}#]).match(start) ? "_" :
148
+ (%r([#{NAMESTARTCHAR}#]).match(start) ? "_#{start}" : start)
149
+ ret2 = s[1..-1] || ""
150
+ ret = (ret1 || "") + ret2.gsub(%r([#{NAMECHAR}#]), "_")
151
+ ret
152
+ end
153
+
154
+ def to_xreftarget(s)
155
+ return to_ncname(s) unless /^[^#]+#.+$/.match(s)
156
+ /^(?<pref>[^#]+)#(?<suff>.+)$/ =~ s
157
+ pref = pref.gsub(%r([#{NAMECHAR}]), "_")
158
+ suff = suff.gsub(%r([#{NAMECHAR}]), "_")
159
+ "#{pref}##{suff}"
160
+ end
161
+
162
+ IDREF = "//*/@id | //review/@from | //review/@to | "\
163
+ "//callout/@target | //citation/@bibitemid | //eref/@bibitemid".freeze
164
+
165
+ def anchor_cleanup(x)
166
+ anchor_cleanup1(x)
167
+ xreftarget_cleanup(x)
168
+ end
169
+
170
+ def anchor_cleanup1(x)
171
+ x.xpath(IDREF).each do |s|
172
+ if (ret = to_ncname(s.value)) != (orig = s.value)
173
+ s.value = ret
174
+ output = s.parent.dup
175
+ output.children.remove
176
+ @log.add("Anchors", s.parent, "normalised identifier in #{output} "\
177
+ "from #{orig}")
178
+ end
179
+ end
180
+ end
181
+
182
+ def xreftarget_cleanup(x)
183
+ x.xpath("//xref/@target").each do |s|
184
+ if (ret = to_xreftarget(s.value)) != (orig = s.value)
185
+ s.value = ret
186
+ output = s.parent.dup
187
+ output.children.remove
188
+ @log.add("Anchors", s.parent, "normalised identifier in #{output} "\
189
+ "from #{orig}")
190
+ end
191
+ end
192
+ end
132
193
  end
133
194
  end
134
195
  end
@@ -49,9 +49,8 @@ module Asciidoctor
49
49
  # consecutively, but that standards codes are preserved as is:
50
50
  # only numeric references are renumbered
51
51
  def biblio_renumber(xmldoc)
52
- r = xmldoc.at("//references[@normative = 'false'] | "\
53
- "//clause[.//references[@normative = 'false']] | "\
54
- "//annex[.//references[@normative = 'false']]") or return
52
+ r = xmldoc.at("//references | //clause[.//references] | "\
53
+ "//annex[.//references]") or return
55
54
  r.xpath(".//bibitem[not(ancestor::bibitem)]").each_with_index do |b, i|
56
55
  next unless docid = b.at("./docidentifier[@type = 'metanorma']")
57
56
  next unless /^\[\d+\]$/.match(docid.text)
@@ -127,7 +126,7 @@ module Asciidoctor
127
126
  bibitemxml = RelatonBib::BibliographicItem.new(
128
127
  RelatonBib::HashConverter::hash_to_bib(bib)).to_xml or next
129
128
  bibitem = Nokogiri::XML(bibitemxml)
130
- bibitem["id"] = c["id"] if c["id"]
129
+ bibitem.root["id"] = c["id"] if c["id"] && !/^_/.match(c["id"])
131
130
  c.replace(bibitem.root)
132
131
  end
133
132
  end
@@ -203,7 +202,9 @@ module Asciidoctor
203
202
  end
204
203
  if !nested and c.at("./title")
205
204
  title = c.at("./title").remove.children.to_xml
206
- bib["title"] = bib["title"] ? Array(bib["title"]) : []
205
+ bib["title"] = [bib["title"]] if bib["title"].is_a? Hash
206
+ bib["title"] = [bib["title"]] if bib["title"].is_a? String
207
+ bib["title"] = [] unless bib["title"]
207
208
  bib["title"] << title if !title.empty?
208
209
  end
209
210
  bib