Skip to content

Commit 05491d8

Browse files
committed
BodyPageTemplate.chapter_title_height: handle None value
When chapter_title_height is None, use a DownExpandingContainer instead of a FlowablesContainer with a fixed height.
1 parent ac6b2fa commit 05491d8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CHANGES.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ New Features:
3030
font_color = #333
3131

3232
* Relocating chapters to other document parts (e.g. front matter) is now
33-
possible by assigning the *out-of-line* class and a custom class to a section::
33+
possible by assigning the *out-of-line* class and a custom class to a
34+
section::
3435

3536
.. rst-class:: out-of-line front-matter
3637

@@ -52,6 +53,9 @@ New Features:
5253

5354
Changed:
5455

56+
* The default for BodyPageTemplate.chapter_title_height is now ``None``, which
57+
creates a DownExpaningContainer for the chapter title flowables instead of
58+
one with a fixed height.
5559
* Add support for Python 3.13 and 3.14
5660
* Support for Python 3.8 was dropped (end-of-life in October 2024)
5761
* Improve error message for unsupported nodes (#421)

src/rinoh/template.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class BodyPageTemplate(BodyPageTemplateBase):
163163
chapter_title_flowables = Option(FlowablesList, None,
164164
'Generator that yields the flowables to '
165165
'represent the chapter title')
166-
chapter_title_height = Option(Dimension, 150*PT, 'The height of the '
166+
chapter_title_height = Option(Dimension, None, 'The height of the '
167167
'container holding the chapter title')
168168

169169
def new_chapter_page(self, document_part, page_number, chain):
@@ -278,9 +278,12 @@ def background_image(self):
278278

279279
def get_header_footer_contenttop(self):
280280
height = self.get_option('chapter_title_height')
281-
self.chapter_title = FlowablesContainer('chapter title',
282-
CHAPTER_TITLE, self.body,
283-
0, 0, height=height)
281+
self.chapter_title = (
282+
FlowablesContainer('chapter title', CHAPTER_TITLE, self.body,
283+
0, 0, height=height) if height is not None
284+
else DownExpandingContainer('chapter title', CHAPTER_TITLE,
285+
self.body, 0, 0)
286+
)
284287
header = try_copy(self.get_option('chapter_header_text'))
285288
footer = try_copy(self.get_option('chapter_footer_text'))
286289
return header, footer, self.chapter_title.bottom

0 commit comments

Comments
 (0)