60 lines
1.3 KiB
Plaintext
60 lines
1.3 KiB
Plaintext
start: _N? block ( _N+ block )+ _N*
|
|
|
|
?block: heading
|
|
| SEPARATOR
|
|
| unordered_list
|
|
| ordered_list
|
|
| table
|
|
| paragraph
|
|
|
|
heading: "{{{" ( TEXT | link | nested_italic | nested_bold ) "}}}"
|
|
|
|
SEPARATOR: "----" "-"*
|
|
|
|
unordered_list: ( "-*" list_element _N )+
|
|
ordered_list: ( "-#" list_element _N )+
|
|
list_element: _inline_format
|
|
|
|
table: ( row _N )+
|
|
row: ( "|" cell )+ "|"
|
|
cell: _inline_format
|
|
|
|
paragraph: ( _inline_format _N? )+
|
|
|
|
// Windows or Unix line break
|
|
_N: /\r/? /\n/
|
|
|
|
_inline_format: bold
|
|
| italic
|
|
| link
|
|
| TEXT
|
|
|
|
bold: "{{" ( TEXT | link | nested_italic )+ "}}"
|
|
italic: "{" ( TEXT | link | nested_bold )+ "}"
|
|
|
|
nested_bold: _NOT_LBRACE "{{" ( TEXT | link ) "}}" _NOT_RBRACE -> bold
|
|
nested_italic: _NOT_LBRACE "{" ( TEXT | link ) "}" _NOT_RBRACE -> italic
|
|
|
|
_NOT_LBRACE: /[^\{]/
|
|
_NOT_RBRACE: /[^\}]/
|
|
|
|
?link: internal_link
|
|
| external_link
|
|
| footnote
|
|
| glossary
|
|
|
|
internal_link: "[" TEXT "->" TEXT "]"
|
|
external_link: "[" TEXT "->" _PROTOCOL "://" TEXT "]"
|
|
|
|
// Protocol, probably http(s)
|
|
// Is made of 2 to 8 latin letters
|
|
_PROTOCOL: /[a-zA-Z]{2,8}/
|
|
|
|
footnote: "[[" TEXT "]]"
|
|
glossary: "[?" TEXT "]"
|
|
|
|
// Pure text :
|
|
// - Never contains line breaks
|
|
// - Never contains curly braces
|
|
TEXT: /[^\r\n\{\}]/+
|