Skip to main content

Python adaptation of the javascript html-to-mrkdwn library.

Project description

mrkdwnify

mrkdwnify is an adaptation of the javascript html-to-mrkdwn library. There are some small implementation differences between html-to-mrkdwn and mrkdwnify.

If you don't know what mrkdwn is, it's a subset of Markdown made by Slack, to enable users to craft nicely formatted messages on their platform. Do not use this if you're looking for a regular html to markdown parser. Try: https://github.com/matthewwithanm/python-markdownify

mrkdwnify itself is derived directly from the python-markdownify library. It overrides several methods from the original library and passes option presets to make outputs compatible with the mrkdwn spec.

  1. Consecutive and are not treated as inline elements.
  2. For "checked" attributes in input tags you need to provide a "true" value

Ex: <li class="task-list-item"><input class="task-list-item-checkbox" type="checkbox" checked="true">item</li> => ☑︎ item

Other than that the implementation should be the same.

Important things to note:

  • <table> elements will not be rendered at all (not even their content) unless you pass render_tables=True as a keyword argument.

Installation

Until I can figure out PyPi:

pip install git+https://github.com/bengelb-io/py-html-to-mrkdwn

Use

from mrkdwnify import mrkdwnify

html = "<h1>Hello this is a mrkdwn header!</h1>"
mrkdwn = mrkdwnify(html) # *Hello this is a mrkdwn header!*

html = '<p>Hello this is an inline link! <a href="https://www.example.com">Example</a></p>'
mrkdwn = mrkdwnify(html) # Hello this is an inline link! <https://www.example.com|Example>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mrkdwnify-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

mrkdwnify-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file mrkdwnify-0.1.1.tar.gz.

File metadata

  • Download URL: mrkdwnify-0.1.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for mrkdwnify-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f6ab9c561e1939204a1d3c57e587bcf2b5329ac0971085eee5854aa3822d727
MD5 cdc682ad1bd3cccfe04f25622f2329a5
BLAKE2b-256 b1a35d34a289cb10dd64472a4c6930a48791ae4bbc575b1588bf890ba5fbf898

See more details on using hashes here.

File details

Details for the file mrkdwnify-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: mrkdwnify-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for mrkdwnify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a7637720cf0118b46daa36d4c3ccfc961b66aa57e59cdb29a71c8f8f131c7571
MD5 2e5c419ba4c2d33444ee3afa64ba9592
BLAKE2b-256 03136609c7f92c128ca02d607300db381dc157625bad39916b55b33052184f8e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page