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.0.5.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdx_spanner-0.0.5.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for mdx_spanner-0.0.5.tar.gz
Algorithm Hash digest
SHA256 18861d845c6890c182501b00b255320116cd1884cc42df73174487d15c091402
MD5 2c04683df30e6d109864032b630e8183
BLAKE2b-256 1ff5ceb980fb6744708e683663d4ed202e2becacf71e5d5910f9e3771ade9854

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mdx_spanner-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for mdx_spanner-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 188a2287cc80a2051542ec8e46cf7918bd28a0ac20f284439d0f2825a9ff6342
MD5 13e5c16862000bee3d4577a6cab69244
BLAKE2b-256 8a77a3194c0a3e9c5bcdd8b92635fd23d0b35fa12c5e1c267745cf2657bea35d

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page