Skip to main content

Python-Markdown extension for MultiMarkdown 6 table syntax

Project description

pymdown-multimd-table

A Python-Markdown extension implementing MultiMarkdown 6 extended table syntax, mirroring the feature set of the markdown-it-multimd-table JavaScript plugin.

Features

Standard (always enabled)

Feature Syntax
Column spanning (colspan) Empty cells || extend the previous cell
Text alignment :---, :---:, ---: in the separator
Wrappable columns ---+ in the separator adds class="extend"
Multiple header rows Multiple rows before the separator
Table captions [caption text] or [caption text][label]
Multiple tbody sections Blank line between data rows (see multibody)
Inline Markdown Bold, italic, code, etc. inside cells

Optional (controlled by config)

Option Default Description
rowspan False ^^ in a cell merges it with the cell above
multiline False Backslash \ at end of row continues cell content on the next row
headerless False Tables without a header/separator row
multibody True Blank lines between data rows create separate <tbody> elements
autolabel True Auto-generate id from caption text
attr_list False Parse {.class #id key=val} attribute blocks on cells and rows

Installation

pip install pymdown-multimd-table

Usage

import markdown

md = markdown.Markdown(extensions=["pymdown_multimd_table"])
html = md.convert(source)

With options:

md = markdown.Markdown(
    extensions=["pymdown_multimd_table"],
    extension_configs={
        "pymdown_multimd_table": {
            "rowspan": True,
            "multiline": True,
            "headerless": True,
            "multibody": True,   # default
            "autolabel": True,   # default
        }
    },
)

In MkDocs (mkdocs.yml):

markdown_extensions:
  - pymdown_multimd_table:
      rowspan: true
      multiline: true

Syntax Examples

Basic table

First Header  | Second Header
------------- | -------------
Content Cell  | Content Cell
First Header Second Header
Content Cell Content Cell

Alignment

| Item      | Value  |
| :-------: | -----: |
| Centered  | Right  |
Item Value
Centered Right

Column spanning

|            | Grouping ||
| Header     | A        | B        |
| ---------- | :------: | -------: |
| Data       | spans    ||
Grouping
Header A B
Data spans

Caption with label

[Sales Data][sales]
| Q1   | Q2   |
| ---- | ---- |
| 100  | 120  |
Sales Data
Q1 Q2
100 120

Row spanning (rowspan: true)

| A      | B  | C  |
| ------ | -- | -- |
| tall   | 1  | x  |
| ^^     | 2  | y  |
A B C
tall 1 x
2 y

Multiline cells (multiline: true)

| Code            | Output  |
| --------------- | ------- |
| ```python      |         |\
| print("hello") | hello   |\
| ```            |         |
Code Output
```python
print("hello")
```
hello

Headerless table (headerless: true)

| -------- | ----- |
| No header| here  |
No header here

Attribute lists on cells and rows (attr_list: true)

Place a {…} block at the end of a cell to add HTML attributes to that cell. The block supports .class, #id, and key="value" tokens — the same syntax as the standard attr_list Markdown extension.

Cell attributes — append {…} inside the cell, before the closing |:

| Header                        |
| ----------------------------- |
| plain cell                    |
| styled cell {.highlight}      |
| id cell {#cell-1}             |
| full {#c2 .bold data-x="1"}   |
<table>
  <thead>
    <tr><th>Header</th></tr>
  </thead>
  <tbody>
    <tr><td>plain cell</td></tr>
    <tr><td class="highlight">styled cell</td></tr>
    <tr><td id="cell-1">id cell</td></tr>
    <tr><td id="c2" class="bold" data-x="1">full</td></tr>
  </tbody>
</table>

Row attributes — append {…} after the last | of a row:

| A | B |
| - | - |
| x | y |{.even}
| p | q |{.odd #row-2}
<table>
  <thead>
    <tr><th>A</th><th>B</th></tr>
  </thead>
  <tbody>
    <tr class="even"><td>x</td><td>y</td></tr>
    <tr class="odd" id="row-2"><td>p</td><td>q</td></tr>
  </tbody>
</table>

Combined — cell and row attributes can be used together:

| H                  |
| ------------------ |
| cell {.myclass} |{.myrow}
<table>
  <thead>
    <tr><th>H</th></tr>
  </thead>
  <tbody>
    <tr class="myrow"><td class="myclass">cell</td></tr>
  </tbody>
</table>

Development

pip install -e ".[dev]"
pytest tests/

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

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

Source Distribution

pymdown_multimd_table-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

pymdown_multimd_table-0.1.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file pymdown_multimd_table-0.1.0.tar.gz.

File metadata

  • Download URL: pymdown_multimd_table-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pymdown_multimd_table-0.1.0.tar.gz
Algorithm Hash digest
SHA256 df88eef12670cdffe69751a7834e7e65d18b00736f3d3cfef9a07f60301a709a
MD5 8d93c6125d5a024a7e7be9a78b069cdc
BLAKE2b-256 9701d6594c35c047cf973ef6adb60cc8c4ab4a3be1a1db1b69fd39e25feac56e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymdown_multimd_table-0.1.0.tar.gz:

Publisher: publish-to-pypi.yml on joapuiib/pymdown-multimd-table

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

File details

Details for the file pymdown_multimd_table-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pymdown_multimd_table-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74056e165f737f293681d913359753e7823a1d49ea24ad29cff483b505367f30
MD5 1ec359394bbc3098531b2cdebe21c736
BLAKE2b-256 97922f0ca3e9c168b9ceac9e05179176d55f70c3f7fc4a00636f1800bb10ca15

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymdown_multimd_table-0.1.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on joapuiib/pymdown-multimd-table

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

Supported by

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