diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-05-17 01:36:41 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-05-17 01:37:25 -0600 |
| commit | dd977e553bfc3f6fed4a0dcfaf8ca20ac989d363 (patch) | |
| tree | 42c27a3ad814abf29357ca92ba6e10985b87cac4 | |
| parent | 7b5be2fdece8e0fd0bf0fdb361f72e6ca8a25fff (diff) | |
remove requirement to add dummy text to title page to preserve it
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 5 | ||||
| -rw-r--r-- | spec/title_page_spec.rb | 28 |
3 files changed, 29 insertions, 5 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 51aaaf39..33947033 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,7 @@ Improvements:: * reclassify and mark which methods in the converter are private * organize methods in converter * add DOM traversal methods to simplify the logic in the converter +* remove requirement to add dummy text to title page to preserve it Bug Fixes:: diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index de82831f..000009ba 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -175,7 +175,7 @@ module Asciidoctor # NOTE: the base font must be set before any content is written to the main or scratch document font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style ink_title_page doc - start_new_page unless page.empty? + start_new_page else @page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress' && page_number == 0 start_new_page unless page&.empty? # rubocop:disable Lint/SafeNavigationWithEmpty @@ -3661,9 +3661,6 @@ module Asciidoctor move_down @theme.title_page_revision_margin_bottom || 0 end end - - ink_prose DummyText, margin: 0, line_height: 1, normalize: false if page.empty? - true end def allocate_toc doc, toc_num_levels, toc_start_cursor, title_page_on diff --git a/spec/title_page_spec.rb b/spec/title_page_spec.rb index a0398cae..4269d1d1 100644 --- a/spec/title_page_spec.rb +++ b/spec/title_page_spec.rb @@ -1147,7 +1147,7 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do (expect title_page_lines).to eql %w(Subtitle) end - it 'should not remove title page if all elements are disabled' do + it 'should advanced past title page if all elements are disabled' do pdf_theme = { title_page_title_display: 'none', title_page_subtitle_display: 'none', @@ -1174,5 +1174,31 @@ describe 'Asciidoctor::PDF::Converter - Title Page' do (expect title_page_images).to have_size 1 (expect title_page_images[0].data).to eql image_data end + + it 'should not remove title page if all elements are disabled' do + pdf_theme = { + title_page_title_display: 'none', + title_page_subtitle_display: 'none', + title_page_authors_display: 'none', + title_page_revision_display: 'none', + } + + pdf = to_pdf <<~'EOS', pdf_theme: pdf_theme, debug: true + = Document Title: Subtitle + :doctype: book + :title-page-background-image: image:cover.jpg[] + Author Name + v1.0, 2020-01-01 + EOS + + (expect pdf.pages).to have_size 1 + title_page_text = (pdf.page 1).text + (expect title_page_text).to be_empty + + image_data = File.binread fixture_file 'cover.jpg' + title_page_images = get_images pdf, 1 + (expect title_page_images).to have_size 1 + (expect title_page_images[0].data).to eql image_data + end end end |
