git.iko.soy/typeable/pandoc
on master help sign in
RST reader: fix handling of header in CSV tables.

The interpretation of this line is not affected by the delim option. Closes #7064.

commitd1875b69ec136c19d9b2336ff57e360ff7b7bef6 authorJohn MacFarlane <jgm@berkeley.edu> dateSun 31 Jan 2021, 12:05 (6 years ago) parent9c8ff53
2 files changed+37−4
src/Text/Pandoc/Readers/RST.hs+5−4 test/command/7064.md+32
src/Text/Pandoc/Readers/RST.hs+5−4
@@ -877,10 +877,11 @@ csvTableDirective top fields rawcsv = do
877877 (bs, _) <- fetchItem u
878878 return $ UTF8.toText bs
879879 Nothing -> return rawcsv
880− let res = parseCSV opts (case explicitHeader of
881− Just h -> h <> "\n" <> rawcsv'
882− Nothing -> rawcsv')
883− case res of
880+ let header' = case explicitHeader of
881+ Just h -> parseCSV defaultCSVOptions h
882+ Nothing -> Right []
883+ let res = parseCSV opts rawcsv'
884+ case (<>) <$> header' <*> res of
884885 Left e ->
885886 throwError $ PandocParsecError "csv table" e
886887 Right rawrows -> do
test/command/7064.mdnew file+32
@@ -0,0 +1,32 @@
1+```
2+% pandoc -f rst -t html
3+.. csv-table:: Changes
4+ :header: "Version", "Date", "Description"
5+ :widths: 15, 15, 70
6+ :delim: $
7+
8+ 0.1.0 $ 18/02/2013 $ Initial Release
9+^D
10+<table>
11+<caption>Changes</caption>
12+<colgroup>
13+<col style="width: 15%" />
14+<col style="width: 15%" />
15+<col style="width: 70%" />
16+</colgroup>
17+<thead>
18+<tr class="header">
19+<th>Version</th>
20+<th>Date</th>
21+<th>Description</th>
22+</tr>
23+</thead>
24+<tbody>
25+<tr class="odd">
26+<td>0.1.0</td>
27+<td>18/02/2013</td>
28+<td>Initial Release</td>
29+</tr>
30+</tbody>
31+</table>
32+```