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
Built Distribution
Hashes for mdx_spanner-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 188a2287cc80a2051542ec8e46cf7918bd28a0ac20f284439d0f2825a9ff6342 |
|
MD5 | 13e5c16862000bee3d4577a6cab69244 |
|
BLAKE2b-256 | 8a77a3194c0a3e9c5bcdd8b92635fd23d0b35fa12c5e1c267745cf2657bea35d |