11require 'asciidoctor-pdf' unless defined? ::Asciidoctor ::Pdf
22
33module AsciidoctorPdfExtensions
4- # Override the built-in layout_toc to move colophon before front of table of contents
4+ # Override the built-in https://github.com/asciidoctor/asciidoctor-pdf/blob/master/lib/asciidoctor-pdf/converter.rb
5+ # layout_toc to move colophon before front of table of contents
56 # NOTE we assume that the colophon fits on a single page
67 def layout_toc doc , num_levels = 2 , toc_page_number = 2 , num_front_matter_pages = 0
78 go_to_page toc_page_number unless ( page_number == toc_page_number ) || scratch?
@@ -49,18 +50,31 @@ def layout_chapter_title node, title, opts = {}
4950 layout_heading title , size : @theme . base_font_size
5051 elsif sect_id . include? 'chapter' # chapters
5152 puts 'Processing ' + sect_id + '...'
53+
54+ blue = [ 91 , 54 , 8 , 13 ]
55+ green = [ 42 , 1 , 83 , 1 ]
56+ black = [ 0 , 0 , 0 , 100 ]
57+ yellow = 'FFCC02'
58+ red = 'ff0267' # https://www.sessions.edu/color-calculator/
59+ purple = '9a02ff'
60+ light_green = '26FFF4'
61+
5262 # use Akkurat font for all custom headings
5363 font 'Akkurat' do
5464 if node . document . attr? 'media' , 'prepress'
5565 move_down 120
5666 else
5767 move_down 180
5868 end
69+
5970 if @ppbook
6071 layout_heading 'PART' , align : :right , size : 100 , style : :normal
6172 else
62- layout_heading 'PART' , align : :right , size : 100 , color : [ 91 , 54 , 8 , 13 ] , style : :normal
73+ # layout_heading 'PART', align: :right, size: 100, color: blue, style: :normal
74+ # layout_heading 'PART', align: :right, size: 100, color: red, style: :normal
75+ layout_heading 'PART' , align : :right , size : 100 , color : yellow , style : :normal
6376 end
77+
6478 move_up 40
6579
6680 part_number = 'ONE'
@@ -73,12 +87,16 @@ def layout_chapter_title node, title, opts = {}
7387 elsif sect_id . include? 'chapter-5'
7488 part_number = 'FIVE'
7589 end
90+
91+
7692 if @ppbook
7793 layout_heading part_number , align : :right , size : 100 , style : :bold
7894 layout_heading title , align : :right , style : :normal , size : 30
7995 else
80- layout_heading part_number , align : :right , size : 100 , color : [ 42 , 1 , 83 , 1 ] , style : :bold
81- layout_heading title , align : :right , color : [ 42 , 1 , 83 , 1 ] , style : :normal , size : 30
96+ # layout_heading part_number, align: :right, size: 100, color: green, style: :bold
97+ # layout_heading title, align: :right, color: green, style: :normal, size: 30
98+ layout_heading part_number , align : :right , size : 100 , color : yellow , style : :bold
99+ layout_heading title , align : :right , style : :normal , size : 30
82100 end
83101 end
84102
0 commit comments