diff options
| author | Dan Allen <dan.j.allen@gmail.com> | 2022-04-27 15:31:09 -0600 |
|---|---|---|
| committer | Dan Allen <dan.j.allen@gmail.com> | 2022-04-27 15:31:09 -0600 |
| commit | 98ea136e8c5d1b368960b18f2a7507599adbc124 (patch) | |
| tree | c81b87c2627c674ecdcb57a20b6062f5f2d369cf | |
| parent | e749cf0485ac77587eecc99478841819d4f7050d (diff) | |
update delete_page to handle dests in subtrees
| -rw-r--r-- | lib/asciidoctor/pdf/ext/prawn/extensions.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/asciidoctor/pdf/ext/prawn/extensions.rb b/lib/asciidoctor/pdf/ext/prawn/extensions.rb index fcafe60c..1e36c53f 100644 --- a/lib/asciidoctor/pdf/ext/prawn/extensions.rb +++ b/lib/asciidoctor/pdf/ext/prawn/extensions.rb @@ -819,7 +819,10 @@ module Asciidoctor pdf_store = state.store content_id = page.content.identifier page_ref = page.dictionary - dests.data.children.delete_if {|entry| entry.value.data[0] == page_ref } + (prune_dests = proc do |node| + node.children.delete_if {|it| ::PDF::Core::NameTree::Node === it ? prune_dests[it] : it.value.data[0] == page_ref } + false + end)[dests.data] # NOTE: cannot delete objects and IDs, otherwise references get corrupted; so just reset the value (pdf_store.instance_variable_get :@objects)[content_id] = ::PDF::Core::Reference.new content_id, {} pdf_store.pages.data[:Kids].pop |
