From b076a26e7e9d31d4b819ca5e5ecb1baaae7f2ac2 Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 18 May 2025 14:08:57 +0200 Subject: tidy PEG grammar --- def.peg | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/def.peg b/def.peg index 336a446..576f884 100644 --- a/def.peg +++ b/def.peg @@ -8,15 +8,23 @@ Markdown <- MetaBlock* Block* # Block elements -Block <- Header / List / LinkDefinition / Paragraph +Block <- Header + / List + / LinkDefinition + / Paragraph Header <- '#'+ SPACE* !NEWLINE Words? SPACE* NEWLINE List <- ([-*]+ / [[:digit:]]+ [).]) (_ (List / Words))? NEWLINE LinkDefinition <- LinkLabel ':' _? Uri (_ LinkTitle)? NEWLINE Paragraph <- Words (HardBreak Words)* NEWLINE+ # Inline elements -Words <- StyledWords / LinkedWords / AnnotatedWords / PlainWords -StyledWords <- '*' Words '*' / '**' Words '**' / '_' Words '_' +Words <- StyledWords + / LinkedWords + / AnnotatedWords + / PlainWords +StyledWords <- '*' Words '*' + / '**' Words '**' + / '_' Words '_' LinkedWords <- '[' Words ']' '(' ((Uri _)? LinkTitle / Uri) ')' / '[' Words ']' LinkLabel / LinkLabel @@ -26,11 +34,15 @@ LinkTitle <- '"' _? !'"' _? PlainWords _? '"' / "'" _? !"'" PlainWords _? "'" / "(" _? ![()] PlainWords _? ")" PlainWords <- PRINTABLES (_ PRINTABLES)* -Uri <- '<' ![<>] PRINTABLES? '>' / ![<>] PRINTABLES +Uri <- '<' ![<>] PRINTABLES? '>' + / ![<>] PRINTABLES HardBreak <- SPACE SPACE+ NEWLINE -_ <- SPACE+ / SPACE? NEWLINE SPACE? SPACE? SPACE? +_ <- SPACE+ + / SPACE? NEWLINE SPACE? SPACE? SPACE? # Terminals PRINTABLES <- [[:graph:]]+ SPACE <- ' ' -NEWLINE <- '\r\n' / '\n' / '\r' +NEWLINE <- '\r\n' + / '\n' + / '\r' -- cgit v1.2.3