Skip to main content

mrkdwnify is a 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.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

mrkdwnify-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for mrkdwnify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b1ab6abde318f960ea9c33d94830505a6c9381e0c841ab32a524e1ab46df4bb
MD5 c428ddebc67c948468f5e850afa95308
BLAKE2b-256 637ee3f617d65964209213344f4ea8c52c0af991bfa50864fe3688a8f2cff364

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for mrkdwnify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f48d973942eb7ff76ce0c67187a211ba55341d751cb4cc7ba28194399f9abe9
MD5 4adbb58532c8754c7610eddf215c41d3
BLAKE2b-256 f21eb918d552b921b76796058b60559bb10200022e83c81ab1a1e4e050dab106

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