Skip to content

Commit

Permalink
allow title of special section to be hidden by setting untitled optio…
Browse files Browse the repository at this point in the history
…n on section
  • Loading branch information
mojavelinux committed Nov 5, 2021
1 parent 5a83c9b commit abec0d2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ def convert_section sect, _opts = {}
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
Expand Down
35 changes: 35 additions & 0 deletions spec/section_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,41 @@
(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
Expand Down

0 comments on commit abec0d2

Please sign in to comment.