diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-08-20 04:42:32 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-20 04:42:32 -0600 |
| commit | eab6556bf405dedd74a330a6bb5271833f3fd0a9 (patch) | |
| tree | 11a07c67b87796c6df52f18bbb80507d42110bbb /lib | |
| parent | dd6f97b74fe29bb4263aedbf250f93e87b2e71c8 (diff) | |
resolves #2304 allow theme to set minimum height of orphans for code blocks (PR #2315)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 697bb55c..cf34f6ca 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -1176,7 +1176,7 @@ module Asciidoctor adjusted_font_size = ((node.option? 'autofit') || (node.document.attr? 'autofit-option')) ? (compute_autofit_font_size source_chunks, :code) : nil end - if !(node.option? 'unbreakable') && (breakable_min_lines = @theme.code_breakable_min_lines) && (source_string.count LF) + 1 < breakable_min_lines + if !(unbreakable = node.option? 'unbreakable') && (breakable_min_lines = @theme.code_breakable_min_lines) && (source_string.count LF) + 1 < breakable_min_lines node.set_option 'unbreakable' toggle_breakable = true end @@ -1186,6 +1186,10 @@ module Asciidoctor tare_first_page_content_stream do theme_fill_and_stroke_block :code, extent, background_color: bg_color_override, caption_node: caption_below ? nil : node end + unless extent || unbreakable || (cursor >= (@theme.code_orphans_min_height || 0)) + delete_current_page + raise NewPageRequiredError + end pad_box @theme.code_padding, node do theme_font :code do typeset_formatted_text source_chunks, (calc_line_metrics @base_line_height), |
