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

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdx_spanner-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 71d25e9efb4e647b94ad653676bc9a7f40deddb93ed10b9c8bbb1a5ac0d11ac8
MD5 235f911050695b923b33ef06db97d495
BLAKE2b-256 7980bc30cc3a52b013e3b2ed532eb9ac133e87823c236de9d5e6b62b8f766e75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mdx_spanner-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3baf2ec5eb2d9893155d749da1c6c01521ca0609918a20390d4c4cb460fd1878
MD5 f0023a4f228b4caad992d78df895f586
BLAKE2b-256 19207d56e8dd1753d8430d945e722bdc0a8a7091cf2a2588c7e6dfcca80b6ead

See more details on using hashes here.

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