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.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e17d5208ed3a153c4dfd359dcab202ac7c3e4ead6eeeb09bef48d40567f07cd |
|
MD5 | dd14499c3414b6f3bb1d3aa02c8fb684 |
|
BLAKE2b-256 | fa2296ac4430602e3961a81157a6671389deb7b0b91888cb0f3bf758e0cebf69 |