Sha256: eb538e54077a9238f1c6bea61eb3f6e9234b3a48cd7aa1b973b57bfa5a4edbf8

Contents?: true

Size: 1.09 KB

Versions: 39

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module Prawn::Text::Formatted
  module IndentedParagraphWrap
    # Override Prawn::Text::Formatted::Box#wrap method to add support for :indent_paragraphs to (formatted_)text_box.
    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

    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
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
asciidoctor-pdf-2.3.19 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.18 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.17 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.16 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.15 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.14 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.13 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.12 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.11 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.10 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.9 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.8 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.7 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.6 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.5 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.4 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.3 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.2 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.1 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
asciidoctor-pdf-2.3.0 lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb