Pandoc filter for creating tables with CSV. Format must conform to RFC 4180. Requires Pandoc 3.2 or later.
pandoc input.md --lua-filter csv-table.lua -o output.html
Write CSV in a fenced code block:
```csv
Name , Age , City
Alice , 30 , __NYC__
Bob , 25 , *LA*
```Or include data from a file:
```{.csv file=data.csv}
```Specify options as code fence attributes:
```{.csv caption="**My Table**" header=false align=lcr widths=3,1,2 tablewidth=80% markdown=false}
Casa , 9 , Seattle
Kira , 7 , Hawaii
```| Option | Description | Example |
|---|---|---|
file/f |
Load CSV from a file | data.csv |
caption/cap |
Table caption (supports markdown) | *Experiment* |
header/h |
Treat first row as header? | true (default) |
align/a |
Column alignments, d for default |
lcrd |
widths/w |
Relative column widths | 4,4,2 |
tablewidth/tw |
Overall table width | 80%, 500px |
markdown/md |
Parse table cells as markdown? | true (default) |
CSV content follows RFC 4180:
- Delimiter must be
, - Fields containing
,,", or\nmust be wrapped in double quotes" - Double quotes inside a quoted field are escaped by doubling:
"say ""hello""" - No trailing spaces after a quoted field
- Every row must have the same number of fields