Module: Asciidoctor::Revealjs::Converter::Footnotes
- Defined in:
- lib/asciidoctor_revealjs/converter.rb
Overview
Footnotes
Class Method Summary collapse
- .clear_slide_footnotes ⇒ Object
- .slide_footnote(footnote) ⇒ Object
- .slide_footnotes(section) ⇒ Object
Class Method Details
.clear_slide_footnotes ⇒ Object
68 69 70 |
# File 'lib/asciidoctor_revealjs/converter.rb', line 68 def @slide_footnotes = {} end |
.slide_footnote(footnote) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/asciidoctor_revealjs/converter.rb', line 41 def (footnote) footnote_parent = footnote.parent # footnotes declared on the section title are processed during the parsing/substitution. # as a result, we need to store them to display them on the right slide/section if footnote_parent.instance_of?(::Asciidoctor::Section) section_footnotes = @section_footnotes[footnote_parent] || [] footnote_index = section_footnotes.length + 1 attributes = footnote.attributes.merge({ 'index' => footnote_index }) inline_footnote = Asciidoctor::Inline.new(footnote_parent, footnote.context, footnote.text, attributes: attributes) section_footnotes << Asciidoctor::Document::Footnote.new(inline_footnote.attr(:index), inline_footnote.id, inline_footnote.text) @section_footnotes[footnote_parent] = section_footnotes else parent = footnote.parent parent = parent.parent until parent.nil? || parent.instance_of?(::Asciidoctor::Section) # check if there is any footnote attached on the section title section_footnotes = parent.nil? ? [] : @section_footnotes[parent] || [] initial_index = footnote.attr(:index) # reset the footnote numbering to 1 on each slide # make sure that if a footnote is used more than once it will use the same index/number = (existing_footnote = @slide_footnotes[initial_index]) ? existing_footnote.index : @slide_footnotes.length + section_footnotes.length + 1 attributes = footnote.attributes.merge({ 'index' => }) inline_footnote = Asciidoctor::Inline.new(footnote_parent, footnote.context, footnote.text, attributes: attributes) @slide_footnotes[initial_index] = Asciidoctor::Document::Footnote.new(inline_footnote.attr(:index), inline_footnote.id, inline_footnote.text) end inline_footnote end |
.slide_footnotes(section) ⇒ Object
72 73 74 75 |
# File 'lib/asciidoctor_revealjs/converter.rb', line 72 def (section) section_footnotes = @section_footnotes[section] || [] section_footnotes + @slide_footnotes.values end |