Skip to content

This repository contains a Python script that converts an HTML table to a markdown table.

Notifications You must be signed in to change notification settings

PFarahani/html-to-md-table-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

HTML Table to Markdown Table Converter

This script converts an HTML table to a Markdown table with the following conditions:

  • If a text is separated with a new line within a <td> tag, rather than going to a new line or printing 'n', use the HTML <br> tag to position the text within the cell.
  • If the text has attributes that cannot be converted to markdown, for example <span style>, the script will print it exactly as an HTML tag.

Usage

from html_to_markdown import html_to_markdown

html_table = '<table>...</table>'
markdown_table = html_to_markdown(html_table)
print(markdown_table)

Note

This script is a basic example of how to do the conversion and you might need to handle more edge cases, add error handling and validation.

Requirements

Installation

pip install beautifulsoup4

Contributing

Feel free to fork this repository, improve the code and submit a pull request for review.

About

This repository contains a Python script that converts an HTML table to a markdown table.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages