Module: RedQuilt::FootnoteAnchors
- Defined in:
- lib/red_quilt/footnote_anchors.rb
Overview
Single source of truth for the HTML element ids used to wire footnote
references to their definitions and back. Both the reference (<sup>),
the definition (<li>), and the back-reference links must agree on
these strings, so they live in one place rather than being rebuilt at
each call site.
Class Method Summary collapse
-
.definition_id(number) ⇒ Object
Id of the definition
<li>and the target of a reference link. -
.reference_id(number, occurrence) ⇒ Object
Id of a reference
<sup>and the target of a back-reference link.
Class Method Details
.definition_id(number) ⇒ Object
Id of the definition <li> and the target of a reference link.
13 14 15 |
# File 'lib/red_quilt/footnote_anchors.rb', line 13 def definition_id(number) "fn-#{number}" end |
.reference_id(number, occurrence) ⇒ Object
Id of a reference <sup> and the target of a back-reference link.
A repeated reference (occurrence > 1) gets a -N suffix so every
back-reference has a unique anchor.
20 21 22 |
# File 'lib/red_quilt/footnote_anchors.rb', line 20 def reference_id(number, occurrence) occurrence > 1 ? "fnref-#{number}-#{occurrence}" : "fnref-#{number}" end |