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...
53 // | "()":: w** "#" (~[\n])* "\n" ws
56 //////////////////////////////////////////////////////////////////////////////
60 Doc = head:Header ws! body:Body
61 Header = { "\\header" { KeyVal */ ws } /ws }
62 Body = { Section } */ws
63 Section = SectionHeader ws! Paragraph*
64 SectionHeader = "==" SectionHeaderBody "=="
65 SectionHeaderBody = "=" SectionHeaderBody "="
69 blank = sp! "\n" sp! "\n" ws!
71 KeyVal = key:bareword "=" val:text /ws
75 Paragraph = { Blockquote:: "\"\" " text }
79 onums = nums (". "|") ")!
82 uli = "* " (ws! text &~ any (oli|uli)!)
83 oli = onums! (ws! text &~ any (oli|uli)!)
89 // > ^"#" ws! { ~[]* }
97 > (Chars:: alphanum++)
102 word = Chars:: bareword
104 blockquote = "adsfafewag"
105 //blockquote = Blockquote:: "\"\"" (block | text "\"\"")
107 Verbatim = "[verbatim]" ws! { (~[])++ }
109 #import meta.g as meta
110 InlineGrammar = "\grammar" ws! { meta.Grammar }
112 styled = Underline:: "__" text "__"
113 | Footnote:: "((" text "))"
114 | TT:: "[[" text "]]"
115 | Citation:: "[" word "]"
116 | Strikethrough:: "!!" text "!!"
117 | Superscript:: "^^" (word|block)
118 | Subscript:: ",," (word|block)
119 | Smallcap:: "\\sc" block
120 | Bold:: "++" text "++"
121 | Keyword:: "!" (word|block)
122 | Italic:: "**" text "**"
126 link = text:({ text }|word) "->" href:(url|email)
128 structured = command & "\\" ([a-zA-Z0-9]++)! block?
141 command = "\\" [a-z]++
143 // URLs //////////////////////////////////////////////////////////////////////////////
145 // interesting opportunity to show off boolean grammars here: define other
146 // subtypes of url (ftp, etc) as conjunctions, but the "master pattern"
147 // only gets parsed once
149 urlpath = urlchar* -> ~urlv // this ~urlv should be handled by url! bug!
150 username = [a-zA-Z0-9;/?:&=$\-_.+]++
151 password = [a-zA-Z0-9;/?:&=$\-_.+]++
152 urlc = [a-zA-Z0-9;/?:&=$\-_.+@]
155 | urlescape:: "%" [0-9] [0-9]
156 url = Mailto:: "mailto" ":" email -> ~urlv
165 url_login = Login:: username:username password:(":" password) "@"
166 method = [+\-.a-z0-9]+
167 domain = (part +/ ".") -> ~"."
168 part = [a-zA-Z0-9\-]++
169 // interesting use of boolean grammars
170 // &~ ([\-0-9] ~[]* | ~[]* [\-0-9])
172 email = user:username "@" host:host -> ~[.]
174 host = IP:: nums "." nums "." nums "." nums
179 // Tokens ///////////////////////////////////////////////////////////////////
181 bareword = alphanum++
184 quoted = "\"" ((~[\"\\] | escaped)+) "\""
191 // Chars ///////////////////////////////////////////////////////////////
194 alphanum = [a-zA-Z0-9]
195 sym = ~[a-zA-Z0-9\ \r\n=\">]