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 > { "*" " " ws text } => "ul"
41 > { "#" " " ws text } => "ol"
42 > { num " " ws text } => "ol"
43 > { "---" "-"* } => "hr"
47 Itemx ::= ws Item | ()
50 > structured Itemx => []
51 > structuredx Itemx => []
54 > alphanum++ Itemx => []
56 // > sym++ Itemx => []
57 > Paragraph Itemx => []
61 blockquote ::= "\"\"" text "\"\"" => "blockquote"
62 | "\"\"" block => "blockquote"
64 qtext ::= "\"" text "\"" => "quoted"
65 pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
67 styled ::= "__" text "__" => ul
68 | "((" text "))" => footnote
69 | ( "[[" text "]]" => tt
70 > "[" word "]" => citation
72 | "!!" text "!!" => strikethrough
73 | "^^" (word|block) => superscript
74 | ",," (word|block) => subscript
75 | "\\sc" block => smallcap
76 | "**" text "**" => bold
77 | "!" (word|block) => keyword
81 structured ::= { text } "->" (url|email) => link
82 //> alphanum++ "->" (url|email) => link
87 glyph ::= "(r)" | "(c)" | "(tm)" | "--" // euro symbol?
88 | "\\today" -> ~[a-z] => today
91 // URLs //////////////////////////////////////////////////////////////////////////////
93 // interesting opportunity to show off boolean grammars here: define other
94 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
95 // only gets parsed once
98 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++
99 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++
100 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
101 | "%" [0-9] [0-9] => "%"
102 url ::= "mailto" ":" email
103 > method "://" url_login? host (":" port)? ("/" urlpath)? => "url"
104 url_login ::= username (":" password) "@" => "login"
105 method ::= [+\-.a-z0-9]+
108 domain ::= (part +/ ".") -> ~"."
109 part ::= [a-zA-Z0-9\-]++ // interesting use of boolean grammars
110 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
112 email ::= username "@" host -> ~[.] => emailaddr
113 host ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
118 // Tokens ///////////////////////////////////////////////////////////////////
123 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
125 escaped ::= "\\n" => "\n"
130 // Chars ///////////////////////////////////////////////////////////////
134 alphanum ::= [a-zA-Z0-9]
135 sym ::= ~[a-zA-Z0-9\ \r\n=\">]