diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-04-25 17:55:38 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-25 17:55:38 -0600 |
| commit | bd194ba444c8f97fcc8c71edd7745a5319663632 (patch) | |
| tree | eaf28deb7dfadce9f7e8f1824c3e236fb2ad022b /spec/section_spec.rb | |
| parent | 426afe5d07327371ca1f26c70bb960ea39936d84 (diff) | |
resolves #2075 keep section title with first block of content is breakable option is set on section (PR #2076)
Diffstat (limited to 'spec/section_spec.rb')
| -rw-r--r-- | spec/section_spec.rb | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 9dfe6dd1..4f36430d 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -872,15 +872,26 @@ describe 'Asciidoctor::PDF::Converter - Section' do create_class (Asciidoctor::Converter.for 'pdf') do register_for (backend = %(pdf#{object_id}).to_sym) def arrange_section sect, title, opts + return if opts[:hidden] orphaned = nil dry_run single_page: true do start_page = page - theme_font(:heading, level: opts[:level]) { layout_general_heading sect, title, opts } - next if page != start_page - page.tare_content_stream - orphaned = stop_if_first_page_empty { traverse sect } + theme_font :heading, level: opts[:level] do + if opts[:part] + layout_part_title sect, title, opts + elsif opts[:chapterlike] + layout_chapter_title sect, title, opts + else + layout_general_heading sect, title, opts + end + end + if page == start_page + page.tare_content_stream + orphaned = stop_if_first_page_empty { traverse sect } + end end start_new_page if orphaned + nil end end @@ -907,6 +918,31 @@ describe 'Asciidoctor::PDF::Converter - Section' do (expect content_text[:page_number]).to be 2 end + it 'should keep section with first block of content if breakable option is set on section' do + pdf = to_pdf <<~EOS, analyze: true + == Section A + + image::tall.svg[pdfwidth=70mm] + + [%breakable] + == Section B + + [%unbreakable] + -- + keep + + this + + together + -- + EOS + + section_b_text = pdf.find_unique_text 'Section B' + (expect section_b_text[:page_number]).to be 2 + content_text = pdf.find_unique_text 'keep' + (expect content_text[:page_number]).to be 2 + end + it 'should not add break before chapter if heading-chapter-break-before key in theme is auto' do pdf = to_pdf <<~'EOS', pdf_theme: { heading_chapter_break_before: 'auto' }, analyze: true = Document Title |
