Skip to main content

md2lineflex - Markdown to LINE FlexMessage Converter

PyPI version Python Versions License: MIT

A lightweight Python library that converts Markdown text into LINE Bot Flex Messages effortlessly.

Designed especially for LLM / Chatbot developers who want to render Markdown outputs (from OpenAI, Claude, etc.) as beautiful, structured LINE Flex Messages instead of plain text.


Features

  • 🚀 Zero-Config Conversion: Simply pass a Markdown string and get a LINE Messaging API compatible FlexMessage object or dict.
  • 🎨 Rich Component Support: Supports Headings, Paragraphs, Lists, Code Blocks, Quotes, Links, Images, and Tables.
  • 🔗 Flexible Link Handling: Render links as embedded URLs, inline text, or interactive LINE URI Action Buttons.
  • 🛡️ Type Safe: Fully typed with py.typed marker (PEP 561) for modern IDE auto-completion.

Compatibility

  • requires-python = ">=3.10"
  • line-bot-sdk>=3.1.0
  • mdformat>=0.7.0
  • mdformat-gfm>=0.3.0
  • mistletoe>=1.2.0

Installation

# Using uv (Recommended)
uv add md2lineflex

# Using pip
pip install md2lineflex

Prerequisite: Python >= 3.10 and line-bot-sdk >= 3.0.0


Quickstart

from linebot.v3.messaging import PushMessageRequest
from md2lineflex import to_flex

md_text = """
## Hello LINE Bot!

This is **bold text** generated from Markdown.

- Feature 1: Automatic Flex Box layout
- Feature 2: Supports [Links](https://example.com)

```python
print("Hello World")
```
"""

# Convert Markdown to FlexMessage object
flex_message = to_flex(md_text, link_mode="button")

# Send via LINE Messaging API SDK
request = PushMessageRequest(to="USER_ID", messages=[flex_message])
messaging_api.push_message(request)

Options

You can control how Markdown links [Title](https://...) are rendered in the Flex Message:

Mode Description
button (Default) Appends interactive URI action buttons below the text block.
action Renders links in text format: Title (https://...).
url_text Renders links in text format: Title [https://...].
flex_msg = to_flex(md_text, link_mode="button")

Development & Contributing

See DEVELOPMENT.md for local setup, running tests, and contribution guidelines.


License

This project is licensed under the MIT License.

Metadata

Release files for md2lineflex 0.1.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 md2lineflex 0.1.1
File Size Uploaded Provenance Actions
md2lineflex-0.1.1.tar.gz 12.4 kB With provenance Details for md2lineflex-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for md2lineflex 0.1.1
File Interpreter ABI Platform Actions
md2lineflex-0.1.1-py3-none-any.whl Python 3 none any Details for md2lineflex-0.1.1-py3-none-any.whl

Total release size: 26.8 kB

Release files / md2lineflex-0.1.1.tar.gz

Download URL md2lineflex-0.1.1.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
895d616b8b093a99a9d16719dd67e6bf2dfe83bd86633bb17372fc4440680058
BLAKE2b-256 checksum
How to use checksums
01539b51a7ba60a4e9f4e7b918524924a52b2dcfe1fadd86a3075b9acedb369c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 3, 2026.

Transparency log

Release files / md2lineflex-0.1.1-py3-none-any.whl

Download URL md2lineflex-0.1.1-py3-none-any.whl
Size 14.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce285f6b9aff9b0102ed9a3111cb6fe0311c3c086891a7a0c47300b551778539
BLAKE2b-256 checksum
How to use checksums
b616c54d88cd5d949b5f9d1643881f112cb97e7f3e94bf21722d584d545e53aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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 3, 2026.

Transparency log

Security for md2lineflex 0.1.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 md2lineflex-0.1.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 3, 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

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