-s ::= {Doc} => top
-
-Doc ::= Header Body /ws => doc
-Header ::= "header" { kv */ ws } /ws => header
-Body ::= Section*/ws => body
-Section ::= SectionHeader Paragraph*/ws /ws => section
-SectionHeader ::= "==" SectionHeaderBody "=="
-SectionHeaderBody ::= "=" SectionHeaderBody "="
- > ws text ws
-
-kv ::= word "=" text /ws => kv1
-
-num !::= [0-9]++ => "stringify"
-Paragraph ::= { "\"\"" ws text } => "blockquote"
- > { "*" " " ws text } => "ul"
- > { "#" " " ws text } => "ol"
- > { num " " ws text } => "ol"
- > { "---" "-"* } => "hr"
- > { text } => "p"
-
-text ::= item */ ws
-pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
-item ::= pre
- > email
- > structured
- > styled
- > "\"" text "\"" => quoted
- > alphanum++ => "stringify"
- > symbol
-
-symbol ::= symbolx & sym++
-symbolx ::= "--" => emdash
- | ","
- | ":"
- | ";"
-
-styled ::= "**" text "**" => bold
- | "__" text "__" => ul
- | "~~" text "~~" => it // hard to type
- | "((" text "))" => footnote
-
-structured ::= glyph
-// | url
-
-glyph ::= "(r)" | "(c)" | "(tm)" // euro symbol?
-
+s = Doc
+
+Doc = head:Header body:Body /ws
+Header = H:: { "header" { KeyVal */ ws } /ws }
+Body = B:: {Section}*/ws
+Section = SectionHeader ws! (Paragraph Paragraph)
+SectionHeader = "==" SectionHeaderBody "=="
+SectionHeaderBody = "=" SectionHeaderBody "="
+ > ws! alphanum++ ws!
+
+sp = " "**
+blank = sp! "\n" sp! "\n" ws!
+
+KeyVal = key:word "=" val:text /ws
+wp = w++
+num = [0-9]++
+
+Paragraph = Blockquote:: { "\"\" " text }
+ > HR:: { "---" "-"* }
+ > P:: { text }
+
+onums = nums (". "|") ")!
+any = ~[]*
+
+uli = "* " (ws! text &~ any (oli|uli)!)
+oli = ("# "|onums)! (ws! text &~ any (oli|uli)!)
+
+text = Item
+
+Item*/ws =
+ blockquote
+ > { UL:: uli+/ws }
+ | { OL:: oli+/ws }
+ > pre
+ > link
+ > structured
+ > styled
+ > (Chars:: alphanum++)
+ > "\"" text "\""
+ > (Symbol:: sym++)
+// > { Block:: text }
+
+blockquote = "adsfafewag"
+//blockquote = Blockquote:: "\"\"" (block | text "\"\"")
+
+pre = Verbatim:: "[verbatim]" { ~[]+ } /ws // FIXME doesn't work
+
+styled = Underline:: "__" text "__"
+ | Footnote:: "((" text "))"
+ | TT:: "[[" text "]]"
+ | Citation:: "[" word "]"
+ | Strikethrough:: "!!" text "!!"
+ | Superscript:: "^^" (word|block)
+ | Subscript:: ",," (word|block)
+ | Smallcap:: "\\sc" block
+ | Bold:: "++" text "++"
+ | Keyword:: "!" (word|block)
+ | Italic:: "**" text "**"
+
+block = { text }
+
+link = LinkText:: text:({ text }) "->" href:(url|email)
+ > LinkChars:: text:alphanum++ ws! "->" href:(url|email)
+
+structured = command & "\\" ([a-zA-Z0-9]++)! block?
+ > glyph
+ > email
+ > url
+
+glyph = Euro:: "(e)" | "(r)" | "(c)" | "(tm)" | emdash:: "--" | "..."
+
+command = Today:: "\\today"
+ | LineBreak:: "\\br"