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 num !::= [0-9]++ => "stringify"
51 Paragraph ::= { "\"\"" ws text } => "blockquote"
52 > { "*" " " ws text } => "ul"
53 > { "#" " " ws text } => "ol"
54 > { num " " ws text } => "ol"
55 > { "---" "-"* } => "hr"
59 pre ::= "[verbatim]" { ~[]+ } /ws => "verbatim" // FIXME doesn't work
64 > "\"" text "\"" => quoted
65 > alphanum++ => "stringify"
68 symbol ::= symbolx & sym++
69 symbolx ::= "--" => emdash
74 styled ::= "**" text "**" => bold
75 | "__" text "__" => ul
76 | "~~" text "~~" => it // hard to type
77 | "((" text "))" => footnote
82 glyph ::= "(r)" | "(c)" | "(tm)" // euro symbol?
85 // URLs //////////////////////////////////////////////////////////////////////////////
87 // interesting opportunity to show off boolean grammars here: define other
88 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
89 // only gets parsed once
92 username ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => "stringify"
93 password ::= [a-zA-Z0-9;/?:&=$\-_.+]++ => "stringify"
94 urlchar ::= [a-zA-Z0-9;/?:&=$\-_.+@]
95 | "%" [0-9] [0-9] => "%"
96 url ::= "mailto" ":" email
97 > method "://" url_login? host (":" port)? ("/" urlpath)? => "url"
98 url_login ::= username (":" password) "@" => "login"
99 method ::= [+\-.a-z0-9]+
102 domain ::= part +/ "."
103 part ::= [a-zA-Z0-9\-]++ => "stringify" // interesting use of boolean grammars
104 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
106 email ::= username "@" host => email
107 host ::= [0-9]+ "." [0-9]+ "." [0-9]+ "." [0-9]+ => "ip"
112 // Tokens ///////////////////////////////////////////////////////////////////
114 word ::= alphanum++ => "stringify"
117 quoted ::= "\"" ((~[\"\\] | escaped)+) "\""
119 escaped ::= "\\n" => "\n"
124 // Chars ///////////////////////////////////////////////////////////////
128 alphanum ::= [a-zA-Z0-9]
129 sym ::= ~[a-zA-Z0-9\ \r\n]