blob: 4fb3295f938a1bcdf9db95c9e029d5a8f4f3fd9b (
plain)
- # 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 / HardBreak))+
- 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'
|