summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-15 15:13:24 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-15 15:27:57 -0600
commitf8fa537b8763253b5b0f4ae2a9ea70c966baaa16 (patch)
tree31ea92ee89ab1cf36f172145ab13410350dcbe4f /spec
parent87cd2d16a11838b736f8016a1f5886b633124a7b (diff)
don't add entry to TOC for notitle section if no content follows it
Diffstat (limited to 'spec')
-rw-r--r--spec/outline_spec.rb6
-rw-r--r--spec/section_spec.rb49
2 files changed, 50 insertions, 5 deletions
diff --git a/spec/outline_spec.rb b/spec/outline_spec.rb
index 231934aa..34363ba5 100644
--- a/spec/outline_spec.rb
+++ b/spec/outline_spec.rb
@@ -645,7 +645,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do
context 'notitle section' do
it 'should add entry for visible section with notitle option' do
- pdf = to_pdf <<~'EOS', debug: true
+ pdf = to_pdf <<~'EOS'
= Document Title
== Section Present
@@ -664,7 +664,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do
end
it 'should not add entry for section with no blocks' do
- pdf = to_pdf <<~'EOS', debug: true
+ pdf = to_pdf <<~'EOS'
= Document Title
== Section Present
@@ -680,7 +680,7 @@ describe 'Asciidoctor::PDF::Converter - Outline' do
end
it 'should not add entry for section on page which has been deleted' do
- pdf = to_pdf <<~'EOS', debug: true
+ pdf = to_pdf <<~'EOS'
= Document Title
== Section Present
diff --git a/spec/section_spec.rb b/spec/section_spec.rb
index 976a5273..b267bf2f 100644
--- a/spec/section_spec.rb
+++ b/spec/section_spec.rb
@@ -823,13 +823,39 @@ describe 'Asciidoctor::PDF::Converter - Section' do
(expect middle_chapter_text[0][:string]).to eql 'The bulk of the content.'
end
+ it 'should add entry to toc for section with notitle option' do
+ pdf = to_pdf <<~'EOS', analyze: true
+ = Document Title
+ :doctype: book
+ :toc:
+
+ == Intro
+
+ Let's get started.
+
+ [%notitle]
+ == Middle
+
+ The bulk of the content.
+
+ == Conclusion
+
+ Wrapping it up.
+ EOS
+
+ toc_lines = pdf.lines pdf.find_text page_number: 2
+ middle_entry = toc_lines.find {|it| it.start_with? 'Middle' }
+ (expect middle_entry).not_to be_nil
+ (expect middle_entry).to end_with '2'
+ end
+
it 'should not output section title for special section marked with notitle option' do
pdf = to_pdf <<~'EOS', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true
= Document Title
:doctype: book
[colophon%notitle]
- = Hide Me
+ = Hidden
Colophon with no title.
@@ -873,10 +899,29 @@ describe 'Asciidoctor::PDF::Converter - Section' do
(expect pdf.pages).to have_size 2
all_text = pdf.pages.map(&:text).join ?\n
- (expect all_text).not_to include 'Hide Me'
+ (expect all_text).not_to include 'Hidden'
(expect get_names pdf).not_to have_key '_hidden'
end
+ it 'should not add entry to toc for section marked with notitle option when no content follows it' do
+ pdf = to_pdf <<~'EOS'
+ = Document Title
+ :doctype: book
+ :toc:
+
+ == Chapter
+
+ Musings.
+
+ [colophon%notitle]
+ == Hidden
+ EOS
+
+ (expect pdf.pages).to have_size 3
+ all_text = pdf.pages.map(&:text).join ?\n
+ (expect all_text).not_to include 'Hidden'
+ end
+
it 'should not promote anonymous preface in book doctype to preface section if preface-title attribute is not set' do
input = <<~'EOS'
= Book Title