CommonMark-Slack extends the commonmark.py library to add rendering of the Slack flavor of Markdown. This can be handy if you are already using standard Markdown for another purpose and would like to also produce Slack output from the same source. CommonMark-slack also allows for producing plaintext from standard Markdown, useful for the areas of Slack that use unadorned text.
You can install CommonMark-Slack from PyPI:
pip install commonmark-slack
The commonmark-slack package is supported by Python 3.6 and above.
import commonmarkslack
parser = commonmarkslack.Parser()
ast = parser.parse("Hello *World*")
renderer = commonmark.SlackRenderer()
slack_md = renderer.render(ast)
print(slack_md) # Hello _World_
renderer = commonmarkslack.PlainTextRenderer()
plain_text = renderer.render(ast)
print(plain_text) # Hello World