2 // indentation styling...
3 // literal blocks [[need to ignore bracing]] double-colon style?
4 // definition -- by prior line indentation, like headings in the original structured text
7 // output formats: latex, contex, ps, pdf, html, man, txt, rfc
9 // URGENT: why does swapping [a-zA-Z0-9] for alphanum in "item" cause severe breakage?
10 // URGENT: why does enabling "url" cause severe breakage? (probably same cause)
11 // ... something to do with unit productions
13 // output formats: latex, contex, ps, pdf, html, man, txt, rfc
23 // today's date, last edit date
27 // citations/references
31 // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build...
36 //////////////////////////////////////////////////////////////////////////////
38 s ::= { Doc } => "top"
40 Doc ::= Header Body /ws => doc
41 Header ::= "header" { kv */ ws } /ws => header
42 Body ::= Section*/ws => body
43 Section ::= SectionHeader Paragraph*/ws /ws => section
44 SectionHeader ::= "==" SectionHeaderBody "=="
45 SectionHeaderBody ::= "=" SectionHeaderBody "="
48 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
64 > alphanum++ => "stringify"
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;/?:&=$\-_.+]++ => "stringify"
92 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => "stringify"
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\-]++ => "stringify"
103 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
105 email ::= username "@" host => email
107 | [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
111 // Tokens ///////////////////////////////////////////////////////////////////
113 word ::= alphanum++ => "stringify"
116 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
118 escaped ::= "\\n" => "\n"
123 // Chars ///////////////////////////////////////////////////////////////
126 num !::= [0-9]++ => "stringify"
128 alphanum ::= [a-zA-Z0-9]
129 sym ::= ~[a-zA-Z0-9\ \r\n]