Skip to main content

Mistune Slack Renderer

Convert Markdown into Slack Block Kit format using Mistune. Useful for LLM-powered chatbots!

Kitchen sink demo

Features

  • Produces Slack Block Kit JSON for posting messages to Slack
  • Renders Slack users, channels, broadcasts, and emojis
  • Supports strikethrough, task lists, URLs, and code blocks
  • Headings, paragraphs, block quotes, and dividers
  • Ordered and bullet lists (with nesting and task-list support)
  • Inline code and fenced code-block rendering
  • Link conversion into Slack link elements
  • Note: images not supported. It should be easy to add by subclassing mistune_slack.renderer.SlackRenderer and adding your own logic (such as you may want to upload the image somewhere as well)

Install

uv add mistune-slack

Usage

from mistune_slack import render_slack_blocks_from_markdown

markdown = "# Hello, *world*!"
blocks = render_slack_blocks_from_markdown(markdown)
print(blocks)  # post `blocks` to Slack

Advanced usage

import mistune
from mistune.plugins.formatting import strikethrough
from mistune.plugins.task_lists import task_lists
from mistune.plugins.url import url

from mistune_slack import SlackRenderer, slack_pluginSlackRenderer

markdown = "# Hello, *world*!"
renderer = mistune.create_markdown(renderer=SlackRenderer(), plugins=[slack_plugin, strikethrough, url, task_lists])
blocks: list[dict] = renderer(markdown)  # type: ignore
print(blocks)  # post `blocks` to Slack

Testing

uv run test

License

MIT

Metadata

Release files for mistune-slack 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mistune-slack 0.1.4
File Size Uploaded
mistune_slack-0.1.4.tar.gz 71.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mistune-slack 0.1.4
File Interpreter ABI Platform
mistune_slack-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 81.8 kB

Release files / mistune_slack-0.1.4.tar.gz

Download URL mistune_slack-0.1.4.tar.gz
Size 71.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ae0f2690868328645fc5ca0a7642159e150f342f274046071bfc7fb480f2fea6
BLAKE2b-256 checksum
How to use checksums
813608b5c3ef1757a9638789a2bc03346a612f75fb837ca008b124b2c721df8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.1

Release files / mistune_slack-0.1.4-py3-none-any.whl

Download URL mistune_slack-0.1.4-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66b3f0ea3ef034049493c7dafd47f67870804b35a0352fd4ab952e077ca3a5a6
BLAKE2b-256 checksum
How to use checksums
0bbf2f1eb4f250d754994d1671a03b34fecf7ae6023427594ea02fcd394697e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.1

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page