Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
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
.
pip install htmltabletomd
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 |
all_cols_alignment
argument to align text in the columns to the left, right, or centerFor 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
.
content_conversion_ind
argument to convert html contents inside the table cells to markdownimport 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___ |
FAQs
Convert html table to markdown table
We found that htmltabletomd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.