metanorma-standoc 1.5.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +6 -1
  5. data/lib/asciidoctor/standoc/basicdoc.rng +23 -0
  6. data/lib/asciidoctor/standoc/cleanup.rb +79 -12
  7. data/lib/asciidoctor/standoc/cleanup_amend.rb +54 -0
  8. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -6
  9. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +14 -0
  10. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +11 -3
  11. data/lib/asciidoctor/standoc/cleanup_inline.rb +11 -2
  12. data/lib/asciidoctor/standoc/cleanup_ref.rb +3 -4
  13. data/lib/asciidoctor/standoc/cleanup_section.rb +1 -2
  14. data/lib/asciidoctor/standoc/converter.rb +6 -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 +135 -58
  19. data/lib/asciidoctor/standoc/lists.rb +4 -2
  20. data/lib/asciidoctor/standoc/macros.rb +59 -33
  21. data/lib/asciidoctor/standoc/ref.rb +41 -46
  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/views/datamodel/model_representation.adoc.erb +10 -10
  26. data/lib/liquid/custom_blocks/key_iterator.rb +21 -0
  27. data/lib/liquid/custom_blocks/with_json_nested_context.rb +18 -0
  28. data/lib/liquid/custom_blocks/with_yaml_nested_context.rb +19 -0
  29. data/lib/liquid/custom_filters/values.rb +7 -0
  30. data/lib/metanorma/standoc.rb +0 -5
  31. data/lib/metanorma/standoc/version.rb +20 -1
  32. data/metanorma-standoc.gemspec +5 -4
  33. data/spec/asciidoctor-standoc/base_spec.rb +246 -9
  34. data/spec/asciidoctor-standoc/blocks_spec.rb +255 -143
  35. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1498 -0
  36. data/spec/asciidoctor-standoc/cleanup_spec.rb +409 -1572
  37. data/spec/asciidoctor-standoc/inline_spec.rb +128 -4
  38. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +6 -20
  39. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  40. data/spec/asciidoctor-standoc/macros_json2text_spec.rb +10 -0
  41. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  42. data/spec/asciidoctor-standoc/macros_spec.rb +36 -0
  43. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +6 -561
  44. data/spec/asciidoctor-standoc/refs_dl_spec.rb +2 -2
  45. data/spec/asciidoctor-standoc/refs_spec.rb +266 -55
  46. data/spec/asciidoctor-standoc/section_spec.rb +0 -1
  47. data/spec/asciidoctor-standoc/table_spec.rb +112 -112
  48. data/spec/asciidoctor-standoc/validate_spec.rb +5 -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/fixtures/test.exp +121 -0
  54. data/spec/spec_helper.rb +142 -108
  55. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +781 -0
  56. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +50 -234
  57. data/spec/vcr_cassettes/isobib_get_123.yml +13 -59
  58. data/spec/vcr_cassettes/isobib_get_123_1.yml +23 -115
  59. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +361 -0
  60. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -57
  61. data/spec/vcr_cassettes/isobib_get_124.yml +13 -59
  62. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  63. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +50 -36
  64. metadata +59 -11
  65. data/.github/workflows/macos.yml +0 -46
  66. data/.github/workflows/ubuntu.yml +0 -49
  67. data/.github/workflows/windows.yml +0 -53
  68. data/lib/asciidoctor/standoc/macros_yaml2text.rb +0 -165
  69. data/lib/metanorma/standoc/latexml_requirement.rb +0 -62
  70. data/lib/metanorma/standoc/requirement.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 910ada4e6d4f62c6106391e3ec0de46a7ba4a9d5362bb103cd80ee0b2acef9dc
4
- data.tar.gz: de8546c035da0236faa4a6ca5df9b0f54f16806d09386793f359e55b69884212
3
+ metadata.gz: 6ca3aedd38f18114d3fb4c86c797294a3f1fb4fced3dbe22141980ad899df051
4
+ data.tar.gz: b885be1a706d741781853f85df50fe988b9ed93d31f15f6458c3f8debe8ab704
5
5
  SHA512:
