-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 = top:: Doc
+
+Doc = doc:: {Header} Body /ws
+Header = header:: "header" { kv */ ws } /ws
+Body = body:: Section*/ws
+Section = { section:: SectionHeader Paragraph* /ws }
+SectionHeader = "==" SectionHeaderBody "=="
+SectionHeaderBody = "=" SectionHeaderBody "="
+ > !ws text !ws
+
+sp = " "**
+blank = !sp "\n" !sp "\n" !ws
+
+kv = kv1:: word "=" text /ws
+wp = w++
+num = [0-9]++
+Paragraph = blockquote:: { "\"\"" !ws text }
+ > hr:: { "---" "-"* }
+ > p:: { text }
+
+onums = nums !(". "|") ")
+any = ~[]*
+
+uli = li:: "* " (!ws text &~ any (oli|uli))
+oli = li:: ("# "|onums) (!ws text &~ any (oli|uli))
+
+//
+
+text = text:: Item
+Itemx = !ws Item
+ | ()
+Item = blockquote
+ > "[]":: { ul:: uli+/ws } Itemx
+ | "[]":: { ol:: oli+/ws } Itemx
+ > "[]":: pre Itemx
+ > "[]":: structured Itemx
+ > "[]":: structuredx Itemx
+ > "[]":: styled Itemx
+ > "[]":: qtext Itemx
+ > "[]":: (stringify:: alphanum++) Itemx
+ > "[]":: symbol Itemx
+ > "[]":: (stringify:: sym++) Itemx
+ > "[]":: Paragraph Itemx
+
+blockquote = blockquote:: "\"\"" text "\"\""
+ | blockquote:: "\"\"" block
+
+qtext = quoted:: "\"" 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)
+ > it:: "*" text "*"
+
+//
+
+block = { text }
+structured = link:: { text } "->" (url|email)
+ //> alphanum++ "->" (url|email) => link
+structuredx = glyph
+ > email
+ > url
+
+glyph = "(r)" | "(c)" | "(tm)" | "--" // euro symbol?
+ | today:: "\\today" -> ~[a-z]