asciidoctor-html 2.2.2 → 2.2.3

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.
@@ -17,17 +17,7 @@ module Asciidoctor
17
17
  include Figure
18
18
 
19
19
  def convert_embedded(node)
20
- result = [node.content]
21
- if node.footnotes?
22
- result << %(<div class="fn-wrapper">)
23
- result << %(<div class="footnote-separator"></div><div class="footnotes">)
24
- node.footnotes.each do |fn|
25
- result << %(<div class="fn-row"><div class="fn-mark">#{fn.index}</div>)
26
- result << %(<div class="footnote" id="_footnotedef_#{fn.index}">#{fn.text}</div></div>)
27
- end
28
- result << %(</div></div>)
29
- end
30
- result.join("\n")
20
+ node.content
31
21
  end
32
22
 
33
23
  def convert_preamble(node)
@@ -41,8 +31,11 @@ module Asciidoctor
41
31
  classes = "section#{" flip" if level == 1}#{" #{node.role}" if node.role}"
42
32
  display_sectnum = Utils.display_sectnum(node, level) if show_sectnum
43
33
  title = "#{display_sectnum}#{node.title}"
44
- content = "#{Utils.heading node, title}#{node.content}"
45
- Utils.wrap_id_classes content, node.id, classes, :section
34
+ content = node.content
35
+ result = ["#{Utils.heading node, title}#{content}"]
36
+ footnotes = Utils.display_footnotes(node, content) if node.level == 1
37
+ result << footnotes if footnotes
38
+ Utils.wrap_id_classes result.join("\n"), node.id, classes, :section
46
39
  end
47
40
 
48
41
  def convert_floating_title(node)
@@ -48,7 +48,8 @@ module Asciidoctor
48
48
  context = :image if style == "figlist"
49
49
  env = env context, style
50
50
  block.set_attr("showcaption", true) unless context == :stem
51
- assign_numeral! block, NUMBERED_CONTEXTS[context] unless context == :section
51
+ counter_name = NUMBERED_CONTEXTS[context]
52
+ assign_numeral!(block, counter_name) if counter_name
52
53
  relative_numeral = relative_numeral block
53
54
 
54
55
  reftext = if context == :stem
@@ -121,6 +121,33 @@ module Asciidoctor
121
121
  def self.reftext(node)
122
122
  node.reftext || (node.title unless node.inline?) || "[#{node.id}]" if node.id
123
123
  end
124
+
125
+ # index_filter: Hash(index => bool)
126
+ def self.display_footnotes(node, content)
127
+ footnotes = []
128
+ content.scan(/data-contentid="_footnotedef_(\d)"/) do |matches|
129
+ index = matches&.first&.to_i
130
+ fn = node.document.footnotes.select { |fn| fn.index == index }.first
131
+ next unless fn
132
+
133
+ footnotes << <<~HTML
134
+ <div class="fn-row">
135
+ <div class="fn-mark">#{fn.index}</div>
136
+ <div class="footnote" id="_footnotedef_#{fn.index}">#{fn.text}</div>
137
+ </div>
138
+ HTML
139
+ end
140
+ return if footnotes.empty?
141
+
142
+ <<~HTML
143
+ <div class="fn-wrapper">
144
+ <div class="footnote-separator"></div>
145
+ <div class="footnotes">
146
+ #{footnotes.join "\n"}
147
+ </div> <!-- .footnotes -->
148
+ </div> <!-- .fn-wrapper -->
149
+ HTML
150
+ end
124
151
  end
125
152
  end
126
153
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Asciidoctor
4
4
  module Html
5
- VERSION = "2.2.2"
5
+ VERSION = "2.2.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-html
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ravi Rajani