summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Textile.hs
diff options
context:
space:
mode:
authorpaul.rivier <paul.r.ml@gmail.com>2010-09-17 18:49:56 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2010-12-03 23:10:51 -0800
commitcfc70863a3a87083749e29df26f696b17033e448 (patch)
treead3dad824cc94609c6fe5ba83d6c8293dde0da9e /src/Text/Pandoc/Readers/Textile.hs
parentd917db5e42353c2878e429fd29bf7ef6d576ad62 (diff)
simpler table cell handling
Diffstat (limited to 'src/Text/Pandoc/Readers/Textile.hs')
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index 0bdb915b3..3d759a944 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -177,28 +177,14 @@ para = try $ do
-- Tables
--- TODO : DOC and factorizing cellInlines
-
+-- | A table cell spans until a pipe |
tableCell :: GenParser Char ParserState TableCell
-tableCell = many1 cellInline >>= return . (:[]) . Plain . normalizeSpaces
- where cellInline = choice [ str
- , whitespace
- , code
- , simpleInline (string "??") (Cite [])
- , simpleInline (char '*') Strong
- , simpleInline (char '_') Emph
- , simpleInline (string "**") Strong
- , simpleInline (string "__") Emph
- , simpleInline (char '-') Strikeout
- , simpleInline (char '+') Inserted
- , simpleInline (char '^') Superscript
- , simpleInline (char '~') Subscript
- -- , link
- -- , image
- -- , math
- -- , autoLink
- ]
+tableCell = do
+ c <- many1 (noneOf "|\n")
+ content <- parseFromString (many1 inline) c
+ return $ [ Plain $ normalizeSpaces content ]
+-- | A table row is made of many table cells
tableRow :: GenParser Char ParserState [TableCell]
tableRow = try $ do
char '|'
@@ -206,9 +192,11 @@ tableRow = try $ do
newline
return cells
+-- | Many table rows
tableRows :: GenParser Char ParserState [[TableCell]]
tableRows = many1 tableRow
+-- | Table headers are made of cells separated by a tag "|_."
tableHeaders :: GenParser Char ParserState [TableCell]
tableHeaders = try $ do
let separator = (try $ string "|_.")
@@ -218,6 +206,7 @@ tableHeaders = try $ do
newline
return headers
+-- | A table with an optional header
table :: GenParser Char ParserState Block
table = try $ do
headers <- option [] tableHeaders
@@ -251,10 +240,10 @@ inlineParsers = [ str
, endline
, code
, simpleInline (string "??") (Cite [])
- , simpleInline (char '*') Strong
- , simpleInline (char '_') Emph
, simpleInline (string "**") Strong
, simpleInline (string "__") Emph
+ , simpleInline (char '*') Strong
+ , simpleInline (char '_') Emph
, simpleInline (char '-') Strikeout
, simpleInline (char '+') Inserted
, simpleInline (char '^') Superscript
@@ -311,7 +300,6 @@ simpleInline border construct = surrounded border inline >>=
-- - Pandoc Meta Information
-- - footnotes
-- - hyperlink "label":target
--- - tables
--- - doc
+-- - tables alignments
-- - tests
-- - Inserted inline handling in writers \ No newline at end of file