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 /ws => section
29 SectionHeader ::= "==" SectionHeaderBody "=="
30 SectionHeaderBody ::= "=" SectionHeaderBody "="
33 kv ::= word "=" text /ws => kv1
36 Paragraph ::= { "\"\"" ws text } => "blockquote"
37 > { "*" " " ws text } => "ul"
38 > { "#" " " ws text } => "ol"
39 > { num " " ws text } => "ol"
40 > { "---" "-"* } => "hr"
44 itemx ::= ws item => "w" | ()
45 item ::= blockquote => "b"
47 > structured itemx => "1"
48 > structuredx itemx => "2"
51 > alphanum++ itemx => "5"
53 // > sym++ itemx => []
54 > Paragraph itemx => "7"
58 blockquote ::= "\"\"" text "\"\"" => "blockquote"
59 | "\"\"" block => "blockquote"
61 qtext ::= "\"" text "\"" => "quoted"
62 pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
64 styled ::= "__" text "__" => ul
65 | "((" text "))" => footnote
66 | ( "[[" text "]]" => tt
67 > "[" word "]" => citation
69 | "!!" text "!!" => strikethrough
70 | "^^" (word|block) => superscript
71 | ",," (word|block) => subscript
72 | "\\sc" block => smallcap
73 | "**" text "**" => bold
74 | "!" (word|block) => keyword
78 structured ::= { text } "->" (url|email) => link
79 //> alphanum++ "->" (url|email) => link
84 glyph ::= "(r)" | "(c)" | "(tm)" | "--" // euro symbol?
85 | "\\today" -> ~[a-z] => today
88 // URLs //////////////////////////////////////////////////////////////////////////////
90 // interesting opportunity to show off boolean grammars here: define other
91 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
92 // only gets parsed once
95 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++
96 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++
97 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
98 | "%" [0-9] [0-9] => "%"
99 url ::= "mailto" ":" email
100 > method "://" url_login? host (":" port)? ("/" urlpath)? => "url"
101 url_login ::= username (":" password) "@" => "login"
102 method ::= [+\-.a-z0-9]+
105 domain ::= (part +/ ".") -> ~"."
106 part ::= [a-zA-Z0-9\-]++ // interesting use of boolean grammars
107 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
109 email ::= username "@" host -> ~[.] => emailaddr
110 host ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
115 // Tokens ///////////////////////////////////////////////////////////////////
120 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
122 escaped ::= "\\n" => "\n"
127 // Chars ///////////////////////////////////////////////////////////////
131 alphanum ::= [a-zA-Z0-9]
132 sym ::= ~[a-zA-Z0-9\ \r\n=\">]