6
- metadata.gz: 422e64b66f95fa4c49727687c446bd3f79bc09aa0609b352bd68cc659ff06bf57243ed410e4baa8f0cb501f101212d305a756b41548fcee7e877135aea22e1f3
7
- data.tar.gz: 97d6e164975997ecc396376abdaf2edad43c1f4fbfa601dbbc5f2f4d465747164350f500aaadc05f9fd6ed1e499925df7d74626fcde21a0578feeb50d607b84e
6
+ metadata.gz: b679c9834b6a85dcbbb743a50f4fe4cae499cf6bc8f6bebe2c58545bc09b282fe2c529068fa8db2a3027023f983f6b589a1b1883b356f18710d34cbdf8e13ce4
7
+ data.tar.gz: 583bc49e6a03656378f097a2acfa91578699d04be365bd92e3515b0252a940104efddf778ef79784fa27e06997345505a8527c530a86cdeaf3d13c78cc644e1f
@@ -0,0 +1,66 @@
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, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
11
+ jobs:
12
+ rake:
13
+ name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
+ runs-on: ${{ matrix.os }}
15
+ continue-on-error: ${{ matrix.experimental }}
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby: [ '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '2.7'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '2.7'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '2.7'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - uses: actions/cache@v1
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
48
+
49
+ - name: install plantuml ubuntu
50
+ if: matrix.os == 'ubuntu-latest'
51
+ uses: nick-invision/retry@v1
52
+ with:
53
+ polling_interval_seconds: 5
54
+ timeout_minutes: 5
55
+ max_attempts: 3
56
+ command: >
57
+ sudo apt-get update -y && sudo bash -c
58
+ "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
59
+
60
+ - if: matrix.os == 'macos-latest'
61
+ run: brew install plantuml
62
+
63
+ - if: matrix.os == 'windows-latest'
64
+ run: cinst -y plantuml
65
+
66
+ - run: bundle exec rake
@@ -1,9 +1,7 @@
1
1
  = Metanorma-standoc
2
2
 
3
3
  image:https://img.shields.io/gem/v/metanorma-standoc.svg["Gem Version", link="https://rubygems.org/gems/metanorma-standoc"]
4
- image:https://github.com/metanorma/metanorma-standoc/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=macos"]
5
- image:https://github.com/metanorma/metanorma-standoc/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=ubuntu"]
6
- image:https://github.com/metanorma/metanorma-standoc/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=windows"]
4
+ image:https://github.com/metanorma/metanorma-standoc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-standoc/actions?workflow=rake"]
7
5
  image:https://codeclimate.com/github/metanorma/metanorma-standoc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-standoc"]
8
6
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-standoc.svg["Pull Requests", link="https://github.com/metanorma/metanorma-standoc/pulls"]
9
7
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-standoc/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-standoc/releases"]
@@ -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}>"
@@ -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
@@ -68,6 +69,7 @@ module Asciidoctor
68
69
  bibdata_cleanup(xmldoc)
69
70
  boilerplate_cleanup(xmldoc)
70
71
  smartquotes_cleanup(xmldoc)
72
+ variant_cleanup(xmldoc)
71
73
  para_cleanup(xmldoc)
72
74
  empty_element_cleanup(xmldoc)
73
75
  img_cleanup(xmldoc)
@@ -80,12 +82,13 @@ module Asciidoctor
80
82
  xmldoc.traverse do |n|
81
83
  next unless n.text?
82
84
  if @smartquotes
83
- next unless /[-'"(<>]|\.\.|\dx/.match(n)
84
- next unless n.ancestors("pre, tt, sourcecode, bibdata, on, "\
85
- "stem, figure[@class = 'pseudocode']").empty?
85
+ /[-'"(<>]|\.\.|\dx/.match(n) or next
86
+ n.ancestors("pre, tt, sourcecode, bibdata, on, "\
87
+ "stem, figure[@class = 'pseudocode']").empty? or next
86
88
  n.replace(Utils::smartformat(n.text))
87
89
  else
88
- n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))
90
+ n.replace(n.text.gsub(/(?<=\p{Alnum})\u2019(?=\p{Alpha})/, "'"))#.
91
+ #gsub(/</, "&lt;").gsub(/>/, "&gt;"))
89
92
  end
