Skip to main content
Date:
December 4, 2016

Build Status GitHub Releases PyPI version Development Status Python version License Coveralls

The pantable package comes with 2 pandoc filters, pantable.py and pantable2csv.py. pantable is the main filter, introducing a syntax to include CSV table in markdown source. pantable2csv complements pantable, is the inverse of pantable, which convert native pandoc tables into the CSV table format defined by pantable.

Some example uses are:

  1. You already have tables in CSV format.

  2. You feel that directly editing markdown table is troublesome. You want a spreadsheet interface to edit, but want to convert it to native pandoc table for higher readability. And this process might go back and forth.

  3. You want lower-level control on the table and column widths.

  4. You want to use all table features supported by the pandoc’s internal AST table format, which is not possible in markdown for pandoc <= 1.18. [1]

pantable

This allows CSV tables, optionally containing markdown syntax (disabled by default), to be put in markdown as a fenced code blocks.

Example

Also see the README in GitHub Pages. There’s a LaTeX output too.

```table
---
caption: '*Awesome* **Markdown** Table'
alignment: RC
table-width: 2/3
markdown: True
---
First row,defaulted to be header row,can be disabled
1,cell can contain **markdown**,"It can be aribrary block element:

- following standard markdown syntax
- like this"
2,"Any markdown syntax, e.g.",$$E = mc^2$$
```

becomes

First row

defaulted to be header row

can be disabled

1

cell can contain markdown

It can be aribrary block element:

  • following standard markdown syntax

  • like this

2

Any markdown syntax, e.g.

\begin{equation*} E = mc^2 \end{equation*}

Table: Awesome Markdown Table

(The equation might not work if you view this on PyPI.)

Install and Use

Install:

pip install -U pantable

Use:

pandoc -F pantable -o README.html README.md

Syntax

Fenced code blocks is used, with a class table. See [Example].

Optionally, YAML metadata block can be used within the fenced code block, following standard pandoc YAML metadata block syntax. 7 metadata keys are recognized:

  • caption: the caption of the table. If omitted, no caption will be inserted. Default: disabled.

  • alignment: a string of characters among L,R,C,D, case-insensitive, corresponds to Left-aligned, Right-aligned, Center-aligned, Default-aligned respectively. e.g. LCRD for a table with 4 columns. Default: DDD...

  • width: a list of relative width corresponding to the width of each columns. e.g.

    - width
        - 0.1
        - 0.2
        - 0.3
        - 0.4

    Default: auto calculated from the length of each line in table cells.

  • table-width: the relative width of the table (e.g. relative to \linewidth). default: 1.0

  • header: If it has a header row or not. True/False/yes/NO are accepted, case-insensitive. default: True

  • markdown: If CSV table cell contains markdown syntax or not. Same as above. Default: False

  • include: the path to an CSV file, can be relative/absolute. If non-empty, override the CSV in the CodeBlock. default: None

When the metadata keys is invalid, the default will be used instead. Note that width and table-width accept fractions as well.

pantable2csv

This one is the inverse of pantable, a panflute filter to convert any native pandoc tables into the CSV table format used by pantable.

Effectively, pantable forms a “CSV Reader”, and pantable2csv forms a “CSV Writer”. It allows you to convert back and forth between these 2 formats.

For example, in the markdown source:

+--------+---------------------+--------------------------+
| First  | defaulted to be     | can be disabled          |
| row    | header row          |                          |
+========+=====================+==========================+
| 1      | cell can contain    | It can be aribrary block |
|        | **markdown**        | element:                 |
|        |                     |                          |
|        |                     | -   following standard   |
|        |                     |     markdown syntax      |
|        |                     | -   like this            |
+--------+---------------------+--------------------------+
| 2      | Any markdown        | $$E = mc^2$$             |
|        | syntax, e.g.        |                          |
+--------+---------------------+--------------------------+

: *Awesome* **Markdown** Table

running pandoc -F pantable2csv -o output.md input.md, it becomes

``` {.table}
---
alignment: DDD
caption: '*Awesome* **Markdown** Table'
header: true
markdown: true
table-width: 0.8055555555555556
width: [0.125, 0.3055555555555556, 0.375]
---
First row,defaulted to be header row,can be disabled
1,cell can contain **markdown**,"It can be aribrary block element:

-   following standard markdown syntax
-   like this
"
2,"Any markdown syntax, e.g.",$$E = mc^2$$
```

Release files for pantable 0.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pantable 0.9.3
File Size Uploaded
pantable-0.9.3.tar.gz 17.2 kB Details

Release files / pantable-0.9.3.tar.gz

Download URL pantable-0.9.3.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cc7111f795116ea878ccaef1243f6f7c15cfb335da802014c31ac717d74e3881
BLAKE2b-256 checksum
How to use checksums
19af5851392613c1d4546755a06666b503276f00dd8d4800ebf89e9e6dd5c565
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.14.2

2 release files

0.14.1

2 release files

0.13.6

2 release files

0.13.5

2 release files

0.13.4

2 release files

0.13.3

2 release files

0.13.2

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.12.4

2 release files

0.12.3

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12

2 release files

0.11.1

3 release files

0.11

3 release files

0.10.4

3 release files

0.10.3

0.10.2

3 release files

0.10.1

3 release files

0.10

2 release files

This release

0.9.3 This release

1 release file

0.9.2

1 release file

0.9.1

1 release file

0.9

1 release file

0.8.1

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3.1

1 release file

0.3

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

0.0.12

1 release file

0.0.11

1 release file

0.0.10

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page