Class: Jekyll::FootnoteBody
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::FootnoteBody
- Includes:
- FootnoteUtils
- Defined in:
- lib/jekyll/footnotes.rb
Instance Method Summary collapse
-
#initialize(tag_name, id, tokens) ⇒ FootnoteBody
constructor
A new instance of FootnoteBody.
- #render(context) ⇒ Object
Methods included from FootnoteUtils
#backlink_id, #footnote_id, #page_hash
Constructor Details
#initialize(tag_name, id, tokens) ⇒ FootnoteBody
Returns a new instance of FootnoteBody.
40 41 42 43 44 |
# File 'lib/jekyll/footnotes.rb', line 40 def initialize(tag_name, id, tokens) raise(SyntaxError.new("invalid footnote ID")) if ['"', '<', '>'].any? { |c| id.include?(c) } @id = id.strip unless id.strip.empty? super end |
Instance Method Details
#render(context) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/jekyll/footnotes.rb', line 46 def render(context) if @id.nil? context.registers[:fnbody] ||= 0 context.registers[:fnbody] = context.registers[:fnbody].next @id = context.registers[:fnbody] end context.stack do body = super "<li id=\"#{footnote_id(context, @id)}\" class=\"footnotebody\" value=\"#{@id}\">#{body}<a href=\"##{backlink_id(context, @id)}\" class=\"backlink\">⏎</a></li>" end end |