Don't double space the title page.

This commit is contained in:
Dan Helfman 2024-01-04 10:32:40 -08:00
parent b549d8117c
commit 5d3eba05ff
1 changed files with 14 additions and 7 deletions

View File

@ -86,21 +86,28 @@ def double_space_and_indent(paragraphs):
previous_paragraph = None
this_paragraph_plaintext = False
previous_paragraph_plaintext = None
reached_first_heading = False
for paragraph in paragraphs:
paragraph.paragraph_format.line_spacing = 2
paragraph.paragraph_format.space_before = docx.shared.Inches(0)
paragraph.paragraph_format.space_after = docx.shared.Inches(0)
# To reduce page count, allow splitting paragraphs across pages.
paragraph.paragraph_format.widow_control = False
this_paragraph_plaintext = not (
paragraph.style.name.startswith('Heading')
or paragraph.style.name == '0 Block'
or paragraph.style.paragraph_format.left_indent
or paragraph.style.paragraph_format.right_indent
)
if not this_paragraph_plaintext:
reached_first_heading = True
# Skip past the title page until we reach the first chapter/other heading.
if not reached_first_heading:
continue
paragraph.paragraph_format.line_spacing = 2
paragraph.paragraph_format.space_before = docx.shared.Inches(0)
paragraph.paragraph_format.space_after = docx.shared.Inches(0)
# To reduce page count, allow splitting paragraphs across pages.
paragraph.paragraph_format.widow_control = False
# Indent first lines of paragraphs except for styled ones (headings, etc.) and initial
# paragraphs.