Class: HTML::Pipeline::CiteFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/html/pipeline/cite/cite_filter.rb

Overview

An ‘HTML::Pipeline` filter that collects references in the text and inserts a table of footnotes where instructed.

Example:

<ref>This is a footnote</ref>

Becomes:

<sup class="reference" id="wiki-cite_ref-1">[<a href="#wiki-cite_note-1">1</a>]</sup>

It will show up as a bracketed, superscripted and anchored number at that location in the text. Then when ‘<references/>` is placed in the text, an ordered list of the references and their text will be placed at that location. The example above would generate a list that looks like this:

<ol>
  <li id="wiki-cite_note-1"><b><a href="#wiki-cite_ref-1">^</a></b> This is a footnote.</li>
</ol>

Constant Summary collapse

NOTE =

ID of the note

'wiki-cite_note'
REF =

ID of the ref

'wiki-cite_ref'

Instance Method Summary collapse

Instance Method Details

#callNokogiri::HTML::DocumentFragment

Replaces ref and references tags with the appropriate HTML and returns the result.

Returns:

  • (Nokogiri::HTML::DocumentFragment)

    Updated HTML document fragment.



38
39
40
41
42
43
# File 'lib/html/pipeline/cite/cite_filter.rb', line 38

def call
  refs = replace_refs
  replace_references(refs)

  doc
end