@@ -63,7 +63,7 @@ readTextile state s = (readWith parseTextile) state (s ++ "\n\n")
6363
6464-- | Special chars border strings parsing
6565specialChars :: [Char]
66−specialChars = "\\[]*#_@~<>!?-+^&'\";:"
66+specialChars = "\\[]*#_@~<>!?-+^&'\";:|"
6767
6868-- | Generate a Pandoc ADT from a textile document
6969parseTextile :: GenParser Char ParserState Pandoc
@@ -82,6 +82,7 @@ blockParsers = [ codeBlock
8282 , header
8383 , blockQuote
8484 , anyList
85+ , table
8586 , para
8687 , nullBlock ]
8788
@@ -173,6 +174,68 @@ para = try $ do
173174 content <- manyTill inline blockBreak
174175 return $ Para $ normalizeSpaces content
175176
177+
178+-- Tables
179+
180+-- TODO : DOC and factorizing cellInlines
181+
182+tableCell :: GenParser Char ParserState TableCell
183+tableCell = many1 cellInline >>= return . (:[]) . Plain . normalizeSpaces
184+ where cellInline = choice [ str
185+ , whitespace
186+ , code
187+ , simpleInline (string "??") (Cite [])
188+ , simpleInline (char '*') Strong
189+ , simpleInline (char '_') Emph
190+ , simpleInline (string "**") Strong
191+ , simpleInline (string "__") Emph
192+ , simpleInline (char '-') Strikeout
193+ , simpleInline (char '+') Inserted
194+ , simpleInline (char '^') Superscript
195+ , simpleInline (char '~') Subscript
196+ -- , link
197+ -- , image
198+ -- , math
199+ -- , autoLink
200+ ]
201+
202+tableRow :: GenParser Char ParserState [TableCell]
203+tableRow = try $ do
204+ char '|'
205+ cells <- endBy1 tableCell (char '|')
206+ newline
207+ return cells
208+
209+tableRows :: GenParser Char ParserState [[TableCell]]
210+tableRows = many1 tableRow
211+
212+tableHeaders :: GenParser Char ParserState [TableCell]
213+tableHeaders = try $ do
214+ let separator = (try $ string "|_.")
215+ separator
216+ headers <- sepBy1 tableCell separator
217+ char '|'
218+ newline
219+ return headers
220+
221+table :: GenParser Char ParserState Block
222+table = try $ do
223+ headers <- option [] tableHeaders
224+ rows <- tableRows
225+ return $ Table []
226+ (replicate (length headers) AlignDefault)
227+ (replicate (length headers) 0.0)
228+ headers
229+ rows
230+
231+
232+----------
233+-- Inlines
234+----------
235+
236+
237+
238+
176239-- | Any inline element
177240inline :: GenParser Char ParserState Inline
178241inline = choice inlineParsers <?> "inline"