Skip to content

Commit

Permalink
resolves #490 support page layout per page
Browse files Browse the repository at this point in the history
  • Loading branch information
darevan authored and mojavelinux committed Apr 18, 2019
1 parent 5caa838 commit ffc6cbf
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/asciidoctor-pdf/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,14 @@ def convert_toc node

# NOTE to insert sequential page breaks, you must put {nbsp} between page breaks
def convert_page_break node
advance_page unless at_page_top?
opts = {}
# Detect if a page layout change was a role of the page break.
page_layout = resolve_layout_from_node node
opts = {
layout: (page_layout || page.layout),
}

advance_page opts unless at_page_top?
end

def convert_index_section node
Expand Down Expand Up @@ -3301,6 +3308,18 @@ def resolve_alignment_from_role roles
end
end

def resolve_layout_from_node node
if (layout = node.attributes['page-layout']).nil_or_empty? || !(PageLayouts.include?(layout = layout.to_sym))
if (layout = node.roles.reverse.find {|r| PageLayouts.include? r.to_sym })
layout.to_sym
else
nil
end
else
layout.to_sym
end
end

# QUESTION is this method still necessary?
def resolve_imagesdir doc
if (imagesdir = doc.attr 'imagesdir').nil_or_empty? || (imagesdir = imagesdir.chomp '/') == '.'
Expand Down

0 comments on commit ffc6cbf

Please sign in to comment.