Skip to main content

pelican-tabular

Pelican plugin to embed data tables in Markdown articles via a {% table %} shortcode.

Installation

uv add pelican-tabular

Add to pelicanconf.py:

PLUGINS = ["pelican.plugins.tabular"]

Usage

{% table data/books.yaml %}
{% table data/books.yaml fields="title,rating,year" %}
{% table data/books.yaml sort_by="rating" sort_order="desc" %}
{% table data/books.yaml hidden="internal_id" %}
{% table data/books.yaml group_by="genre" group_summary_at="genre" %}
{% table data/books.yaml group_by="author,year" aggregate="year:year" field_labels="year:Publication Year" %}
{% table data/books.yaml sort_by="date" date_format="%b %Y" %}
{% table data/books.yaml group_by="date:year" group_summary_at="date:year" %}
{% table data/books.yaml aria_columns="slide,recording" %}

Shortcode parameters

Parameter Description
(first positional) Path to data file, relative to TABULAR_DATA_ROOT
fields Comma-separated list of fields to display (overrides TABULAR_FIELDS)
hidden Comma-separated list of fields to exclude from output
sort_by Field key to sort rows by
sort_order asc (default) or desc
group_by Comma-separated fields to group rows by. A field may use a field:transform form to group by a derived value (currently supports year, e.g. date:year)
group_summary_at Fields at which to render a collapsible group-header row with row count; must be a prefix of group_by (transforms allowed, e.g. date:year)
aggregate Comma-separated field:op pairs for collapsed groups (currently supports year)
field_labels Per-shortcode label overrides, formatted as field:Label,field2:Label 2
date_format strftime pattern applied to date/datetime cells, e.g. %b %YJun 2026 (overrides TABULAR_DATE_FORMAT). Sorting still uses the underlying date
aria_columns Comma-separated columns whose links should get an aria-label taken from the column header, giving icon-only link text (e.g. an emoji) an accessible name

Data formats

Supports YAML (list of dicts), JSON arrays, and CSV.

# data/books.yaml
- title: The Left Hand of Darkness
  author: Ursula K. Le Guin
  year: 1969
  rating: 5
- title: Piranesi
  author: Susanna Clarke
  year: 2020
  rating: 5

Cell value types

Type Example Rendered as
Scalar "Ursula K. Le Guin" Plain text
Date 2020-01-15 ISO string
Link dict {href: "https://…", text: "Homepage"} <a href="…">Homepage</a>
List ["tag1", "tag2"] Unordered list

Link dicts also accept url as an alias for href, and label as an alias for text.

{filename} links

Link href values support Pelican's {filename} syntax to cross-reference other articles:

- title: My Post
  link: {href: "{filename}posts/my-post.md", text: "Read more"}

Settings

Setting Default Description
TABULAR_SHORTCODE "table" Shortcode name
TABULAR_DATA_ROOT (Pelican PATH) Root directory for data files; absolute or relative to pelicanconf.py
TABULAR_FIELDS [] Default field list (empty = auto-detect from data)
TABULAR_FIELD_LABELS {} Global map of field key → display label
TABULAR_COUNT_TEMPLATE "{n} rows" Row-count string below the table; {n} is replaced with the count
TABULAR_GROUP_COUNT_TEMPLATE "{n} rows" Count string inside group-header rows
TABULAR_DATE_FORMAT "" Global strftime pattern for date/datetime cells (empty = ISO format). Per-shortcode date_format overrides it

TABULAR_COUNT_TEMPLATE and TABULAR_GROUP_COUNT_TEMPLATE have built-in defaults for zh ({n} 筆資料 / {n} 筆) and ja ({n} 件), derived from Pelican's DEFAULT_LANG setting.

Grouping

group_by reorders rows so that rows sharing the same key values are contiguous. group_summary_at adds a collapsible header row above each group that shows the group value and a row count.

{% table data/books.yaml group_by="genre,author" group_summary_at="genre" %}

This renders a genre-level header row for each genre, with all books listed beneath it. The header is collapsible via pelican-osm's osm-map.js — see CSS / JS below.

Derived group keys

A group_by (and group_summary_at) field may use a field:transform form to group by a value derived from the field rather than its raw value. The only transform currently supported is year, which extracts the year from a date/datetime:

{% table data/talks.yaml sort_by="date" sort_order="desc" group_by="date:year" group_summary_at="date:year" %}

This groups rows under a collapsible header per year while keeping the original date column intact. Sorting still operates on the underlying date.

Aggregation

When aggregate is set, rows sharing a group_by key are collapsed into a single row. Currently supported operations:

Op Description
year Collect all unique years from the field across grouped rows, sorted ascending, joined with ,
count Number of grouped rows with a non-empty value for the field
sum Sum of the field's numeric values (non-numeric/missing values are skipped)
avg Mean of the field's numeric values, rounded to 2 decimal places
min / max Smallest / largest of the field's numeric values

sum/avg/min/max coerce numeric-looking strings (e.g. "8.5") but skip anything that can't be parsed as a number; if no value in the group is numeric, the aggregated cell is empty.

{% table data/books.yaml group_by="author" aggregate="year:year" %}
{% table data/books.yaml group_by="genre" aggregate="rating:avg,pages:sum" %}

Column anchors

Every <th> element has an id attribute derived from the column label (e.g., id="osm-col--title"). These can be used as fragment links within the page. IDs are unique within a table; duplicate slugs get a numeric suffix (-2, -3, …).

CSS / JS

The generated HTML uses the same class names as pelican-osm (osm-place-list, osm-group-*) so the two plugins share CSS and the osm-map.js interactive sorting and group-toggle behaviour.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pelican_tabular-0.5.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pelican_tabular-0.5.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file pelican_tabular-0.5.0.tar.gz.

File metadata

  • Download URL: pelican_tabular-0.5.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pelican_tabular-0.5.0.tar.gz
Algorithm Hash digest
SHA256 3536de8f480951f7c81d059da6de7feabf0eabd552ea3f5c86d88dc018315dc9
MD5 68dd18c6bbcde66d7ca9688140f823a1
BLAKE2b-256 90e4153a06de17e0b44d0320d37acc3bdeea13a06ca37c25de1c522f4b82dfe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pelican_tabular-0.5.0.tar.gz:

Publisher: publish-to-pypi.yaml on Lee-W/pelican-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pelican_tabular-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pelican_tabular-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pelican_tabular-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 334eb1235d01dd9e5670d800e22bfcfbdc2d445e1a23ac2cae68890b7b9cc3a5
MD5 4489d730932dcfbe5f6987873ca873f1
BLAKE2b-256 405d74fdb3cfb518d8db51300e0dfd7050f98ca006d8c469e4b2a148d1b78c70

See more details on using hashes here.

Provenance

The following attestation bundles were made for pelican_tabular-0.5.0-py3-none-any.whl:

Publisher: publish-to-pypi.yaml on Lee-W/pelican-tabular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

0.4.0

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page