add paragraph merging
This commit is contained in:
parent
a071793d3c
commit
d5cc217971
14
uml.py
14
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()
|
||||
|
|
Loading…
Reference in New Issue