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.1.tar.gz (21.6 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.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymdown_multimd_table-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fae94a844d19f5da4dec6294b52de34c5d539a14619799bcc206e2ddfcf924e2
MD5 eaa8d644f9874ad8a6fe9ac73e1d94b2
BLAKE2b-256 2a437bdbf61093ec2018456837b4cd9c39bc381ac79d0f3a264b07e220213d74

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymdown_multimd_table-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pymdown_multimd_table-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eefc9074a46adefe8529d52a7994f546e225bbda37b3071dce8e0dd97b351605
MD5 bbd78ba7b6a3737b93a5908d8756338e
BLAKE2b-256 0237101af3a28ada0f1617e7f4bfbc31ac3608be23a80ff62cbf48155f50ca2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymdown_multimd_table-0.1.1-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