Module: Arrolio::GenericFlowBuilder::Bibliography

Included in:
Arrolio::GenericFlowBuilder
Defined in:
lib/arrolio/generic_flow_builder/bibliography.rb

Overview

Extracted emission seam: one module per content family, the same pattern as GenericAdapter's decomposition. The class keeps build(), dispatch, and shared helpers.

Instance Method Summary collapse

Instance Method Details

#bibliography_body_paragraph(item) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/arrolio/generic_flow_builder/bibliography.rb', line 27

def bibliography_body_paragraph(item)
  runs = []
  if item.formattedref
    runs.concat(item.formattedref.inline_runs.map do |r|
      Content::InlineRun.new(r.text, style_id: r.style_id)
    end)
  end
  Content::Paragraph.new(runs, style_id: item.style_id || :bibitem,
                               id: item.id)
end

#bibliography_item_flowable(item, out) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/arrolio/generic_flow_builder/bibliography.rb', line 9

def bibliography_item_flowable(item, out)
  tag = item.tag.to_s
  body_para = bibliography_body_paragraph(item)
  if tag.empty?
    out << paragraph_flowable(body_para)
    return
  end

  body = paragraph_flowable(body_para)
  out << Flowables::NoteFlowable.new(
    tag,
    [body],
    style: resolve(item.style_id || :bibitem),
    label_style: resolve(:bibitem_marker),
    marker_width: 24.0
  )
end

#marker_width_of(tag) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/arrolio/generic_flow_builder/bibliography.rb', line 38

def marker_width_of(tag)
  return 0.0 if tag.to_s.empty?

  style = resolve(:bibitem_marker)
  GlyphMeasurer.new(font_name: style.font_name)
               .width_of_string("#{tag} ", font_size: style.font_size)
end