Skip to content

Commit

Permalink
rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Oct 28, 2016
1 parent 6fa9299 commit 6a8e78c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2460,15 +2460,15 @@ def layout_running_content periphery, doc, opts = {}

def add_outline doc, num_levels = 2, toc_page_nums = [], num_front_matter_pages = 0
front_matter_counter = RomanNumeral.new 0, :lower
page_num_labels = {}
pagenum_labels = {}

num_front_matter_pages.times do |n|
page_num_labels[n] = { P: (::PDF::Core::LiteralString.new front_matter_counter.next!.to_s) }
pagenum_labels[n] = { P: (::PDF::Core::LiteralString.new front_matter_counter.next!.to_s) }
end

# add labels for each content page in case the page has no matching entry in the outline
(num_front_matter_pages..(page_count - 1)).each_with_index do |n, i|
page_num_labels[n] = { P: (::PDF::Core::LiteralString.new %(#{i + 1})) }
pagenum_labels[n] = { P: (::PDF::Core::LiteralString.new %(#{i + 1})) }
end

outline.define do
Expand All @@ -2479,27 +2479,27 @@ def add_outline doc, num_levels = 2, toc_page_nums = [], num_front_matter_pages
end
page title: (doc.attr 'toc-title'), destination: (document.dest_top toc_page_nums.first) if toc_page_nums.first
# QUESTION any way to get add_outline_level to invoke in the context of the outline?
document.add_outline_level self, doc.sections, num_levels, page_num_labels, num_front_matter_pages
document.add_outline_level self, doc.sections, num_levels, pagenum_labels, num_front_matter_pages
end

catalog.data[:PageLabels] = state.store.ref Nums: page_num_labels.flatten
catalog.data[:PageLabels] = state.store.ref Nums: pagenum_labels.flatten
catalog.data[:PageMode] = :UseOutlines
nil
end

# TODO only nest inside root node if doctype=article
def add_outline_level outline, sections, num_levels, page_num_labels, num_front_matter_pages
def add_outline_level outline, sections, num_levels, pagenum_labels, num_front_matter_pages
sections.each do |sect|
sect_title = sanitize sect.numbered_title formal: true
sect_destination = sect.attr 'pdf-destination'
pgnum_label = (pgnum = sect.attr 'pdf-page-start') - num_front_matter_pages
# QUESTION do we even need this assignment anymore?
page_num_labels[pgnum - 1] = { P: ::PDF::Core::LiteralString.new(pgnum_label.to_s) }
pagenum_labels[pgnum - 1] = { P: ::PDF::Core::LiteralString.new(pgnum_label.to_s) }
if (subsections = sect.sections).empty? || sect.level == num_levels
outline.page title: sect_title, destination: sect_destination
elsif sect.level < num_levels + 1
outline.section sect_title, { destination: sect_destination } do
add_outline_level outline, subsections, num_levels, page_num_labels, num_front_matter_pages
add_outline_level outline, subsections, num_levels, pagenum_labels, num_front_matter_pages
end
end
end
Expand Down

0 comments on commit 6a8e78c

Please sign in to comment.