Remove duplicate empty paragraphs to cut down on vertical whitespace.
continuous-integration/drone/push Build is running Details

This commit is contained in:
Dan Helfman 2023-02-03 11:46:03 -08:00
parent 143a42446f
commit 5789f9b188
1 changed files with 6 additions and 0 deletions

View File

@ -70,6 +70,7 @@ def right_align_header(document):
def double_space_and_indent(paragraphs):
this_paragraph_plaintext = False
previous_paragraph_plaintext = False
previous_paragraph_style = None
for paragraph in paragraphs:
paragraph.paragraph_format.line_spacing = 2
@ -88,7 +89,12 @@ def double_space_and_indent(paragraphs):
if this_paragraph_plaintext and previous_paragraph_plaintext:
paragraph.paragraph_format.first_line_indent = docx.shared.Inches(0.5)
# Remove duplicate empty paragraphs to cut down on vertical whitespace.
if paragraph.style == previous_paragraph_style and not paragraph.text:
paragraph._element.getparent().remove(paragraph._element)
previous_paragraph_plaintext = this_paragraph_plaintext
previous_paragraph_style = paragraph.style
def parse_arguments(unparsed_arguments):