Skip to main content

Span table cols and rows in MkDocs

Project description

mdx_spanner

This package enables rowspan and colspan in markdown tables when using MkDocs.

Syntax

Basics (spanning indicators)

You can activate colspan by putting only ~~ in a cell. This will merge the cell with the cell in the previous column.

You can activate rowspan by putting __ in a cell. This will merge the cell with the cell in the previous row. If the cell in previous row is empty it will continue to merge until it finds a non-empty cell.

Sample:

| Header 1 | Header 2 | Header 3 |
| ---------| -------- | -------- |
| Value 1  |    ~~    | Value 2  |
|          |    ~~    | Value 3  |
|_        _|    ~~    | Value 5  |
| Value 6  | Value 7  | Value 8  |

This should result in the following table:

+----------+----------+----------+
| Header 1 | Header 2 | Header 3 |
+----------+----------+----------+
| Value 1             | Value 2  |
|                     +----------+
|                     | Value 3  |
|                     +----------+
|                     | Value 5  |
+----------+----------+----------+
| Value 6  | Value 7  | Value 8  |
+----------+----------+----------+

Advanced (alignment markers)

You can change the alignment of a single spanned cell by adding markers to the spanning indicators.

To change the horizontal alignment (when multiple columns are merged) put colons before and/or after the ~~ to indicate the alignment:

Sample Result
:~~ Left aligned
:~~: Centered
~~: Right aligned

To change the vertical alignment (when multiple rows are merged) put one of the following chars (`^`,`=`,`_`) between the `__` to indicate the alignment:
Sample Result
_^_ Top aligned
_=_ Centered
___ Bottom aligned

Sample:

| Header 1   | Header 2 | Header 3 |
| ---------- | -------- | -------- |
| Value 1    |   :~~:   | Value 2  |
|            |    ~~    | Value 3  |
|_     =    _|    ~~    | Value 5  |
| Value 6    | Value 7  | Value 8  |

This should result in the following table:

+----------+----------+----------+
| Header 1 | Header 2 | Header 3 |
+----------+----------+----------+
|                     | Value 2  |
|                     +----------+
|       Value 1       | Value 3  |
|                     +----------+
|                     | Value 5  |
+----------+----------+----------+
| Value 6  | Value 7  | Value 8  |
+----------+----------+----------+

Install

$ pip install mdx_spanner

Usage

After installing the extension you can add it in the mkdocs.yml file:

site_name: ...
nav:
  ...
theme:
  ...
markdown_extensions:
  - mdx_spanner

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

mdx_spanner-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

mdx_spanner-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdx_spanner-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for mdx_spanner-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e72345800a9b867412dc3cb7b1c53dbf2ed327bdaf559917f9107af62eac13b3
MD5 8e432fc1e363ab689dd45331667cb5ee
BLAKE2b-256 92bcc4785b372c2dd968d4b864bcdf06b6ece3c2cd43a3148e66109a79e74622

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mdx_spanner-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for mdx_spanner-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43934ad26924418521fc908968db1611be109577c910a6a8baa6b91b12e9b4fc
MD5 9ffd7cd4fd37948e8b69e0fd7383d56f
BLAKE2b-256 7732f4653b6acac2c7b541e42c903bb106cb4a163775c7e6488c76d3b9bd8f73

See more details on using hashes here.

Supported by

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