diff --git a/src/Text/Pandoc/Readers/CSV.hs b/src/Text/Pandoc/Readers/CSV.hs index 3d2de11a5..294e20add 100644 --- a/src/Text/Pandoc/Readers/CSV.hs +++ b/src/Text/Pandoc/Readers/CSV.hs @@ -25,6 +25,7 @@ import Text.Pandoc.Sources (ToSources(..), sourcesToText) import Text.Pandoc.Options (ReaderOptions) import Control.Monad.Except (throwError) import Data.Text (Text) +import Data.List (intersperse) import Text.Pandoc.Parsing (fromParsecError) readCSV :: (PandocMonad m, ToSources a) @@ -60,7 +61,8 @@ readCSVWith csvopts txt = do (TableFoot nullAttr []) where capt = B.emptyCaption numcols = length r - toplain = B.simpleCell . B.plain . B.text . T.strip + toplain = B.simpleCell . B.plain . mconcat . + intersperse B.linebreak . map B.text . T.lines toRow = Row nullAttr . map toplain toHeaderRow l = [toRow l | not (null l)] hdrs = toHeaderRow r diff --git a/test/command/9797.md b/test/command/9797.md new file mode 100644 index 000000000..b3c562232 --- /dev/null +++ b/test/command/9797.md @@ -0,0 +1,39 @@ +``` +% pandoc -t native -f csv +"one_line_break: +four_line_breaks: + + + +last_line" +^D +[ Table + ( "" , [] , [] ) + (Caption Nothing []) + [ ( AlignDefault , ColWidthDefault ) ] + (TableHead + ( "" , [] , [] ) + [ Row + ( "" , [] , [] ) + [ Cell + ( "" , [] , [] ) + AlignDefault + (RowSpan 1) + (ColSpan 1) + [ Plain + [ Str "one_line_break:" + , LineBreak + , Str "four_line_breaks:" + , LineBreak + , LineBreak + , LineBreak + , LineBreak + , Str "last_line" + ] + ] + ] + ]) + [ TableBody ( "" , [] , [] ) (RowHeadColumns 0) [] [] ] + (TableFoot ( "" , [] , [] ) []) +] +```