From aa046aa45cd5d85c43fac31fae01b14bc7653c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Faur=C3=A9?= Date: Tue, 9 May 2023 14:37:12 +0200 Subject: [PATCH] parser tests --- spip2md/content.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spip2md/content.py b/spip2md/content.py index a5f7df5..53895aa 100644 --- a/spip2md/content.py +++ b/spip2md/content.py @@ -18,3 +18,18 @@ class content: except Exception as e: print(" PARSING FAILED :\n", e) return markdown + +# Parses a file & display its parse tree +def test(filename): + print(f"--- Parsing of {filename} ---\n") + parsed = spipParser.parse(open(path.dirname(__file__) + "/" + filename).read()) + print(parsed, "\n") + print(f"--- Parse tree of {filename} ---\n\n", parsed.pretty(), "\n") + +if __name__ == "__main__": + # Test + test("../test/0.spip") + test("../test/1.spip") + test("../test/2.spip") + test("../test/3.spip") + test("../test/4.spip")