Class: Arrolio::Flowables::FootnoteMarkerFlowable
- Inherits:
-
Arrolio::Flowable
- Object
- Arrolio::Flowable
- Arrolio::Flowables::FootnoteMarkerFlowable
- Defined in:
- lib/arrolio/flowables/footnote_marker_flowable.rb
Overview
Anchors a footnote to the page it is referenced on and reserves the vertical space its body needs at the page bottom.
The footnote's layout policy lives here so the engine's height
accounting and the renderer's drawing agree by construction:
both ask .body_flowable for the same laid-out block. The
marker itself renders inline (superscript) from the paragraph's
run sequence; this flowable's job is space + page attribution.
Instance Attribute Summary collapse
-
#footnote ⇒ Object
readonly
Returns the value of attribute footnote.
Attributes inherited from Arrolio::Flowable
Class Method Summary collapse
-
.body_flowable(footnote, style) ⇒ Object
The footnote as it renders at the page bottom: marker + ")" prefix, body paragraphs joined, footnote style, 2pt gap after.
Instance Method Summary collapse
-
#emit(_x, _y, width, _context = nil) ⇒ Object
Emits nothing into the body area - the consumed height frees the bottom zone where the renderer draws the footnote body.
- #height(width, _context = nil) ⇒ Object
-
#initialize(footnote, style: Style::Definition.new(font_size: 9.0)) ⇒ FootnoteMarkerFlowable
constructor
A new instance of FootnoteMarkerFlowable.
Methods inherited from Arrolio::Flowable
#do_split, #keep_together?, #keep_with_next?, #min_keep_height, #page_break_after?, #page_break_before?, #space_after, #space_before, #split, #splittable?
Constructor Details
#initialize(footnote, style: Style::Definition.new(font_size: 9.0)) ⇒ FootnoteMarkerFlowable
Returns a new instance of FootnoteMarkerFlowable.
16 17 18 19 |
# File 'lib/arrolio/flowables/footnote_marker_flowable.rb', line 16 def initialize(footnote, style: Style::Definition.new(font_size: 9.0)) super(style: style) @footnote = footnote end |
Instance Attribute Details
#footnote ⇒ Object (readonly)
Returns the value of attribute footnote.
14 15 16 |
# File 'lib/arrolio/flowables/footnote_marker_flowable.rb', line 14 def footnote @footnote end |
Class Method Details
.body_flowable(footnote, style) ⇒ Object
The footnote as it renders at the page bottom: marker + ")" prefix, body paragraphs joined, footnote style, 2pt gap after.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/arrolio/flowables/footnote_marker_flowable.rb', line 23 def self.body_flowable(footnote, style) footnote_style = style.with(margin_top: 0.0, margin_bottom: 2.0) runs = [InlineRun.new("#{footnote.marker}) ", style: footnote_style)] footnote.body.each do |node| next unless node.is_a?(Content::Paragraph) node.inline_runs.each do |run| runs << InlineRun.new(run.text, style: footnote_style) end end TextFlowable.new(runs, style: footnote_style) end |
Instance Method Details
#emit(_x, _y, width, _context = nil) ⇒ Object
Emits nothing into the body area - the consumed height frees the bottom zone where the renderer draws the footnote body.
42 43 44 |
# File 'lib/arrolio/flowables/footnote_marker_flowable.rb', line 42 def emit(_x, _y, width, _context = nil) [[], height(width)] end |
#height(width, _context = nil) ⇒ Object
36 37 38 |
# File 'lib/arrolio/flowables/footnote_marker_flowable.rb', line 36 def height(width, _context = nil) self.class.body_flowable(@footnote, @style).height(width) end |