mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 11:16:33 +00:00
CSV reader: turn line breaks into LineBreaks not SoftBreaks.
Closes #9797.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ( "" , [] , [] ) [])
|
||||
]
|
||||
```
|
||||
Reference in New Issue
Block a user