This is an extended version of the tables extension of Python-Markdown. It contains addtions from the cell_row_span extension and allows to create tables without header.
Project description
Tables-Extended
Summary
This fork is created just to create a pip package
pip install markdown-tables-extended
- In mkdocs.yaml
- markdown_tables_extended
goes in themarkdown_extension:
section
This is an extended version of the tables extension of Python-Markdown. It contains addtions from the cell_row_span extension and allows to create tables without header.
tables_extended
is backward compatible to tables
and nearly backward compatible to cell_row_span
.
Syntax
Basic table creation
The tables_extended
extension can be used to create tables using markdown like the default tables extension:
First Header | Second Header
------------- | -------------
Content Cell | Content Cell
Content Cell | Content Cell
renders as
.-------------------------------.
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
`-------------------------------`
The separator row can be used to specify the horizontal alignment of the cells' content:
Header 1 | Header 2 | Header 3
:------- | :------: | -------:
Cell 1 | Cell 2 | Cell 3
renders as
.-------------------------------------------.
| Header 1 | Header 2 | Header 3 |
| ----------- | ------------ | ------------ |
| Cell 1 | Cell 2 | Cell 3 |
`-------------------------------------------`
Tables without header
If no row is provided above the separator line, no header is generated:
------ | ------
Cell 1 | Cell 2
Cell 3 | Cell 4
becomes
.-----------------.
| Cell 1 | Cell 2 |
| Cell 3 | Cell 4 |
`-----------------`
Merging of columns or rows
| Column 1 | Col 2 | Big row span |
|:-----------------------:|-------| -------------- |
| r1_c1 spans two cols || One large cell |
| r2_c1 spans two rows | r2_c2 | |
|_^ _| r3_c2 | |
| ______  | r4_c2 |_ _|
The example renders as:
.--------------------------------------------------.
| Column 1 | Col 2 | Big row span |
|---------------------------------+----------------|
| r1_c1 spans two cols | |
|---------------------------------| |
| r2_c1 spans two rows | r2_c2 | |
| |-------| One large cell |
| | r3_c2 | |
|-------------------------+-------| |
| ____ | r4_c2 | |
`--------------------------------------------------'
To span cells across multiple columns, end them with two or more consecutive vertical bars. Cells to the left will be merged together, as many cells are there are bars. In the example above, there are two bars at the end of cell 2 on row 1, so the two cells to the left of it (numbers 1 and 2) are merged.
To span cells across rows, fill the cell on the last row with at least two
underscores, one at the start and the other at the end of its content, and no
other characters than spaces, underscores, ^
, -
or =
. This is referred to as
the marker. The cell with the marker and all the empty cells above it to the
first non-empty cell will be made into a single cell, with the content of the
non-empty cell. See column 3 ("Big row span") in the example.
By default the contents are vertically aligned using baseline
alignment, which
is the default used by browsers. To
align to the top, include at least one ^
character in the marker between the
two underscores; for example, |_^^^_|
or simply |_^ _|
. See row 2 in
column 1 of the example, which is merged with row 3 and aligned at the top. To
align to the bottom, use at least one =
character between the underscores;
for example, |_ = _|
. To align in the middle of the cell, include at least
one -
character in the marker row. Including more than one of ^
, -
and =
in a marker raises a ValueError
exception.
Vertical alignment codes:
^
sets an alignment to the top-
sets middle alignment (new withtables_extended
)=
sets bottom aligment
Note: If this extension finds a cell with at least two underscores and no other
characters other than spaces, ^
or =
, it assumes it's a row span marker and
attempts to process it. If you need a cell that looks like a marker (generally
one with only underscores in it), add the text 
as well --- this extension
won't process it as a row span marker and Markdown will change the 
to a
space.
Installation
Either clone this repository or download the released package from github and unpack it.
Change into the new directory. tables_extended
can now be installed using install.sh
,
which installs the package using pip
:
pip install .
or use the setup.py
script:
python setup.py install --user
Usage
See Extensions for general extension usage. Use tables_extended
as the name of the extension.
This extension does not accept any special configuration options.
The extension can be used by either providing the markdown processor with an extension instance
from markdown_tables_extended import TableExtension
markdown.markdown(some_text, extensions=[TableExtension()])
or by using the extension name
markdown.markdown(some_text, extensions=['markdown_tables_extended'])
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file markdown_tables_extended-0.1.3.tar.gz
.
File metadata
- Download URL: markdown_tables_extended-0.1.3.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b4224220e71c4566503bd1b15584afacec869bb173b65a363e51ce9a972651c |
|
MD5 | 430a49fe832a2aafc65a9c21fda82121 |
|
BLAKE2b-256 | af476bd6d9192ea3916bd59596ecf0300a5ef0141f5822e0d781efe3608b0544 |
File details
Details for the file markdown_tables_extended-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: markdown_tables_extended-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27614ab7bb35920c8eaf85dddf081edbfed12f15ac2176e1a439f9216f0117cb |
|
MD5 | f067d06108c1fa8e80957e9f4a3c9b05 |
|
BLAKE2b-256 | 13b8d0de942938d404bdabfdde59b071a2fdf1ca458964074cfe47bc73f35bb9 |