From 6b99613d597fb8a13a0bdf5cf493a711fd54a390 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sat, 9 Mar 2024 14:19:56 -0700 Subject: [PATCH] resolves #2505 drop links from entries in TOC (PR #2506) --- CHANGELOG.adoc | 1 + lib/asciidoctor/pdf/converter.rb | 1 + spec/toc_spec.rb | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 67bbfdbc8..44e2e1023 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -39,6 +39,7 @@ Improvements:: * refactor formatted text transform to simplify how inner space is collapsed; verify only inner hard breaks are preserved * allow relative font size for sub and sup to be set independently; support combined setting for backwards compatibility * upgrade prawn-svg to 0.34 to add support for SVG referenced by image tag (SVG in SVG) +* drop links from entries in TOC (#2505) Bug Fixes:: diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index 1e32cd30d..d8a2d04ea 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -3952,6 +3952,7 @@ def ink_toc_level entries, num_levels, dot_leader, num_front_matter_pages entry_title = entry.context == :section ? entry.numbered_title : (entry.title? ? entry.title : (entry.xreftext 'basic')) next if entry_title.empty? theme_font :toc, level: entry_level do + entry_title = entry_title.gsub DropAnchorRx, '' if entry_title.include? '> Started + END + + (expect pdf.pages).to have_size 4 + toc_lines = ((pdf.page 2).text.split ?\n).reject(&:empty?) + (expect toc_lines).to have_size 3 + (expect toc_lines[0]).to eql 'Table of Contents' + (expect toc_lines[1]).to start_with 'Once Upon a Time' + (expect toc_lines[2]).to start_with 'Continuing What Once Upon a Time Started' + annots = get_annotations pdf, 2 + (expect annots).to have_size 4 + (expect annots.map {|it| it[:Dest] }.sort).to eql %w(ch1 ch1 ch2 ch2) + end + it 'should allow extended converter to insert extra page before toc' do backend = nil create_class (Asciidoctor::Converter.for 'pdf') do