Vibe.Gateway.Telegram.Text (vibe v0.2.2)

Copy Markdown View Source

Telegram-safe text rendering and splitting helpers.

Telegram accepts a small HTML subset and limits messages to 4096 visible characters after entity parsing. These helpers prefer safety over clever Markdown fidelity: raw text is escaped, a small Markdown-like subset is mapped to Telegram HTML, and long messages are split on paragraph/line/word boundaries before sending.

Summary

Functions

Converts and splits text into Telegram-safe HTML chunks.

Limits a string with an ellipsis, preserving valid grapheme boundaries.

Splits text into chunks that fit Telegram's visible text limit.

Converts plain/Markdown-like text to Telegram-safe HTML.

Functions

html_chunks(text, opts \\ [])

@spec html_chunks(
  String.t(),
  keyword()
) :: [String.t()]

Converts and splits text into Telegram-safe HTML chunks.

limit(text, max_length)

@spec limit(String.t(), pos_integer()) :: String.t()

Limits a string with an ellipsis, preserving valid grapheme boundaries.

split(text, opts \\ [])

@spec split(
  String.t(),
  keyword()
) :: [String.t()]

Splits text into chunks that fit Telegram's visible text limit.

to_html(text)

@spec to_html(String.t()) :: String.t()

Converts plain/Markdown-like text to Telegram-safe HTML.