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.1

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.1
File Size Uploaded Provenance Actions
mdto_messages-0.3.1.tar.gz 17.0 kB With provenance Details for mdto_messages-0.3.1.tar.gz

Built distribution (wheel)

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

Total release size: 36.9 kB

Release files / mdto_messages-0.3.1.tar.gz

Download URL mdto_messages-0.3.1.tar.gz
Size 17.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8573344f491a2085a5d2fe66146463bb63a483a9b377103722c8c9b4b9a29ffa
BLAKE2b-256 checksum
How to use checksums
a3a323872468be3b6c41cc06ebd081b64edfe8d997d4bf681fc70cab45e55a93
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 30, 2026.

Transparency log

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

Download URL mdto_messages-0.3.1-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4b787713b9996985657286bedb9eb33b7d1769f2070d3c22eb7554265bbe81a
BLAKE2b-256 checksum
How to use checksums
c19bb6e844ef508a45174c91322cf8963ace3964d398fb455597a929165972f4
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 30, 2026.

Transparency log

Security for mdto-messages 0.3.1

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.1.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 30, 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