aboutsummaryrefslogtreecommitdiff
path: root/def.peg
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-18 12:41:35 +0200
committerJonas Smedegaard <dr@jones.dk>2025-05-18 14:05:02 +0200
commit90d5b0125fb943eea852ab14ed7a8243c86d7d21 (patch)
treeadcd22463cc5b7654551db156b9f737741475edb /def.peg
parentba1aaf9246f7371bc4c4f8e6636baf44ddf28444 (diff)
define LinkTitle
Diffstat (limited to 'def.peg')
-rw-r--r--def.peg7
1 files changed, 5 insertions, 2 deletions
diff --git a/def.peg b/def.peg
index 8bec09d..336a446 100644
--- a/def.peg
+++ b/def.peg
@@ -11,17 +11,20 @@ Markdown <- MetaBlock* Block*
Block <- Header / List / LinkDefinition / Paragraph
Header <- '#'+ SPACE* !NEWLINE Words? SPACE* NEWLINE
List <- ([-*]+ / [[:digit:]]+ [).]) (_ (List / Words))? NEWLINE
-LinkDefinition <- LinkLabel ':' _? Uri (_ '"' !'"' PlainWords '"')? NEWLINE
+LinkDefinition <- LinkLabel ':' _? Uri (_ LinkTitle)? NEWLINE
Paragraph <- Words (HardBreak Words)* NEWLINE+
# Inline elements
Words <- StyledWords / LinkedWords / AnnotatedWords / PlainWords
StyledWords <- '*' Words '*' / '**' Words '**' / '_' Words '_'
-LinkedWords <- '[' Words ']' '(' Uri ')'
+LinkedWords <- '[' Words ']' '(' ((Uri _)? LinkTitle / Uri) ')'
/ '[' Words ']' LinkLabel
/ LinkLabel
AnnotatedWords <- '[' Words ']' '{' ![{}] PlainWords '}'
LinkLabel <- '[' _? ![\[\]] PlainWords _? ']'
+LinkTitle <- '"' _? !'"' _? PlainWords _? '"'
+ / "'" _? !"'" PlainWords _? "'"
+ / "(" _? ![()] PlainWords _? ")"
PlainWords <- PRINTABLES (_ PRINTABLES)*
Uri <- '<' ![<>] PRINTABLES? '>' / ![<>] PRINTABLES
HardBreak <- SPACE SPACE+ NEWLINE