summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2021-11-04 23:53:20 -0600
committerDan Allen <dan.j.allen@gmail.com>2021-11-05 00:43:33 -0600
commitabec0d22bba4211a6a861d098dd252cb72c1f9b2 (patch)
treedb4c1fdfe6bdb6198c47f1726569b44c816e90f2
parent5a83c9b078c8bea5cae4003982e09a23b969ebd8 (diff)
allow title of special section to be hidden by setting untitled option on section
-rw-r--r--CHANGELOG.adoc1
-rw-r--r--lib/asciidoctor/pdf/converter.rb2
-rw-r--r--spec/section_spec.rb35
3 files changed, 37 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index 8f7a6ff3..93124389 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -20,6 +20,7 @@ Enhancements::
* allow theme to control background color and border offset (only for background) for links (#1705)
* don't show link URL next to link text when media is not screen and show-link-uri is unset
* don't render index section if index is empty (i.e., there are no index entries)
+* allow title of special section to be hidden by setting "untitled" option on section
* stabilize font paths in built-in themes by prefixing paths with GEM_FONTS_DIR (#1568)
* assign page-layout attribute in running content so it can be used select background per layout (#1570)
* reset numbering of footnotes in each chapter; add chapter xreftext to label of footnote reference that refers to previous chapter (#1639)
diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb
index ccd5b755..bf10dcc7 100644
--- a/lib/asciidoctor/pdf/converter.rb
+++ b/lib/asciidoctor/pdf/converter.rb
@@ -681,7 +681,7 @@ module Asciidoctor
if sectname == 'part'
layout_part_title sect, title, align: align, level: hlevel
elsif chapterlike
- layout_chapter_title sect, title, align: align, level: hlevel
+ layout_chapter_title sect, title, align: align, level: hlevel unless sect.special && (sect.option? 'untitled')
else
layout_general_heading sect, title, align: align, level: hlevel, outdent: true
end
diff --git a/spec/section_spec.rb b/spec/section_spec.rb
index a6d8a7f5..c338aeb8 100644
--- a/spec/section_spec.rb
+++ b/spec/section_spec.rb
@@ -713,6 +713,41 @@ describe 'Asciidoctor::PDF::Converter - Section' do
(expect appendix_text[:page_number]).to be 4
end
+ it 'should not output section title for special section marked with untitled option' do
+ pdf = to_pdf <<~'EOS', pdf_theme: { heading_h2_font_color: 'AA0000' }, analyze: true
+ = Document Title
+ :doctype: book
+
+ [colophon%untitled]
+ = Hide Me
+
+ Colophon with no title.
+
+ = Part
+
+ == Chapter
+
+ content
+
+ [appendix]
+ = Details
+
+ We let you know.
+ EOS
+
+ colophon_page_text = pdf.find_text page_number: 2
+ (expect colophon_page_text).to have_size 1
+ (expect colophon_page_text[0][:string]).to eql 'Colophon with no title.'
+ chapter_texts = pdf.find_text font_color: 'AA0000'
+ (expect chapter_texts).to have_size 2
+ chapter_text = chapter_texts[0]
+ (expect chapter_text[:string]).to eql 'Chapter'
+ (expect chapter_text[:page_number]).to be 4
+ appendix_text = chapter_texts[1]
+ (expect appendix_text[:string]).to eql 'Appendix A: Details'
+ (expect appendix_text[:page_number]).to be 5
+ 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