Module: Prawn::Text::Formatted::IndentedParagraphWrap

Defined in:
lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb

Instance Method Summary collapse

Instance Method Details

#wrap(array) ⇒ Object

Override Prawn::Text::Formatted::Box#wrap method to add support for :indent_paragraphs to (formatted_)text_box.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb', line 6

def wrap array
  initialize_wrap array
  stop = nil
  until stop
    if (first_line_indent = @indent_paragraphs) && @printed_lines.empty?
      @width -= first_line_indent
      stop = @document.indent(first_line_indent) { wrap_and_print_line }
      @width += first_line_indent
    else
      stop = wrap_and_print_line
    end
  end
  @text = @printed_lines.join ?\n
  @everything_printed = @arranger.finished?
  @arranger.unconsumed
end

#wrap_and_print_lineObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb', line 23

def wrap_and_print_line
  @line_wrap.wrap_line \
    document: @document,
    kerning: @kerning,
    width: @width,
    arranger: @arranger,
    disable_wrap_by_char: @disable_wrap_by_char
  if enough_height_for_this_line?
    move_baseline_down
    print_line
    @single_line || @arranger.finished?
  else
    true
  end
end