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 ws! body:Body
60 Header = { "\\header" { KeyVal */ ws } /ws }
61 Body = { Section } */ws
62 Section = SectionHeader ws! Paragraph*
63 SectionHeader = "==" SectionHeaderBody "=="
64 SectionHeaderBody = "=" SectionHeaderBody "="
68 blank = sp! "\n" sp! "\n" ws!
70 KeyVal = key:bareword "=" 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)!)
94 > (Chars:: alphanum++)
99 word = Chars:: bareword
101 blockquote = "adsfafewag"
102 //blockquote = Blockquote:: "\"\"" (block | text "\"\"")
104 Verbatim = "[verbatim]" ws! { (~[])++ }
106 styled = Underline:: "__" text "__"
107 | Footnote:: "((" text "))"
108 | TT:: "[[" text "]]"
109 | Citation:: "[" word "]"
110 | Strikethrough:: "!!" text "!!"
111 | Superscript:: "^^" (word|block)
112 | Subscript:: ",," (word|block)
113 | Smallcap:: "\\sc" block
114 | Bold:: "++" text "++"
115 | Keyword:: "!" (word|block)
116 | Italic:: "**" text "**"
120 link = text:({ text }|word) "->" href:(url|email)
122 structured = command & "\\" ([a-zA-Z0-9]++)! block?
135 command = "\\" [a-z]++
137 // URLs //////////////////////////////////////////////////////////////////////////////
139 // interesting opportunity to show off boolean grammars here: define other
140 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
141 // only gets parsed once
143 urlpath = urlchar* -> ~urlv // this ~urlv should be handled by url! bug!
144 username = [a-zA-Z0-9;/?:&=$\-_.+]++
145 password = [a-zA-Z0-9;/?:&=$\-_.+]++
146 urlc = [a-zA-Z0-9;/?:&=$\-_.+@]
149 | urlescape:: "%" [0-9] [0-9]
150 url = Mailto:: "mailto" ":" email -> ~urlv
159 url_login = Login:: username:username password:(":" password) "@"
160 method = [+\-.a-z0-9]+
161 domain = (part +/ ".") -> ~"."
162 part = [a-zA-Z0-9\-]++
163 // interesting use of boolean grammars
164 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
166 email = user:username "@" host:host -> ~[.]
168 host = IP:: nums "." nums "." nums "." nums
173 // Tokens ///////////////////////////////////////////////////////////////////
175 bareword = alphanum++
178 quoted = "\"" ((~[\"\\] | escaped)+) "\""
185 // Chars ///////////////////////////////////////////////////////////////
188 alphanum = [a-zA-Z0-9]
189 sym = ~[a-zA-Z0-9\ \r\n=\">]