90
93
  end
91
94
  end
@@ -145,16 +148,59 @@ module Asciidoctor
145
148
  align_callouts_to_annotations(xmldoc)
146
149
  end
147
150
 
151
+ def xml_unescape_mathml(x)
152
+ return if x.children.any? { |y| y.element? }
153
+ math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
154
+ gsub(/&apos;/, "'").gsub(/&amp;/, "&").
155
+ gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</")
156
+ x.children = math
157
+ end
158
+
159
+ MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
160
+
161
+ def mathml_preserve_space(m)
162
+ m.xpath(".//m:mtext", "m" => MATHML_NS).each do |x|
163
+ x.children = x.children.to_xml.gsub(/^\s/, "&#xA0;").
164
+ gsub(/\s$/, "&#xA0;")
165
+ end
166
+ end
167
+
168
+ def mathml_namespace(stem)
169
+ stem.xpath("./math", ).each { |x| x.default_namespace = MATHML_NS }
170
+ end
171
+
172
+ def mathml_mi_italics
173
+ { uppergreek: true, upperroman: true,
174
+ lowergreek: true, lowerroman: true }
175
+ end
176
+
177
+ # presuppose multichar mi upright, singlechar mi MathML default italic
178
+ def mathml_italicise(x)
179
+ x.xpath(".//m:mi", "m" => MATHML_NS).each do |i|
180
+ char = HTMLEntities.new.decode(i.text)
181
+ i["mathvariant"] = "normal" if mi_italicise?(char)
182
+ end
183
+ end
184
+
185
+ def mi_italicise?(c)
186
+ return false if c.length > 1
187
+ if /\p{Greek}/.match(c)
188
+ /\p{Lower}/.match(c) && !mathml_mi_italics[:lowergreek] ||
189
+ /\p{Upper}/.match(c) && !mathml_mi_italics[:uppergreek]
190
+ elsif /\p{Latin}/.match(c)
191
+ /\p{Lower}/.match(c) && !mathml_mi_italics[:lowerroman] ||
192
+ /\p{Upper}/.match(c) && !mathml_mi_italics[:upperroman]
193
+ else
194
+ false
195
+ end
196
+ end
197
+
148
198
  def mathml_cleanup(xmldoc)
149
199
  xmldoc.xpath("//stem[@type = 'MathML']").each do |x|
