diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-04-27 04:39:14 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-04-27 04:39:14 -0600 |
| commit | 2e6decd6053a90d1988d8631851f554ebb276109 (patch) | |
| tree | 0cfcc5c456bff207a2881dcb6de23b8134636e13 | |
| parent | a0faa7b3fb608a7aa25dcdef2ad57cdc558ab17f (diff) | |
allow the title of any section to be hidden using the notitle option
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 2 | ||||
| -rw-r--r-- | spec/section_spec.rb | 24 |
3 files changed, 26 insertions, 1 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index cd043160..3e28c2f3 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -16,6 +16,7 @@ Enhancements:: * add support for image-based icons, resolved from `iconsdir` and having the `icontype` file extension (#1770) * add `asciidoctor/pdf/nogmagick` script to prevent Gmagick from handling PNG images (#1687) * change name of `untitled` option on special section to `notitle` +* allow the title of any section to be hidden using the `notitle` option Bug Fixes:: diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 56f376bb..b62ecc5a 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -667,7 +667,7 @@ module Asciidoctor hlevel = sect.level + 1 align = (@theme[%(heading_h#{hlevel}_align)] || @theme.heading_align || @base_align).to_sym chapterlike = !(part = sectname == 'part') && (sectname == 'chapter' || (sect.document.doctype == 'book' && sect.level == 1)) - hidden = true if sect.special && (sect.option? 'notitle') + hidden = sect.option? 'notitle' hopts = { align: align, level: hlevel, part: part, chapterlike: chapterlike, outdent: !(part || chapterlike) } if part unless @theme.heading_part_break_before == 'auto' diff --git a/spec/section_spec.rb b/spec/section_spec.rb index 6e28fab5..6760e870 100644 --- a/spec/section_spec.rb +++ b/spec/section_spec.rb @@ -713,6 +713,30 @@ describe 'Asciidoctor::PDF::Converter - Section' do (expect appendix_text[:page_number]).to be 4 end + it 'should not output section title for section marked with notitle option' do + pdf = to_pdf <<~'EOS', analyze: true + = Document Title + :doctype: book + + == Intro + + Let's get started. + + [%notitle] + == Middle + + The bulk of the content. + + == Conclusion + + Wrapping it up. + EOS + + middle_chapter_text = pdf.find_text page_number: 3 + (expect middle_chapter_text).to have_size 1 + (expect middle_chapter_text[0][:string]).to eql 'The bulk of the content.' + 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 |
