1 // indentation styling...
2 // literal blocks [[need to ignore bracing]] double-colon style?
3 // definition -- by prior line indentation, like headings in the original structured text
6 // output formats: latex, contex, ps, pdf, html, man, txt, rfc
8 // URGENT: why does swapping [a-zA-Z0-9] for alphanum in "item" cause severe breakage?
9 // URGENT: why does enabling "url" cause severe breakage? (probably same cause)
10 // ... something to do with unit productions
12 // output formats: latex, contex, ps, pdf, html, man, txt, rfc
22 // today's date, last edit date
26 // citations/references
30 // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build...
35 //////////////////////////////////////////////////////////////////////////////
39 Doc ::= Header Body /ws => doc
40 Header ::= "header" { kv */ ws } /ws => header
41 Body ::= Section*/ws => body
42 Section ::= SectionHeader Paragraph*/ws /ws => section
43 SectionHeader ::= "==" SectionHeaderBody "=="
44 SectionHeaderBody ::= "=" SectionHeaderBody "="
47 kv ::= word "=" text /ws => kv1
50 Paragraph ::= { "\"\"" ws text } => "blockquote"
51 > { "*" " " ws text } => "ul"
52 > { "#" " " ws text } => "ol"
53 > { num " " ws text } => "ol"
54 > { "---" "-"* } => "hr"
58 pre ::= "[verbatim]" { [~]+ } /ws => "verbatim" // FIXME doesn't work
63 > "\"" text "\"" => quoted
67 symbol ::= symbolx & sym++
68 symbolx ::= "--" => emdash
73 styled ::= "**" text "**" => bold
74 | "__" text "__" => ul
75 | "~~" text "~~" => it // hard to type
76 | "((" text "))" => footnote
81 glyph ::= "(r)" | "(c)" | "(tm)" // euro symbol?
84 // URLs //////////////////////////////////////////////////////////////////////////////
86 // interesting opportunity to show off boolean grammars here: define other
87 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
88 // only gets parsed once
91 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++
92 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++
93 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
94 | "%" [0-9] [0-9] => "%"
95 url ::= "mailto" ":" email
96 > method "://" url_login? host (":" port)? ("/" urlpath)? => "url"
97 url_login ::= username (":" password) "@" => "login"
98 method ::= [+\-.a-z0-9]+
101 domain ::= part +/ "."
102 part ::= [a-zA-Z0-9\-]++ // interesting use of boolean grammars
103 // &~ ([\-0-9] [~]* | [~]* [\-0-9])
105 email ::= username "@" host => email
106 host ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
111 // Tokens ///////////////////////////////////////////////////////////////////
116 quoted ::= "\"" (([~\"\\] | escaped)+) "\""
118 escaped ::= "\\n" => "\n"
123 // Chars ///////////////////////////////////////////////////////////////
127 alphanum ::= [a-zA-Z0-9]
128 sym ::= [~a-zA-Z0-9\ \r\n]