Skip to main content

Convert Telegram MarkdownV2 text to LINE Flex Messages

Project description

tg-markdown-to-flex

Convert Telegram MarkdownV2 text to LINE Flex Messages.

Available as both a Rust crate and a Python package (via PyO3).

What it does

Takes a string with Telegram MarkdownV2 formatting and produces a LINE Flex Message JSON — a bubble with styled text spans, code blocks, and link buttons.

Formatting mapping

Telegram MarkdownV2 LINE Flex
*bold* span weight: "bold"
_italic_ span style: "italic"
__underline__ span decoration: "underline"
~strikethrough~ span decoration: "line-through"
`inline code` span with red color, small size
```code block``` separate text component, red/small
||spoiler|| span with near-white color
[text](url) blue underlined span + footer URI button

Python

Requires Python 3.13+.

Installation

uv add tg-markdown-to-flex

# or
pip install tg-markdown-to-flex

Usage

import json
from tg_markdown_to_flex import tg_markdown_to_flex

flex_json = tg_markdown_to_flex("Hello *bold* and _italic_ with [a link](https://example.com)")
message = json.loads(flex_json)

# Send via LINE Messaging API
# line_bot_api.push_message(to, FlexMessage(alt_text=message["altText"], contents=message["contents"]))

The function returns a JSON string representing a complete Flex Message (type "flex" with altText and contents).

Type checking

The package ships with PEP 561 type stubs.

Rust

Installation

[dependencies]
tg-markdown-to-flex = "0.1.0"

Usage

use tg_markdown_to_flex::{tg_markdown_to_flex, tg_markdown_to_flex_json};

// Get a FlexMessage struct
let message = tg_markdown_to_flex("Hello *world*");

// Or get JSON directly
let json = tg_markdown_to_flex_json("Hello *world*");

Testing

cargo test

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tg_markdown_to_flex-0.1.2.tar.gz (19.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (254.0 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (247.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_11_0_arm64.whl (221.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl (223.4 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

File details

Details for the file tg_markdown_to_flex-0.1.2.tar.gz.

File metadata

  • Download URL: tg_markdown_to_flex-0.1.2.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for tg_markdown_to_flex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a4ee4ace0e575a9eb82130b91761c26873616855ff324bb74d8ed5b3f9ef4d03
MD5 af4b7239853d83c90cbad17d4a473824
BLAKE2b-256 4aad84619548eeee56fdfb633961c10aa60c88b81c6b786fba5436b916ecf5c7

See more details on using hashes here.

File details

Details for the file tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 254.0 kB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2bd3f0f4d57cf7c4054f1cfd129ae7cf89c2f8627a9b0fcefee342f522c6b04b
MD5 2dea206c92c856ad27c0492df5fbf73e
BLAKE2b-256 ea482830670269a3a6c0e4248b4d479a957bd0bf32354596568821a013175ecc

See more details on using hashes here.

File details

Details for the file tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 247.4 kB
  • Tags: CPython 3.13, manylinux: glibc 2.17+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for tg_markdown_to_flex-0.1.2-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ddc7c9acc8d01789d06ed9298e6b7231a1abe1b0299ac50694e4a5a3536e30bd
MD5 d86f9c6138b29dc671479da845747738
BLAKE2b-256 02c8fccca674c8dd6998690b5a648e8aff0aed0236b6d0fa257609e55e8051b5

See more details on using hashes here.

File details

Details for the file tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

  • Download URL: tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 221.1 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93464cbe42c9a2f331bcd2c4501c356fcb8e95e2b8ed9bc5f0168bf8f9672616
MD5 026801b0531cf118baa762d8b41c0131
BLAKE2b-256 5163e7d8b621e8669182e631cb6dcda5c394a907c00d20e250b81e6fa9c73c96

See more details on using hashes here.

File details

Details for the file tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl
  • Upload date:
  • Size: 223.4 kB
  • Tags: CPython 3.13, macOS 10.12+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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}

File hashes

Hashes for tg_markdown_to_flex-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 293faabb9c92d29f46119e98215c2131526f513db4a271dfdafb3fa6fe7b9bf1
MD5 6981ab0f705c3e13dfbee33514c60292
BLAKE2b-256 7554c31732eeab70fa329a4da0f776766f6f3cc2616ed2e29fdfb1e15d80d2a3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page