-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backport fix for #2455 add extended converter use case to place colop…
…hon before TOC
- Loading branch information
1 parent
c443694
commit 1a30248
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
docs/modules/extend/examples/pdf-converter-colophon-placement.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class AsciidoctorPDFExtensions < (Asciidoctor::Converter.for 'pdf') | ||
register_for 'pdf' | ||
|
||
def ink_toc doc, num_levels, toc_page_number, start_cursor, num_front_matter_pages = 0 | ||
colophon = (doc.instance_variable_get :@colophon) || (doc.sections.find {|sect| sect.sectname == 'colophon' }) | ||
return super unless colophon | ||
go_to_page toc_page_number unless (page_number == toc_page_number) || scratch? | ||
if scratch? | ||
(doc.instance_variable_set :@colophon, colophon).parent.blocks.delete colophon | ||
else | ||
# if doctype=book and media=prepress, use blank page before table of contents | ||
go_to_page page_number.pred if @ppbook | ||
convert_section colophon | ||
go_to_page page_number.next | ||
end | ||
offset = @ppbook ? 0 : 1 | ||
toc_page_numbers = super doc, num_levels, (toc_page_number + offset), start_cursor, num_front_matter_pages | ||
scratch? ? ((toc_page_numbers.begin - offset)..toc_page_numbers.end) : toc_page_numbers | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters