Skip to main content

mdto-messages for Python

Convert a Markdown draft into text for a chat composer, safe HTML for email, or JSON-ready request bodies for messaging APIs. Conversion runs locally. Python 3.10 or newer is required.

Install

python -m pip install mdto-messages

PyPI versions · Source repository

Convert a draft

from mdto_messages import convert, to_messages

draft = convert("Please **review**.", "whatsapp")
assert draft.text == "Please *review*."

message = to_messages("😀 **Ready**", "telegram").messages[0]
assert message["entities"] == [{"type": "bold", "offset": 3, "length": 5}]

convert(markdown, target="plaintext") returns text, optional html, format, target, and diagnostics. Draft targets are plaintext, html, email, whatsapp, threema, viber, google-chat, signal, discord, telegram, slack, and teams.

to_messages(markdown, target) returns an ordered list of message bodies in messages, plus diagnostics. API targets are whatsapp, threema, viber, google-chat, discord, telegram, slack, and teams. Each body can be passed to json.dumps. Slack bodies include a per-message text fallback for notifications and screen readers. It escapes Slack control characters, abbreviates previews that exceed 3,900 UTF-16 units after escaping, and adds part numbers to multipart replies. The rich-text blocks retain the full message. The caller provides delivery, credentials and recipient information.

Both functions accept keyword-only policy and max_input_length. The default readable policy preserves paragraph spacing. compact reduces spacing, and strict raises an error when formatting must be simplified. Diagnostics describe each adjustment with a stable code, severity, and suggested action. The default limit is 32,768 UTF-16 code units. Set a value from 1 through 131,072 to adjust it. Rendering and platform-specific size limits also apply.

Catch ConversionError and check exc.code: INVALID_INPUT denotes invalid Markdown input or options, UNKNOWN_TARGET an unsupported target, LIMIT an exceeded resource or payload bound, and LOSS an adjustment that strict policy rejects.

Try the browser tools for chat drafts, email, and plain text.

Metadata

Release files for mdto-messages 0.3.0

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

Source distribution (sdist)

Source distribution for mdto-messages 0.3.0
File Size Uploaded Provenance Actions
mdto_messages-0.3.0.tar.gz 16.2 kB With provenance Details for mdto_messages-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mdto-messages 0.3.0
File Interpreter ABI Platform Actions
mdto_messages-0.3.0-py3-none-any.whl Python 3 none any Details for mdto_messages-0.3.0-py3-none-any.whl

Total release size: 35.4 kB

Release files / mdto_messages-0.3.0.tar.gz

Download URL mdto_messages-0.3.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
dcec76c0684b61419f0cb5d6991f94c801b83f0f101269f028358364722c66e1
BLAKE2b-256 checksum
How to use checksums
7c7acbe44b0690d1a1f805a2d784690402870039c656e03903a28668070a97c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / mdto_messages-0.3.0-py3-none-any.whl

Download URL mdto_messages-0.3.0-py3-none-any.whl
Size 19.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49796520285b886c1c82c79621385e22c64db45d0bace7f34d4099038525824d
BLAKE2b-256 checksum
How to use checksums
945b9d443b5e56438764b162fc476e1f592db7df0912c05bf2eb07f7aee364c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for mdto-messages 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mdto_messages-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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