1 // interactions between !=> and &~ mean that I need to rethink the chartage
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
15 // "reference-style" links
24 // Arrows: <- -> => <= <->
27 // - attention, caution, danger, error, hint, important, note, tip, warning
30 // figure-with-caption
31 // epigraph (end-of-chapter note)
32 // compound paragraph (??)
38 // simple macros (#define) (\define)
40 // table representation
50 // FIXME: these have to go at the top so they have their dropAll bit set before PreSequence.build...
55 //////////////////////////////////////////////////////////////////////////////
59 Doc = head:Header body:Body /ws
60 Header = H:: { "header" { KeyVal */ ws } /ws }
61 Body = B:: {Section}*/ws
62 Section = SectionHeader Paragraph* /ws
63 SectionHeader = "==" SectionHeaderBody "=="
64 SectionHeaderBody = "=" SectionHeaderBody "="
68 blank = sp! "\n" sp! "\n" ws!
70 KeyVal = key:word "=" val:text /ws
74 Paragraph = Blockquote:: { "\"\" " text }
78 onums = nums (". "|") ")!
81 uli = "* " (ws! text &~ any (oli|uli)!)
82 oli = ("# "|onums)! (ws! text &~ any (oli|uli)!)
90 // "[]":: blockquote ((ws! Item) | ())
92 "[]":: { UL:: uli+/ws } ((ws! Item) | ())
93 | "[]":: { OL:: oli+/ws } ((ws! Item) | ())
94 > "[]":: pre ((ws! Item) | ())
95 > "[]":: link ((ws! Item) | ())
96 > "[]":: structured ((ws! Item) | ())
97 > "[]":: styled ((ws! Item) | ())
98 > "[]":: (Chars:: alphanum++) ((ws! Item) | ())
99 > "[]":: "\"" text "\"" ((ws! Item) | ())
100 > "[]":: (Symbol:: sym++) ((ws! Item) | ())
101 > "[]":: { Block:: text } ((ws! Item) | ())
104 //blockquote = Blockquote:: "\"\"" (block | text "\"\"")
106 pre = Verbatim:: "[verbatim]" { ~[]+ } /ws // FIXME doesn't work
108 styled = Underline:: "__" text "__"
109 | Footnote:: "((" text "))"
110 | TT:: "[[" text "]]"
111 | Citation:: "[" word "]"
112 | Strikethrough:: "!!" text "!!"
113 | Superscript:: "^^" (word|block)
114 | Subscript:: ",," (word|block)
115 | Smallcap:: "\\sc" block
116 | Bold:: "++" text "++"
117 | Keyword:: "!" (word|block)
118 | Italic:: "**" text "**"
122 link = LinkText:: text:({ text }) "->" href:(url|email)
123 > LinkChars:: text:alphanum++ ws! "->" href:(url|email)
125 structured = command & "\\" ([a-zA-Z0-9]++)! block?
130 glyph = Euro:: "(e)" | "(r)" | "(c)" | "(tm)" | emdash:: "--" | "..."
132 command = Today:: "\\today"
135 // URLs //////////////////////////////////////////////////////////////////////////////
137 // interesting opportunity to show off boolean grammars here: define other
138 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
139 // only gets parsed once
142 username = [a-zA-Z0-9;/?:&=$\-_.+]++
143 password = [a-zA-Z0-9;/?:&=$\-_.+]++
144 urlc = [a-zA-Z0-9;/?:&=$\-_.+@]
147 | urlescape:: "%" [0-9] [0-9]
148 url = Mailto:: "mailto" ":" email -> ~urlv
157 url_login = Login:: username:username password:(":" password) "@"
158 method = [+\-.a-z0-9]+
159 domain = (part +/ ".") -> ~"."
160 part = [a-zA-Z0-9\-]++
161 // interesting use of boolean grammars
162 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
164 email = user:username "@" host:host -> ~[.]
166 host = IP:: nums "." nums "." nums "." nums
171 // Tokens ///////////////////////////////////////////////////////////////////
176 quoted = "\"" ((~[\"\\] | escaped)+) "\""
183 // Chars ///////////////////////////////////////////////////////////////
186 alphanum = [a-zA-Z0-9]
187 sym = ~[a-zA-Z0-9\ \r\n=\">]