2 // interactions between !=> and &~ mean that I need to rethink the chartage
3 // indentation styling...
4 // literal blocks [[need to ignore bracing]] double-colon style?
5 // definition -- by prior line indentation, like headings in the original structured text
8 // output formats: latex, contex, ps, pdf, html, man, txt, rfc
16 // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build...
21 //////////////////////////////////////////////////////////////////////////////
25 Doc ::= {Header} Body /ws => doc
26 Header ::= "header" { kv */ ws } /ws => header
27 Body ::= Section*/ws => body
28 Section ::= { SectionHeader Paragraph* /ws => section }
29 SectionHeader ::= "==" SectionHeaderBody "=="
30 SectionHeaderBody ::= "=" SectionHeaderBody "="
34 blank ::= sp "\n" sp "\n" ws
36 kv ::= word "=" text /ws => kv1
39 Paragraph ::= { "\"\"" ws text } => "blockquote"
40 > { "---" "-"* } => "hr"
43 onums !::= nums (". "|") ")
46 uli ::= "* " (ws text &~ any (oli|uli)) => "li"
47 oli ::= ("# "|onums) (ws text &~ any (oli|uli)) => "li"
53 > { uli+/ws => "ul" } Itemx => []
54 | { oli+/ws => "ol" } Itemx => []
56 > structured Itemx => []
57 > structuredx Itemx => []
60 > (alphanum++ => stringify) Itemx => []
62 > (sym++ => stringify) Itemx => []
63 > Paragraph Itemx => []
65 blockquote ::= "\"\"" text "\"\"" => "blockquote"
66 | "\"\"" block => "blockquote"
68 qtext ::= "\"" text "\"" => "quoted"
69 pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
71 styled ::= "__" text "__" => underline
72 | "((" text "))" => footnote
73 | ( "[[" text "]]" => tt
74 > "[" word "]" => citation
76 | "!!" text "!!" => strikethrough
77 | "^^" (word|block) => superscript
78 | ",," (word|block) => subscript
79 | "\\sc" block => smallcap
80 | "**" text "**" => bold
81 | "!" (word|block) => keyword
85 structured ::= { text } "->" (url|email) => link
86 //> alphanum++ "->" (url|email) => link
91 glyph ::= "(r)" | "(c)" | "(tm)" | "--" // euro symbol?
92 | "\\today" -> ~[a-z] => today
95 // URLs //////////////////////////////////////////////////////////////////////////////
97 // interesting opportunity to show off boolean grammars here: define other
98 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
99 // only gets parsed once
102 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
103 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
104 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
105 | "%" [0-9] [0-9] => "%"
106 url ::= "mailto" ":" email
107 > method "://" url_login? host (":" nums)? ("/" urlpath)? => "url"
108 url_login ::= username (":" password) "@" => "login"
109 method ::= [+\-.a-z0-9]+ => stringify
110 domain ::= (part +/ ".") -> ~"." => domain
111 part ::= [a-zA-Z0-9\-]++ => stringify
112 // interesting use of boolean grammars
113 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
115 email ::= username "@" host -> ~[.] => emailaddr
116 nums ::= [0-9]++ => stringify
117 host ::= nums "." nums "." nums "." nums => "ip"
122 // Tokens ///////////////////////////////////////////////////////////////////
124 word ::= alphanum++ => stringify
127 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
129 escaped ::= "\\n" => "\n"
134 // Chars ///////////////////////////////////////////////////////////////
138 alphanum ::= [a-zA-Z0-9]
139 sym ::= ~[a-zA-Z0-9\ \r\n=\">]