From d1875b69ec136c19d9b2336ff57e360ff7b7bef6 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 31 Jan 2021 12:05:46 -0800 Subject: [PATCH] RST reader: fix handling of header in CSV tables. The interpretation of this line is not affected by the delim option. Closes #7064. --- src/Text/Pandoc/Readers/RST.hs | 9 +++++---- test/command/7064.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 test/command/7064.md diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 707af905f..0f32d993c 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -877,10 +877,11 @@ csvTableDirective top fields rawcsv = do (bs, _) <- fetchItem u return $ UTF8.toText bs Nothing -> return rawcsv - let res = parseCSV opts (case explicitHeader of - Just h -> h <> "\n" <> rawcsv' - Nothing -> rawcsv') - case res of + let header' = case explicitHeader of + Just h -> parseCSV defaultCSVOptions h + Nothing -> Right [] + let res = parseCSV opts rawcsv' + case (<>) <$> header' <*> res of Left e -> throwError $ PandocParsecError "csv table" e Right rawrows -> do diff --git a/test/command/7064.md b/test/command/7064.md new file mode 100644 index 000000000..58b72e363 --- /dev/null +++ b/test/command/7064.md @@ -0,0 +1,32 @@ +``` +% pandoc -f rst -t html +.. csv-table:: Changes + :header: "Version", "Date", "Description" + :widths: 15, 15, 70 + :delim: $ + + 0.1.0 $ 18/02/2013 $ Initial Release +^D + + +++++ + + + + + + + + + + + + + + +
Changes
VersionDateDescription
0.1.018/02/2013Initial Release
+```