Skip to content

Commit

Permalink
don't crash if theme does not define toc_indent key
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Apr 18, 2022
1 parent 0183d62 commit a65c718
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/asciidoctor/pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ def prepare_theme theme
theme.key_separator ||= '+'
theme.title_page_authors_delimiter ||= ', '
theme.title_page_revision_delimiter ||= ', '
theme.toc_indent ||= 0
theme.toc_hanging_indent ||= 0
if ::Array === (quotes = theme.quotes)
TypographicQuotes.each_with_index {|char, idx| quotes[idx] ||= char }
Expand Down
15 changes: 15 additions & 0 deletions spec/toc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,21 @@
(expect page_3_lines[0]).to match %r/we are ?(\. )+ ?\u00a038$/
end

it 'should not crash if theme does not specify toc_indent' do
(expect do
pdf = to_pdf <<~'EOS', attributes: { 'pdf-theme' => (fixture_file 'custom-theme.yml') }, analyze: true
= Document Title
:toc:
== Section
EOS

toc_text = pdf.find_unique_text %r/Table of Contents/
(expect toc_text).not_to be_nil
(expect toc_text[:font_name]).to eql 'Times-Roman'
end).to not_raise_exception
end

it 'should allow hanging indent to be applied to lines that wrap' do
pdf = to_pdf <<~'EOS', doctype: :book, pdf_theme: { toc_hanging_indent: 36 }, analyze: true
= Document Title
Expand Down

0 comments on commit a65c718

Please sign in to comment.