From 68ccfcbf5d77ce93a41c4f2a2380e1057dcf750c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Faur=C3=A9?= Date: Wed, 26 Apr 2023 11:41:18 +0200 Subject: [PATCH] test function --- spip2md/content.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/spip2md/content.py b/spip2md/content.py index 9ddf346..0531f85 100644 --- a/spip2md/content.py +++ b/spip2md/content.py @@ -5,15 +5,6 @@ from lark import Lark spipParser = Lark(open(path.dirname(__file__) + "/spip.lark")) -# Test -print("\n--- First test") -text = open(path.dirname(__file__) + "/../test/1.spip").read() -print(spipParser.parse(text).pretty()) -print("\n--- Second test") -text = open(path.dirname(__file__) + "/../test/2.spip").read() -print(spipParser.parse(text).pretty()) - - class content: def __init__(self, content): self.spip = content @@ -21,3 +12,17 @@ class content: def get_markdown(self): markdown = self.spip return markdown + + +# Parses a file & display its parse tree +def test(filename): + print(f"--- Parsing of {filename}") + parsed = spipParser.parse(open(path.dirname(__file__) + "/" + filename).read()) + print(parsed) + print(parsed.pretty()) + print() + + +# Test +test("../test/1.spip") +test("../test/2.spip")