aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/CSV.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers/CSV.hs')
-rw-r--r--src/Text/Pandoc/Readers/CSV.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/CSV.hs b/src/Text/Pandoc/Readers/CSV.hs
index a1272d47f..384687a6a 100644
--- a/src/Text/Pandoc/Readers/CSV.hs
+++ b/src/Text/Pandoc/Readers/CSV.hs
@@ -30,12 +30,18 @@ readCSV :: PandocMonad m
-> m Pandoc
readCSV _opts s =
case parseCSV defaultCSVOptions (crFilter s) of
- Right (r:rs) -> return $ B.doc $ B.table capt (zip aligns widths) hdrs rows
- where capt = mempty
+ Right (r:rs) -> return $ B.doc $ B.table capt
+ (zip aligns widths)
+ (TableHead nullAttr hdrs)
+ [TableBody nullAttr 0 [] rows]
+ (TableFoot nullAttr [])
+ where capt = B.emptyCaption
numcols = length r
- toplain = B.plain . B.text . T.strip
- hdrs = map toplain r
- rows = map (map toplain) rs
+ toplain = B.simpleCell . B.plain . B.text . T.strip
+ toRow = Row nullAttr . map toplain
+ toHeaderRow l = if null l then [] else [toRow l]
+ hdrs = toHeaderRow r
+ rows = map toRow rs
aligns = replicate numcols AlignDefault
widths = replicate numcols ColWidthDefault
Right [] -> return $ B.doc mempty