diff --git a/uml.py b/uml.py index 40fe46b..4a52235 100644 --- a/uml.py +++ b/uml.py @@ -126,12 +126,15 @@ def renderer(chain): cbuf = " " cbuf += i print(cbuf) + elif i.element == "x": + print(i.data) if rendered: print() chain = [] flags = { "TABLE_PREV": False, "PARA_PREV": False, + "IN_PREFORMATTED": False, } def main(): for i in finput(): @@ -141,7 +144,7 @@ def main(): if len(i) == 0: continue # lines with text - if i[0].isalpha(): + if i[0].isalpha() and not flags["IN_PREFORMATTED"]: if not flags["PARA_PREV"]: flags["PARA_PREV"] = True chain.append(Element("p", i)) @@ -152,8 +155,17 @@ def main(): chain[-1].data += i continue + if i[0:3] == '```': + if not flags["IN_PREFORMATTED"]: + flags["IN_PREFORMATTED"] = True + params = i[3:] + chain.append(Element("x", "", params)) + else: + flags["IN_PREFORMATTED"] = False + continue + # we have a processing command - if not i[0].isalpha(): + if not i[0].isalpha() and not flags["IN_PREFORMATTED"]: command = "" params = "" counter = 0 @@ -185,6 +197,8 @@ def main(): flags["TABLE_PREV"] = False flags["PARA_PREV"] = False continue + elif flags["IN_PREFORMATTED"]: + chain[-1].data += i + "\n" renderer(chain) if __name__ == "__main__": main()