summaryrefslogtreecommitdiff
path: root/spec/section_spec.rb
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-04-28 11:34:26 -0600
committerGitHub <noreply@github.com>2022-04-28 11:34:26 -0600
commit1bf99be6bd73649bfa4cca026b4e77fb8e8cef9a (patch)
tree1e2739ae14cd85eb0d9619ed6d42b6b5169ba8bc /spec/section_spec.rb
parentdf242484a5dea886d40e50bd181d00f1bea83d34 (diff)
resolves #1786 allow entry for preface to be added to TOC without adding title to body (PR #2094)
Diffstat (limited to 'spec/section_spec.rb')
-rw-r--r--spec/section_spec.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/section_spec.rb b/spec/section_spec.rb
index 6760e870..9b62c965 100644
--- a/spec/section_spec.rb
+++ b/spec/section_spec.rb
@@ -860,6 +860,33 @@ describe 'Asciidoctor::PDF::Converter - Section' do
(expect text[2][:font_size]).to eql 10.5
end
+ it 'should only show preface title in TOC if notitle option is set on first child block of anonymous preface' do
+ input = <<~'EOS'
+ = Book Title
+ :doctype: book
+ :preface-title: Preface
+ :toc:
+
+ [%notitle]
+ anonymous preface
+
+ == First Chapter
+
+ chapter content
+ EOS
+
+ pdf = to_pdf input
+ (expect (preface_dest = get_dest pdf, '_preface')).not_to be_nil
+ _, page_height = get_page_size pdf, preface_dest[:page_number]
+ (expect preface_dest[:y]).to eql page_height
+
+ pdf = to_pdf input, analyze: true
+ (expect pdf.find_unique_text 'Preface', page_number: 2).not_to be_nil
+ (expect pdf.find_unique_text 'Preface', page_number: 3).to be_nil
+ # NOTE: lead role on first paragraph is retained
+ (expect (pdf.find_unique_text 'anonymous preface', page_number: 3)[:font_size]).to eql 13
+ end
+
it 'should not force title of empty section to next page if it fits on page' do
pdf = to_pdf <<~EOS, analyze: true
== Section A