-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
508ab3f
commit 77393d3
Showing
15 changed files
with
1,142 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
docs/modules/extend/examples/pdf-converter-code-float-wrapping.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class PDFConverterCodeFloatWrapping < (Asciidoctor::Converter.for 'pdf') | ||
register_for 'pdf' | ||
|
||
def supports_float_wrapping? node | ||
%i(paragraph listing literal).include? node.context | ||
end | ||
|
||
def convert_code node | ||
return super unless (float_box = @float_box ||= nil) | ||
indent(float_box[:left] - bounds.left, bounds.width - float_box[:right]) { super } | ||
@float_box = nil unless page_number == float_box[:page] && cursor > float_box[:bottom] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
lib/asciidoctor/pdf/ext/prawn/formatted_text/indented_paragraph_wrap.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.