From d5cc2179711c59877ab08d32e4c2315d458fc292 Mon Sep 17 00:00:00 2001 From: randomuser Date: Wed, 30 Jun 2021 13:53:02 -0500 Subject: [PATCH] add paragraph merging --- uml.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/uml.py b/uml.py index e620c17..84dbf4c 100644 --- a/uml.py +++ b/uml.py @@ -129,6 +129,7 @@ def renderer(chain): chain = [] flags = { "TABLE_PREV": False, + "PARA_PREV": False, } def main(): for i in finput(): @@ -138,7 +139,16 @@ def main(): if len(i) == 0: continue # lines with text - if i[0].isalpha(): chain.append(Element("p", i)) + if i[0].isalpha(): + if not flags["PARA_PREV"]: + flags["PARA_PREV"] = True + chain.append(Element("p", i)) + else: + if not chain[-1].data[-1] == " ": + chain[-1].data += " " + i + else: + chain[-1].data += i + continue # we have a processing command if not i[0].isalpha(): @@ -171,8 +181,8 @@ def main(): flags["TABLE_PREV"] = True continue flags["TABLE_PREV"] = False + flags["PARA_PREV"] = False continue -# printchain(chain) renderer(chain) if __name__ == "__main__": main()