Commit 29f41d66 authored by Marco Cavalli's avatar Marco Cavalli
Browse files

feat: add spacing only after a sequence of list items

parent 2c9aa484
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -551,10 +551,12 @@ def add_tagged_styles_and_formatting(doc: Doc):
def set_keep_with_next_false(doc: Doc):
    """By default, `keep with next` is set to `True`. This has the effect of adding blocks of whitespace throughout the document. For all paragraphs, ensure `keep with next` is set to `False` to maintain visual continuity within the document."""

    previous_paragraph = None
    for paragraph in iter_paragraphs(doc):
        paragraph.paragraph_format.keep_with_next = False
        paragraph.paragraph_format.space_after = Pt(12)

        if previous_paragraph and previous_paragraph.style.name in "Compact" and paragraph.style.name not in "Compact":
            previous_paragraph.paragraph_format.space_after = Pt(12)
        previous_paragraph = paragraph

    return doc