pandoc-csv2table: Convert CSV to Pandoc Table Markdown

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

A Pandoc filter that replaces image inline or fenced code blocks with pandoc table markdown. CSV contents will be parsed by the pandoc markdown reader.


[Skip to ReadMe]

Properties

Versions1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.6
Change logCHANGELOG.md
Dependenciesbase (>=4.6 && <5), csv (>=0.1.2), pandoc (>=1.13.0.0), pandoc-csv2table, pandoc-types (>=1.12.0.0), text (>=0.11 && <1.3) [details]
LicenseMIT
Copyright(c) 2015 Wasif Hasan Baig
AuthorWasif Hasan Baig <pr.wasif@gmail.com>
MaintainerWasif Hasan Baig <pr.wasif@gmail.com>
CategoryText
Home pagehttps://github.com/baig/pandoc-csv2table-filter
Bug trackerhttps://github.com/baig/pandoc-csv2table-filter/issues
Source repositoryhead: git clone git://github.com/baig/pandoc-csv2table-filter.git
Executablespandoc-csv2table
UploadedThu Nov 29 16:39:03 UTC 2018 by vmandela

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for pandoc-csv2table-1.0.6

[back to package description]

Pandoc csv2table Filter

A Pandoc filter that replaces CSV content (either inside fenced code blocks or referenced CSV files) with Pandoc Table Markdown.

A CSV file rendered to Markdown and PDF

Installation

You can use this filter in two ways.

  1. Install using Cabal: After installing Haskell platform, run:

    cabal install pandoc-csv2table
    
  2. Use the single file filter: There is a gist hosting a single file version of this filter here. Clone it and make it an executable script by running:

    chmod +x pandoc-csv2table.hs
    

You can also use this filter in your Pandoc application by calling tablifyCsvlinks.

Usage

Referencing or including CSV

There are three ways to include CSV in your markdown.

  1. Referencing CSV file in Image Links:

    ![This text will become the table caption](table.csv)
    
  2. Referencing CSV file in Fenced Code Blocks:

    ```{.table caption="This is the **caption**" source="table.csv"}  
    ```
    

    Only code blocks having .table class will be processed.

  3. Including CSV content inside Fenced Code Blocks:

    ```{.table aligns="LCR" caption="This is the **caption**" header="yes"}  
    Fruit, Quantity, Price  
    apples, 15, 3.24  
    oranges, 12, 2.22  
    ```
    

    Only code blocks having .table class will be processed.

CSV file or content can contain pandoc markdown. It will be parsed by the Pandoc Markdown Reader before being inserted as a table into the document.

Running the filter

Given the filename test.md, run the filter using command

pandoc --filter pandoc-csv2table -o test.html test.md

or

pandoc -t json test.md | pandoc-csv2table | pandoc -f json -o test.html

Examples

See example.md and the rendered pdf version in the Examples folder for more details on usage.

Options

You can specify a configuration string for image links and attributes for fenced code blocks. There are valid options for specifying

Configuration String

It is included right before the closing square bracket without any space in between, as shown in the example below.

![Another table. mylrcd](table.csv)

mylrcd is the configuration string. This will be rendered as a multiline table with a header with first column left-aligned, second right-aligned, third center-aligned, and the fourth one having default alignment. The config string will be removed from the caption after being processed.

The config string can contain following letters:

You can specify l r c d for each column in a series. The extra letters will be ignored if they exceed the number of columns in the CSV file.

Attributes

You can specify header attributes in fecnced code blocks like this:

```{.table type="pipe" aligns="LCR" caption="A **caption**" header="yes"}  
Fruit, Quantity, Price  
apples, 15, 3.24  
oranges, 12, 2.22  
```

Note: .table must be included if the fenced code block is intended to be processed by this filter.

Valid attributes that you can specify in code blocks include:

License

Copyright © 2015-2018 Wasif Hasan Baig

Source code is released under the Terms and Conditions of MIT License.

Please refer to the License file in the project's root directory.