diff options
| -rw-r--r-- | CHANGELOG.adoc | 4 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 10 | ||||
| -rw-r--r-- | spec/section_spec.rb | 15 |
3 files changed, 24 insertions, 5 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c2f52a5c..cd9b1f70 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -19,6 +19,10 @@ Enhancements:: * rename `kbd-separator` theme key to `kbd-separator-content` to make its consistent with other content keys; remap old key and warn * preserve em and rem units on numerator in calc operation in theme (#2314) +Improvements:: + +* don't include bottom margin when computing heading height if `heading-min-height-after` theme key is empty (#2326) + Bug Fixes:: * keep caret between items in menu macro with previous item if items wrap diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 21574349..b8ee8c01 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -2862,13 +2862,13 @@ module Asciidoctor advance_page if orphaned else theme_font :heading, level: (hlevel = opts[:level]) do + if (space_below = ::Numeric === min_height_after ? min_height_after : 0) > 0 && (node.context == :section ? node.blocks? : !node.last_child?) + space_below += @theme[%(heading_h#{hlevel}_margin_bottom)] || @theme.heading_margin_bottom + end h_padding_t, h_padding_r, h_padding_b, h_padding_l = expand_padding_value @theme[%(heading_h#{hlevel}_padding)] h_fits = indent h_padding_l, h_padding_r do - heading_h = (height_of_typeset_text title, inline_format: true, text_transform: @text_transform) + - (@theme[%(heading_h#{hlevel}_margin_top)] || @theme.heading_margin_top) + - (@theme[%(heading_h#{hlevel}_margin_bottom)] || @theme.heading_margin_bottom) + h_padding_t + h_padding_b - heading_h += min_height_after if min_height_after && (node.context == :section ? node.blocks? : !node.last_child?) - cursor >= heading_h + cursor >= (height_of_typeset_text title, inline_format: true, text_transform: @text_transform) + + h_padding_t + h_padding_b + (@theme[%(heading_h#{hlevel}_margin_top)] || @theme.heading_margin_top) + space_below end advance_page unless h_fits end diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 42ff43c9..2c7d7cbb 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -1101,6 +1101,21 @@ describe 'Asciidoctor::PDF::Converter - Section' do (expect heading_texts.map {|it| it[:page_number] }.uniq).to eql [2] end + it 'should not require space for bottom margin between section title and bottom of page if min-height-after is 0' do + pdf = with_content_spacer 10, 710 do |spacer_path| + to_pdf <<~EOS, pdf_theme: { heading_min_height_after: 0, heading_font_color: 'AA0000' }, analyze: true + image::#{spacer_path}[] + + == Heading Fits + + content + EOS + end + + heading_text = pdf.find_unique_text font_color: 'AA0000' + (expect heading_text[:page_number]).to eql 1 + end + it 'should force section title with text transform to next page to keep with first line of section content' do pdf = to_pdf <<~EOS, pdf_theme: { heading_text_transform: 'uppercase' }, analyze: true image::tall.svg[pdfwidth=80mm] |
