aboutsummaryrefslogtreecommitdiff
path: root/def.peg
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-18 11:08:01 +0200
committerJonas Smedegaard <dr@jones.dk>2025-05-18 14:04:21 +0200
commitba1aaf9246f7371bc4c4f8e6636baf44ddf28444 (patch)
treea8eb32ce0d7ad526e9fea948d5a71d345c6c7327 /def.peg
parent72827171201ee9c022a6a8c30107e55a16c3826c (diff)
define _
Diffstat (limited to 'def.peg')
-rw-r--r--def.peg16
1 files changed, 7 insertions, 9 deletions
diff --git a/def.peg b/def.peg
index 4e64c27..8bec09d 100644
--- a/def.peg
+++ b/def.peg
@@ -9,13 +9,10 @@ Markdown <- MetaBlock* Block*
# Block elements
Block <- Header / List / LinkDefinition / Paragraph
-Header <- '#'+ SPACE* Words? SPACE* NEWLINE
-List <- ([-*]+ / [[:digit:]]+ [).]) (SPACE+ (List / Words))?
- NEWLINE
-LinkDefinition <- LinkLabel ':' SPACE Uri NEWLINE
- SPACE SPACE '"' !'"' PlainWords '"' NEWLINE
-Paragraph <- (Words (SPACE? NEWLINE / HardBreak))+
- NEWLINE+
+Header <- '#'+ SPACE* !NEWLINE Words? SPACE* NEWLINE
+List <- ([-*]+ / [[:digit:]]+ [).]) (_ (List / Words))? NEWLINE
+LinkDefinition <- LinkLabel ':' _? Uri (_ '"' !'"' PlainWords '"')? NEWLINE
+Paragraph <- Words (HardBreak Words)* NEWLINE+
# Inline elements
Words <- StyledWords / LinkedWords / AnnotatedWords / PlainWords
@@ -24,10 +21,11 @@ LinkedWords <- '[' Words ']' '(' Uri ')'
/ '[' Words ']' LinkLabel
/ LinkLabel
AnnotatedWords <- '[' Words ']' '{' ![{}] PlainWords '}'
-LinkLabel <- '[' SPACE? ![\[\]] PlainWords SPACE? ']'
-PlainWords <- PRINTABLES (SPACE PRINTABLES)*
+LinkLabel <- '[' _? ![\[\]] PlainWords _? ']'
+PlainWords <- PRINTABLES (_ PRINTABLES)*
Uri <- '<' ![<>] PRINTABLES? '>' / ![<>] PRINTABLES
HardBreak <- SPACE SPACE+ NEWLINE
+_ <- SPACE+ / SPACE? NEWLINE SPACE? SPACE? SPACE?
# Terminals
PRINTABLES <- [[:graph:]]+