A package used to generate basic markdown tables from a list of dicts
Project description
markdownTable
A class used to generate padded tables in a markdown code block
Args:
data (list): List of dicts with uniform key : value pairs. The keys will be used for generating the header and values -- the rows.
row_sep (str): A flag used to indicate how and where to insert row separators. Possible values are 'always'/'topbottom'/None where:
'always 'inserts separators between each individual data row
'topbottom' inserts separators above the header and below the last row
'None' omits the insertion of a row separator
padding_width (int): Value used to indicate how much extra padding to insert to table cells.
padding_weight (str): A flag used to indicate the strategy of applying the padding indicated through padding_width.
Possible values are 'left'/'right'/'centerleft'/'centerright' where:
'left' aligns items in cells to the end of the cell
'right' aligns items in cells to the beginning of the cell
'centerleft' centers items with the extra padding allocated to the beginning of the cell
'centerright' centers items with the extra padding allocated to the end of the cell
padding_char (str): Custom character to fill extra and normal padding with. Default is a blank space.
newline_char (str): Custom character to be used for indicating a newline
Methods
-------
getHeader()
gets unescaped table header
getBody()
gets unescaped table content
getMarkdown()
gets complete escaped markdown table
Installation
You can install it via pip with the following command
pip3 install py-markdown-table
and consequently import it via
from markdownTable import markdownTable
Examples
markdownTable(data, row_sep = 'always').getMarkdown()
+----------------------------------------+
| title | time | date |seats|
+------------+-----------+---------+-----+
|Vrij Zwemmen|21:30-23:00|Wed 09.12|24/24|
+------------+-----------+---------+-----+
|Vrij Zwemmen|12:00-13:00|Thu 10.12|18/18|
+------------+-----------+---------+-----+
|Vrij zwemmen| 7:30-8:30 |Fri 11.12|18/18|
+------------+-----------+---------+-----+
|Vrij Zwemmen|13:15-14:15|Sat 12.12|18/18|
+----------------------------------------+
markdownTable(data, row_sep = 'topbottom').getMarkdown()
+----------------------------------------+
| title | time | date |seats|
|Vrij Zwemmen|21:30-23:00|Wed 09.12|24/24|
|Vrij Zwemmen|12:00-13:00|Thu 10.12|18/18|
|Vrij zwemmen| 7:30-8:30 |Fri 11.12|18/18|
|Vrij Zwemmen|13:15-14:15|Sat 12.12|18/18|
+----------------------------------------+
markdownTable(data, row_sep = 'topbottom', padding_width = 5, padding_weight='left').getMarkdown()
+------------------------------------------------------------+
| title| time| date| seats|
| Vrij Zwemmen| 21:30-23:00| Wed 09.12| 24/24|
| Vrij Zwemmen| 12:00-13:00| Thu 10.12| 18/18|
| Vrij zwemmen| 7:30-8:30| Fri 11.12| 18/18|
| Vrij Zwemmen| 13:15-14:15| Sat 12.12| 18/18|
+------------------------------------------------------------+
markdownTable(data, row_sep = 'topbottom', padding_width = 5, padding_weight='centerright').getMarkdown()
+------------------------------------------------------------+
| title | time | date | seats |
| Vrij Zwemmen | 21:30-23:00 | Wed 09.12 | 24/24 |
| Vrij Zwemmen | 12:00-13:00 | Thu 10.12 | 18/18 |
| Vrij zwemmen | 7:30-8:30 | Fri 11.12 | 18/18 |
| Vrij Zwemmen | 13:15-14:15 | Sat 12.12 | 18/18 |
+------------------------------------------------------------+
markdownTable(data, row_sep = 'always', padding_width = 5, padding_weight='centerright', padding_char = '.').getMarkdown()
+------------------------------------------------------------+
|......title......|......time......|.....date.....|..seats...|
+-----------------+----------------+--------------+----------+
|..Vrij Zwemmen...|..21:30-23:00...|..Wed 09.12...|..24/24...|
+-----------------+----------------+--------------+----------+
|..Vrij Zwemmen...|..12:00-13:00...|..Thu 10.12...|..18/18...|
+-----------------+----------------+--------------+----------+
|..Vrij zwemmen...|...7:30-8:30....|..Fri 11.12...|..18/18...|
+-----------------+----------------+--------------+----------+
|..Vrij Zwemmen...|..13:15-14:15...|..Sat 12.12...|..18/18...|
+------------------------------------------------------------+
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
Hashes for py_markdown_table-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a43a99f61813d1c3f23578d0215c723e30fc278d73621d29bdb9d2e149b93454 |
|
MD5 | c10292a70f3eb731103ede31d662b86d |
|
BLAKE2b-256 | 86fa453e5fe5005e807bc61f8e4ca0ae515cf4ed4a190ba86fda1ac28c566087 |