diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 3fe95c38c..194a13d4a 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -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 } diff --git a/spec/toc_spec.rb b/spec/toc_spec.rb index 825e2b992..cff2a7c9d 100644 --- a/spec/toc_spec.rb +++ b/spec/toc_spec.rb @@ -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