Class: Marker::Footnotes
- Inherits:
-
Object
- Object
- Marker::Footnotes
- Defined in:
- lib/marker/markup.rb
Instance Method Summary collapse
Instance Method Details
#add(*args) ⇒ Object
45 46 47 48 |
# File 'lib/marker/markup.rb', line 45 def add( *args ) notes << args notes.size end |
#notes ⇒ Object
41 42 43 |
# File 'lib/marker/markup.rb', line 41 def notes @notes ||= [] end |
#to_html(options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/marker/markup.rb', line 50 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
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/marker/markup.rb', line 65 def to_s( = {} ) return "" unless notes.any? s = "\n" notes.each_with_index{ |n, i| target = n.shift if n.any? s << "#{'%2d' % (i + 1)}. #{n.join(' ')}: #{target}\n" else s << "#{'%2d' % (i + 1)}. #{target}\n" end } s end |