From 942e3ee1f9ce3593b3ce3cc32c7ed7039aee205a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 21 Jul 2020 10:20:15 -0700 Subject: [PATCH] RST reader: fix csv tables with multiline cells. Closes #6549. --- pandoc.cabal | 1 + src/Text/Pandoc/Readers/RST.hs | 7 ++++++- test/command/01.csv | 4 ++++ test/command/6549.md | 26 ++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/command/01.csv create mode 100644 test/command/6549.md diff --git a/pandoc.cabal b/pandoc.cabal index 25ce935a4..9b0ee6fb2 100644 --- a/pandoc.cabal +++ b/pandoc.cabal @@ -205,6 +205,7 @@ extra-source-files: test/command/B.txt test/command/C.txt test/command/D.txt + test/command/01.csv test/command/defaults1.yaml test/command/defaults2.yaml test/command/3533-rst-csv-tables.csv diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 7c25be486..25682a500 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -879,7 +879,12 @@ csvTableDirective top fields rawcsv = do Left e -> throwError $ PandocParsecError "csv table" e Right rawrows -> do - let parseCell = parseFromString' (plain <|> return mempty) + let singleParaToPlain bs = + case B.toList bs of + [Para ils] -> B.fromList [Plain ils] + _ -> bs + let parseCell t = singleParaToPlain + <$> parseFromString' parseBlocks (t <> "\n\n") let parseRow = mapM parseCell rows <- mapM parseRow rawrows let (headerRow,bodyRows,numOfCols) = diff --git a/test/command/01.csv b/test/command/01.csv new file mode 100644 index 000000000..76a84398d --- /dev/null +++ b/test/command/01.csv @@ -0,0 +1,4 @@ +"Column1";"Column2" +"Data1";"- data1 + +- data2" diff --git a/test/command/6549.md b/test/command/6549.md new file mode 100644 index 000000000..e41f4b76a --- /dev/null +++ b/test/command/6549.md @@ -0,0 +1,26 @@ +``` +% pandoc -f rst +.. csv-table:: Test table + :file: command/01.csv + :delim: ; + :header-rows: 1 +^D + + + + + + + + + + + + + + +
Test table
Column1Column2
Data1
    +
  • data1
  • +
  • data2
  • +
+```