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"
41 > { "# " text } => "ol"
42 > { num " " ws text } => "ol"
43 > { "---" "-"* } => "hr"
45 uli ::= { "* " text } => "li"
52 > structured Itemx => []
53 > structuredx Itemx => []
56 > (alphanum++ => stringify) Itemx => []
58 > (sym++ => stringify) Itemx => []
60 > Paragraph Itemx => []
62 blockquote ::= "\"\"" text "\"\"" => "blockquote"
63 | "\"\"" block => "blockquote"
65 qtext ::= "\"" text "\"" => "quoted"
66 pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
68 styled ::= "__" text "__" => underline
69 | "((" text "))" => footnote
70 | ( "[[" text "]]" => tt
71 > "[" word "]" => citation
73 | "!!" text "!!" => strikethrough
74 | "^^" (word|block) => superscript
75 | ",," (word|block) => subscript
76 | "\\sc" block => smallcap
77 | "**" text "**" => bold
78 | "!" (word|block) => keyword
82 structured ::= { text } "->" (url|email) => link
83 //> alphanum++ "->" (url|email) => link
88 glyph ::= "(r)" | "(c)" | "(tm)" | "--" // euro symbol?
89 | "\\today" -> ~[a-z] => today
92 // URLs //////////////////////////////////////////////////////////////////////////////
94 // interesting opportunity to show off boolean grammars here: define other
95 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
96 // only gets parsed once
99 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
100 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => stringify
101 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
102 | "%" [0-9] [0-9] => "%"
103 url ::= "mailto" ":" email
104 > method "://" url_login? host (":" nums)? ("/" urlpath)? => "url"
105 url_login ::= username (":" password) "@" => "login"
106 method ::= [+\-.a-z0-9]+ => stringify
107 domain ::= (part +/ ".") -> ~"." => domain
108 part ::= [a-zA-Z0-9\-]++ => stringify
109 // interesting use of boolean grammars
110 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
112 email ::= username "@" host -> ~[.] => emailaddr
113 nums ::= [0-9]++ => stringify
114 host ::= nums "." nums "." nums "." nums => "ip"
119 // Tokens ///////////////////////////////////////////////////////////////////
121 word ::= alphanum++ => stringify
124 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
126 escaped ::= "\\n" => "\n"
131 // Chars ///////////////////////////////////////////////////////////////
135 alphanum ::= [a-zA-Z0-9]
136 sym ::= ~[a-zA-Z0-9\ \r\n=\">]