From d7247e805a081ba0e398f4702419ed0b16d3ddd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guilhem=20Faur=C3=A9?= Date: Wed, 26 Apr 2023 11:27:05 +0200 Subject: [PATCH] simplified grammar, start in .lark file --- spip2md/content.py | 2 +- spip2md/spip.lark | 29 ++++++++++++----------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/spip2md/content.py b/spip2md/content.py index 5bfa346..9ddf346 100644 --- a/spip2md/content.py +++ b/spip2md/content.py @@ -2,7 +2,7 @@ from os import path from lark import Lark -spipParser = Lark(open(path.dirname(__file__) + "/spip.lark"), start="section") +spipParser = Lark(open(path.dirname(__file__) + "/spip.lark")) # Test diff --git a/spip2md/spip.lark b/spip2md/spip.lark index e804880..4559a85 100644 --- a/spip2md/spip.lark +++ b/spip2md/spip.lark @@ -1,27 +1,22 @@ -section: list - | table - | SEPARATOR - | N+ - | heading | paragraph +start: unordered_list + | ordered_list + | table + | SEPARATOR + | _N+ + | heading + | paragraph -list: unordered_list - | unordered_sublist - | ordered_list - | ordered_sublist - -unordered_list: ( N "-*" list_element )+ -unordered_sublist: ( N "-**" list_element )+ -ordered_list: ( N "-#" list_element )+ -ordered_sublist: ( N "-##" list_element )+ +unordered_list: ( _N "-*" list_element )+ +ordered_list: ( _N "-#" list_element )+ list_element: text -table: ( N row )+ +table: ( _N row )+ row: ( "|" cell )+ "|" cell: text -SEPARATOR: N /-{4,}/ +SEPARATOR: _N /-{4,}/ -N: /\r/? /\n/ +_N: /\r/? /\n/ heading: "{{{" text "}}}"