diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-05-11 01:11:45 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-05-11 01:19:42 -0600 |
| commit | e8831a5f9c82f82dc463a24b2d02b07270d607bd (patch) | |
| tree | d29f24febffc0d1d2c942633ae209af70f1bc3f7 /spec/section_spec.rb | |
| parent | 96d57921a328fbaa2f077fe6cd597c4458611d67 (diff) | |
update extended converter that avoids a page break after a heading and use it in the test case
Diffstat (limited to 'spec/section_spec.rb')
| -rw-r--r-- | spec/section_spec.rb | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 67e14c8f..976a5273 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -1023,35 +1023,13 @@ describe 'Asciidoctor::PDF::Converter - Section' do (expect content_text[:page_number]).to be 2 end - it 'should allow arrange_heading to be reimplemented to always keep section with content that follows' do - backend = nil - create_class (Asciidoctor::Converter.for 'pdf') do - register_for (backend = %(pdf#{object_id}).to_sym) - def arrange_heading node, title, opts - orphaned = nil - dry_run single_page: true do - start_page = page - theme_font :heading, level: opts[:level] do - if opts[:part] - layout_part_title node, title, opts - elsif opts[:chapterlike] - layout_chapter_title node, title, opts - else - layout_general_heading node, title, opts - end - end - if page == start_page - page.tare_content_stream - orphaned = stop_if_first_page_empty do - node.context == :section ? (traverse node) : (convert (siblings = node.parent.blocks)[(siblings.index node) + 1]) - end - end - end - start_new_page if orphaned - nil - end - end - + it 'should allow arrange_heading to be reimplemented to always keep section title with content that follows it' do + source_file = doc_file 'modules/extend/examples/pdf-converter-avoid-break-after-heading.rb' + source_lines = (File.readlines source_file).select {|l| l == ?\n || (l.start_with? ' ') } + ext_class = create_class Asciidoctor::Converter.for 'pdf' + backend = %(pdf#{ext_class.object_id}) + source_lines[0] = %( register_for '#{backend}'\n) + ext_class.class_eval source_lines.join, source_file pdf = to_pdf <<~EOS, backend: backend, analyze: true == Section A |