150
- next if x.children.any? { |y| y.element? }
151
- math = x.text.gsub(/&lt;/, "<").gsub(/&gt;/, ">").gsub(/&quot;/, '"').
152
- gsub(/&apos;/, "'").gsub(/&amp;/, "&").
153
- gsub(/<[^: \r\n\t\/]+:/, "<").gsub(/<\/[^ \r\n\t:]+:/, "</").
154
- gsub(/ xmlns[^>"']+/, "").
155
- gsub(/<math /, '<math xmlns="http://www.w3.org/1998/Math/MathML" ').
156
- gsub(/<math>/, '<math xmlns="http://www.w3.org/1998/Math/MathML">')
157
- x.children = math
200
+ xml_unescape_mathml(x)
201
+ mathml_namespace(x)
202
+ mathml_preserve_space(x)
203
+ mathml_italicise(x)
158
204
  end
159
205
  end
160
206
 
@@ -173,6 +219,27 @@ module Asciidoctor
173
219
  i["src"] = datauri(i["src"])
174
220
  end
175
221
  end
222
+
223
+ def variant_cleanup(xmldoc)
224
+ xmldoc.xpath("//*[variant]").each do |c|
225
+ c&.next&.text? && c&.next&.next&.name == "variant" &&
226
+ c.next.text.gsub(/\s/, "").empty? and c.next.remove
227
+ end
228
+ xmldoc.xpath("//*[variant]").each do |c|
229
+ next unless c.children.any? do |n|
230
+ n.name != "variant" && (!n.text? || !n.text.gsub(/\s/, "").empty?)
231
+ end
232
+ c.xpath("./variant").each do |n|
233
+ if n.at_xpath('preceding-sibling::node()[not(self::text()'\
234
+ '[not(normalize-space())])][1][self::variantwrap]')
235
+ n.previous_element << n
236
+ else
237
+ n.replace('<variantwrap/>').first << n
238
+ end
239
+ end
240
+ end
241
+ xmldoc.xpath("//variantwrap").each { |n| n.name = "variant" }
242
+ end
176
243
  end
177
244
  end
178
245
  end
@@ -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
@@ -21,12 +19,22 @@ module Asciidoctor
21
19
  end
22
20
  end
23
21
 
22
+ def dl1_table_cleanup(xmldoc)
23
+ q = "//table/following-sibling::*[1][self::dl]"
24
+ xmldoc.xpath(q).each do |s|
25
+ if s["key"] == "true"
26
+ s.previous_element << s.remove
27
+ end
28
+ end
29
+ end
30
+
24
31
  # move Key dl after table footer
25
- def dl_table_cleanup(xmldoc)
32
+ def dl2_table_cleanup(xmldoc)
26
33
  q = "//table/following-sibling::*[1][self::p]"
27
34
  xmldoc.xpath(q).each do |s|
28
35
  if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
29
36
  s.next_element.name == "dl"
37
+ s.next_element["key"] = "true"
30
38
  s.previous_element << s.next_element.remove
31
39
  s.remove
32
40
  end
@@ -56,7 +64,8 @@ module Asciidoctor
56
64
  end
57
65
 
58
66
  def table_cleanup(xmldoc)
59
- dl_table_cleanup(xmldoc)
67
+ dl1_table_cleanup(xmldoc)
68
+ dl2_table_cleanup(xmldoc)
60
69
  notes_table_cleanup(xmldoc)
61
70
  header_rows_cleanup(xmldoc)
62
71
  end
@@ -76,22 +85,47 @@ module Asciidoctor
76
85
 
77
86
  # include where definition list inside stem block
78
87
  def formula_cleanup(x)
88
+ formula_cleanup_where1(x)
89
+ formula_cleanup_where2(x)
90
+ end
91
+
92
+ def formula_cleanup_where1(x)
93
+ q = "//formula/following-sibling::*[1][self::dl]"
94
+ x.xpath(q).each do |s|
95
+ if s["key"] == "true"
96
+ s.previous_element << s.remove
97
+ end
98
+ end
99
+ end
100
+
101
+ def formula_cleanup_where2(x)
79
102
  q = "//formula/following-sibling::*[1][self::p]"
80
103
  x.xpath(q).each do |s|
81
104
  if s.text =~ /^\s*where[^a-z]*$/i && !s.next_element.nil? &&
82
105
  s.next_element.name == "dl"
106
+ s.next_element["key"] = "true"
83
107
  s.previous_element << s.next_element.remove
84
108
  s.remove
85
109
  end
86
110
  end
87
111
  end
88
112
 
113
+ def figure_dl_cleanup1(xmldoc)
114
+ q = "//figure/following-sibling::*[self::dl]"
115
+ xmldoc.xpath(q).each do |s|
116
+ if s["key"] == "true"
117
+ s.previous_element << s.remove
118
+ end
119
+ end
120
+ end
121
+
89
122
  # include key definition list inside figure
90
- def figure_dl_cleanup(xmldoc)
123
+ def figure_dl_cleanup2(xmldoc)
91
124
  q = "//figure/following-sibling::*[self::p]"
92
125
  xmldoc.xpath(q).each do |s|
93
126
  if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? &&
94
127
  s.next_element.name == "dl"
128
+ s.next_element["key"] = "true"
95
129
  s.previous_element << s.next_element.remove
96
130
  s.remove
97
131
  end
@@ -117,7 +151,8 @@ module Asciidoctor
117
151
 
118
152
  def figure_cleanup(xmldoc)
119
153
  figure_footnote_cleanup(xmldoc)
120
- figure_dl_cleanup(xmldoc)
154
+ figure_dl_cleanup1(xmldoc)
155
+ figure_dl_cleanup2(xmldoc)
121
156
  subfigure_cleanup(xmldoc)
122
157
  end
123
158
 
@@ -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