Metadata-Version: 2.1
Name: mdx_spanner
Version: 0.1.0
Summary: Span table cols and rows in MkDocs
Home-page: https://gitlab.com/mschleeweiss/mdx_spanner
Author: Marc Schleeweiß
Author-email: mschleeweiss@gmail.com
Project-URL: Bug Tracker, https://gitlab.com/mschleeweiss/mdx_spanner/-/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Markdown>=3.0

# mdx_spanner

This package enables `rowspan` and `colspan` in markdown tables when using [MkDocs](https://www.mkdocs.org/).

## 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:

```md
| 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:
```md
+----------+----------+----------+
| 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 |

<br>
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:

```md
| 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:


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


## Install

```console
$ pip install mdx_spanner
```

## Usage

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

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