diff options
| author | Jonas Smedegaard <dr@jones.dk> | 2025-05-17 16:34:36 +0200 |
|---|---|---|
| committer | Jonas Smedegaard <dr@jones.dk> | 2025-05-17 16:34:36 +0200 |
| commit | 8f185d6a88b13eea2f5fdfb6bc34f197b40fb121 (patch) | |
| tree | 6fd4adcdfcd630df0a7ca7c40ea6f75a4a0d4ef1 /def.peg | |
| parent | b4125c5a22700f86784b94fdb8587b7cef8d110b (diff) | |
add chapter on Markdown and annotation
Diffstat (limited to 'def.peg')
| -rw-r--r-- | def.peg | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +# Subsets of Markdown syntax structure +# expressed in parsing expression grammar (PEG) notation. +# +# Copyright 2025, Jonas Smedegaard <dr@jones.dk> +# SPDX-License-Identifier: GPL-3+ + +# Document +Markdown <- MetaBlock* Block* + +# Block elements +Block <- Header / List / LinkDefinition / Paragraph +Header <- '#'+ SPACE* Words? SPACE* NEWLINE +List <- ([-*]+ / [[:digit:]]+ [).]) (SPACE+ (List / Words))? + NEWLINE +LinkDefinition <- '[' !'[]' PlainWords ']:' SPACE Uri NEWLINE + SPACE SPACE '"' !'"' PlainWords '"' NEWLINE +Paragraph <- Words (SPACE? NEWLINE Words / HardBreak Words)* + NEWLINE NEWLINE + +# Inline elements +Words <- StyledWords / LinkedWords / AnnotatedWords / PlainWords +StyledWords <- '*' Words '*' / '**' Words '**' / '_' Words '_' +LinkedWords <- '[' Words ']' '(' Uri ')' + / '[' Words ']' '[' ![\[\]] LinkDefinitionKeyphrase ']' + / '[' LinkDefinitionKeyphrase ']' +AnnotatedWords <- '[' Words ']' '{' ![{}] PlainWords '}' +PlainWords <- PRINTABLES (SPACE PRINTABLES)* +Uri <- '<' ![<>] PRINTABLES? '>' / ![<>] PRINTABLES +HardBreak <- SPACE SPACE NEWLINE + +# Terminals +PRINTABLES <- [[:graph:]]+ +SPACE <- ' ' +NEWLINE <- '\r\n' / '\n' / '\r' |
