Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pyhtml2md

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyhtml2md

Transform your HTML into clean, easy-to-read markdown with pyhtml2md.

  • 1.6.0
  • PyPI
  • Socket score

Maintainers
1

pyhtml2md

pyhtml2md provides a way to use the html2md C++ library in Python. html2md is a fast and reliable library for converting HTML content into markdown.

  • Installation
  • Basic usage
  • Advanced usage
  • Supported Tags
  • License

[TOC]

Installation

You can install using pip:

pip3 install pyhtml2md

Basic usage

Here is an example of how to use the pyhtml2md to convert HTML to markdown:

import pyhtml2md

markdown = pyhtml2md.convert("<h1>Hello, world!</h1>")
print(markdown)

The convert function takes an HTML string as input and returns a markdown string.

Advanced usage

pyhtml2md provides a Options class to customize the generation process.
You can find all information on the c++ documentation

Here is an example:

import pyhtml2md

options = pyhtml2md.Options()
options.splitLines = False

converter = pyhtml2md.Converter("<h1>Hello Python!</h1>", options)
markdown = converter.convert()
print(markdown)
print(converter.ok())

Supported Tags

pyhtml2md supports the following HTML tags:

TagDescriptionComment
aAnchor or linkSupports the href, name and title attributes.
bBold
blockquoteIndented paragraph
brLine break
citeInline citationSame as i.
codeCode
ddDefinition data
delStrikethrough
dfnDefinitionSame as i.
divDocument division
emEmphasizedSame as i.
h1Level 1 heading
h2Level 2 heading
h3Level 3 heading
h4Level 4 heading
h5Level 5 heading
h6Level 6 heading
headDocument headerIgnored.
hrHorizontal line
iItalic
imgImageSupports src, alt, title attributes.
liList item
metaMeta-informationIgnored.
olOrdered list
pParagraph
prePreformatted textWorks only with code.
sStrikethroughSame as del.
spanGrouped elementsDoes nothing.
strongStrongSame as b.
tableTableTables are formatted!
tbodyTable bodyDoes nothing.
tdTable data cellUses align from th.
tfootTable footerDoes nothing.
thTable header cellSupports the align attribute.
theadTable headerDoes nothing.
titleDocument titleSame as h1.
trTable row
uUnderlinedUses HTML.
ulUnordered list

License

pyhtml2md is licensed under The MIT License (MIT)

Keywords

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc