Class: Marker::Footnotes
- Inherits:
-
Object
- Object
- Marker::Footnotes
- Defined in:
- lib/marker/markup.rb
Instance Method Summary collapse
Instance Method Details
#add(*args) ⇒ Object
63 64 65 66 |
# File 'lib/marker/markup.rb', line 63 def add( *args ) notes << args notes.size end |
#notes ⇒ Object
59 60 61 |
# File 'lib/marker/markup.rb', line 59 def notes @notes ||= [] end |
#to_html(options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/marker/markup.rb', line 68 def to_html( = {} ) return "" unless notes.any? "<ol class='footnotes'>" + notes.map { |n| target = n.shift if n.any? "<li><a href='#{target}'>#{n.join(' ')}</a></li>" else "<li><a href='#{target}'>#{target}</a></li>" end }.join + "</ol>" end |
#to_s(options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/marker/markup.rb', line 83 def to_s( = {} ) return "" unless notes.any? s = "\n---- Notes ----\n" notes.each_with_index{ |n, i| target, *label_words = n if label_words.any? s << "#{'%2d' % (i + 1)}. #{label_words.join(' ')}: #{target}\n" else s << "#{'%2d' % (i + 1)}. #{target}\n" end } s end |