diff --git a/format_novel/format_novel.py b/format_novel/format_novel.py index 94a8c61..fb1f19f 100755 --- a/format_novel/format_novel.py +++ b/format_novel/format_novel.py @@ -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.