-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sidebar doesn't render more than 1 page #259
Comments
Here's the simplest implementation, which doesn't give any page continuation indicators: keep_together do |box_height = nil|
if box_height
float do
initial_page, remaining_height = true, box_height
while remaining_height > 0
start_new_page unless initial_page
fill_height = [(available_height = cursor), remaining_height].min
bounding_box [0, available_height], width: bounds.width, height: fill_height do
theme_fill_and_stroke_bounds :sidebar
end
remaining_height -= fill_height
initial_page = false
end
end
end
pad_box @theme.sidebar_padding do
if node.title?
theme_font :sidebar_title do
layout_heading node.title, align: (@theme.sidebar_title_align || @base_align).to_sym, margin_top: 0
end
end
theme_font :sidebar do
convert_content_for_block node
end
end
end |
Here's the more complex implementation that adds continuation borders the page boundaries within the sidebar block: keep_together do |box_height = nil|
if box_height
float do
if (b_width = @theme.sidebar_border_width || 0) > 0 && (b_color = @theme.sidebar_border_color)
if b_color == @page_bg_color # let page background cut into sidebar background
b_gap_color, b_shift = @page_bg_color, b_width
elsif (b_gap_color = @theme.sidebar_background_color) && b_gap_color != b_color
b_shift = 0
else # let page background cut into border
b_gap_color, b_shift = @page_bg_color, 0
end
else # let page background cut into sidebar background
b_width = 0.5 if b_width == 0
b_shift, b_gap_color = b_width * 0.5, @page_bg_color
end
b_radius = (@theme.sidebar_border_radius || 0) + b_width
initial_page, remaining_height = true, box_height
while remaining_height > 0
start_new_page unless initial_page
fragment_height = [(available_height = cursor), remaining_height].min
bounding_box [0, available_height], width: bounds.width, height: fragment_height do
theme_fill_and_stroke_bounds :sidebar
unless b_width == 0
indent b_radius, b_radius do
move_down b_shift
# dashed line to indicate continuation from previous page; swell line to cover background
stroke_horizontal_rule b_gap_color, line_width: b_width * 1.2, line_style: :dashed
move_up b_shift
end unless initial_page
if remaining_height > fragment_height
move_down fragment_height - b_shift
indent b_radius, b_radius do
# dashed line to indicate continuation to next page; swell line to cover background
stroke_horizontal_rule b_gap_color, line_width: b_width * 1.2, line_style: :dashed
end
end
end
end
remaining_height -= fragment_height
initial_page = false
end
end
end
pad_box @theme.sidebar_padding do
if node.title?
theme_font :sidebar_title do
layout_heading node.title, align: (@theme.sidebar_title_align || @base_align).to_sym, margin_top: 0
end
end
theme_font :sidebar do
convert_content_for_block node
end
end
end |
We have to do a lot of logic to determine how to draw the dashed lines, considering the following scenarios:
|
Hi @mojavelinux! Is it possible to start a sidebar on the same page if it doesn't fit available space? Or should I create another issue for it? |
I have pretty big sidebar block that we use to emphasize Good to Know section.
Apparently, it doesn't render correctly if there is page break.
The text was updated successfully, but these errors were encountered: