CSV reader: turn line breaks into LineBreaks not SoftBreaks.

Closes #9797.
This commit is contained in:
John MacFarlane
2024-05-27 14:32:59 -07:00
parent ad68ff34ae
commit fa01764a0e
2 changed files with 42 additions and 1 deletions
+3 -1
View File
@@ -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
+39
View File
@@ -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 ( "" , [] , [] ) [])
]
```