htmltabletomd
htmltabletomd is for converting html tables to markdown.
Additionally, contents inside table cells can be converted to markdown if they contain HTML,
for which it uses the library htmltomarkdown .
Installation
pip install htmltabletomd
Usage
Convert HTML table to Markdown table
import htmltabletomd
html_table = """<table>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
</tr>
<tr>
<td>column 11</td>
<td>column 12</td>
</tr>
<tr>
<td>column 21</td>
<td>column 22</td>
</tr>
</table>
"""
md_table = htmltabletomd.convert_table(html_table)
print(md_table)
Output:
| Heading 1 | Heading 2 |
| :--- | :--- |
| column 11 | column 12 |
| column 21 | column 22 |
Pass all_cols_alignment argument to align text in the columns to the left, right, or center
For the above html table...
md_table = htmltabletomd.convert_table(html_table, all_cols_alignment="right")
print(md_table)
Output:
| Heading 1 | Heading 2 |
| ---: | ---: |
| column 11 | column 12 |
| column 21 | column 22 |
Allowed values: left, right or center.
Pass content_conversion_ind argument to convert html contents inside the table cells to markdown
import htmltabletomd
html_table = """
<table>
<tr>
<th>Heading <b>1</b></th>
<th>Heading <b>2</b></th>
</tr>
<tr>
<td>column <i>11</i></td>
<td>column <b>12</b></td>
</tr>
<tr>
<td>column 21</td>
<td>column <b><i>22</i></b></td>
</tr>
</table>
"""
md_table = htmltabletomd.convert_table(html_table, content_conversion_ind=True)
print(md_table)
Output:
| Heading __1__ | Heading __2__ |
| :--- | :--- |
| column _11_ | column __12__ |
| column 21 | column ___22___ |
Metadata
Release files for htmltabletomd 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| htmltabletomd-1.0.0.tar.gz | 3.8 kB | Without provenance | Details for htmltabletomd-1.0.0.tar.gz |
Release files / htmltabletomd-1.0.0.tar.gz
| Download URL | htmltabletomd-1.0.0.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53e16a63fe97cdf28393dcff01d265bbe675447eac15737bf5823641e6cfa82b
|
|
BLAKE2b-256 checksum How to use checksums |
a9e40aaa9345b9c013a0b71ee1526d561dcae08530087034c59d09abb5b86fe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.3
|
Security for htmltabletomd 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.