pandoc-placetable: Pandoc filter to include CSV files

[ program, text ] [ Propose Tags ]

A Pandoc filter that replaces code blocks (that have the class table) with tables generated from CSV. The CSV is read from the code block and from an optional external CSV file and concatenated. There's a flag to enable parsing of inline markdown.

[Skip to Readme]


Manual Flags


Require entire Pandoc as a dependency so it can be used to compile inline markdown in the CSV and caption if desired.


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.2, 0.3, 0.4, 0.4.1, 0.4.2, 0.5, 0.5.1, 0.6
Dependencies aeson (>=0.7), base (>=4.7 && <5), bytestring (>=0.10), explicit-exception (>=0.1.0), http-conduit (>=2.1.11), pandoc-types (>=1.20), spreadsheet (>=0.1.3), text (>=1.2), utf8-string (>=1.0) [details]
License LicenseRef-GPL
Copyright (c) 2015 Mauro Bieg
Author Mauro Bieg
Maintainer Mauro Bieg
Category Text
Home page
Bug tracker
Source repo head: git clone git://
Uploaded by mb21 at 2020-03-29T15:00:09Z
Reverse Dependencies 1 direct, 0 indirect [details]
Executables pandoc-placetable
Downloads 6803 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2020-03-29 [all 2 reports]

Readme for pandoc-placetable-0.6

[back to package description]

pandoc-placetable filter

A Pandoc filter that replaces fenced code blocks (that have the class table) with tables generated from CSV. The CSV is read from the code block and from an optional external CSV file (or URL) and concatenated. There's an option to enable parsing of inline markdown.

Some usage examples:

```{.table file="foo.csv"}

even,"with spaces"

```{.table file=""}

```{.table inlinemarkdown=yes}
"when compiled with the inlineMarkdown flag","we _can_ write **Markdown** here"

```{.table file="foo.csv" header=yes}

```{.table file="foo.csv" header=yes aligns=LRCRR inlinemarkdown=yes
     caption="my **caption**" delimiter="," quotechar="\"" }


Prepare a markdown file containing a fenced code block like the ones above, then:

pandoc --filter pandoc-placetable

Alternatively, the program can be used as an ad-hoc csv-reader and run without a markdown file. Then the options can be provided as command-line arguments. For example:

$ pandoc-placetable --file=foo.csv --widths="0.2 0.8" | pandoc -f json -o output.html

Or also:

$ cat foo.csv | pandoc-placetable --widths="0.2 0.8" | pandoc -f json -o output.html

(For this use-case, you might not even need pandoc-placetable; pandoc 2.9.2 and later ships with a simple built-in csv-reader: pandoc foo.csv -o output.html)

All options are optional and are specified as follows (cf. pandoc-placetable -h):

  • csv: The path or URL to the CSV file that is appended to the code block's content
  • file: synonym for csv
  • header: If set to yes, then the first row of data is interpreted as the table headers.
  • aligns: For each column, one letter (L, R or C) that specifies the column's alignment.
  • widths: For each column, a number specifying its width as a fraction of the page width, e.g. widths="0.5 0.2 0.3".
  • inlinemarkdown: If set to yes, interprets the caption and CSV fields as markdown. This requires pandoc-placetable to be compiled with the inlineMarkdown flag (see below).
  • caption: The table caption.
  • delimiter: A one-character string used in the CSV to separate fields, defaults to ,. For characters not allowed standing alone in Pandoc markdown attributes, use \t for a tab and \s for a space.
  • quotechar: A one-character string that may be used in the CSV to quote fields containing special characters, defaults to ".

If there is an id set (e.g. {.table #my-id}), the table will be wrapped in a div with that id so it can be referenced.


Using cabal and Hackage

cabal update
cabal install pandoc-placetable

Using stack

git clone
cd pandoc-placetable
stack install pandoc-placetable

The inlineMarkdown flag

When compiled with the inlineMarkdown flag, the inlinemarkdown=yesoption is available to have CSV and the caption be interpreted as markdown. Note that the flag causes Pandoc to be required as a dependency so it will take a while to build.

cabal install -f inlineMarkdown pandoc-placetable


cd pandoc-placetable
stack install --flag pandoc-placetable:inlineMarkdown pandoc-placetable


The idea and syntax for this filter was proposed by @jgm on pandoc-discuss and first implemented by @baig's pandoc-csv2table, over which I consider this filter an improvement.