diff options
Diffstat (limited to 'src/Text/Pandoc/Readers/CSV.hs')
-rw-r--r-- | src/Text/Pandoc/Readers/CSV.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/CSV.hs b/src/Text/Pandoc/Readers/CSV.hs index fa358424f..384687a6a 100644 --- a/src/Text/Pandoc/Readers/CSV.hs +++ b/src/Text/Pandoc/Readers/CSV.hs @@ -30,13 +30,19 @@ 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 0 + widths = replicate numcols ColWidthDefault Right [] -> return $ B.doc mempty Left e -> throwError $ PandocParsecError s e |