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.

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.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 md2lineflex 0.1.0
File Size Uploaded Provenance Actions
md2lineflex-0.1.0.tar.gz 10.7 kB With provenance Details for md2lineflex-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 24.1 kB

Release files / md2lineflex-0.1.0.tar.gz

Download URL md2lineflex-0.1.0.tar.gz
Size 10.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de569dfa406226f15adcda779739685c67fc97b6eb0170ff3fba35ff6b1dacf2
BLAKE2b-256 checksum
How to use checksums
02261cb4a0597322d2ab71dcfb9806d6ea64e5b83248ff53ed7e86bb2e832bd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 Aug 23, 2026.

Transparency log

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

Download URL md2lineflex-0.1.0-py3-none-any.whl
Size 13.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5662c70f933a6719058806001ff7e812ea419cc6039cdfcd200d77256349eb98
BLAKE2b-256 checksum
How to use checksums
c859c60f0cada959826fb3a2c0fe9041a3e8dcee0c5a685a0b203075e9b1afe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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 Aug 23, 2026.

Transparency log

Security for md2lineflex 0.1.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 md2lineflex-0.1.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 Aug 23, 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.0 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