/** * tg-md — the opinionated Telegram-Markdown formatter (xtldr's house style, * grown from theSummaryBot's tg-html lineage). ONE input dialect, the * markdown LLMs actually emit, rendered to every shape a bot sends: * * markdownToRichHtml(md, coverUrl?) rich-message HTML (Bot API 10.1): real * headings/lists, optional cover * spliced after the title * markdownToTelegramHtml(md) strict parse_mode=HTML subset: # title * -> bold underlined line, ## headings -> * bold lines with breathing room, ###### * footer -> quiet plain line, bullets -> • * toPlainText(md) last-ditch fallback (quotes keep their * > marker so they still read as quotes) * tidyRichMarkdown(md) strip the stray ```fence``` models add * * The dialect contract, load-bearing and deliberate: * - `_` is NEVER emphasis — snake_case in model output survives verbatim. * Only `*italic*` / `**bold**` are honored. * - Every tag is balanced by construction: a render can never produce a * message Telegram rejects; unmatched markers stay literal. * - Pure functions of the whole string — safe for full-frame draft repaints * (bot/draft): malformed mid-stream markdown degrades to literal text * this frame and renders correctly the next. * * Typography (heading air, bullet glyph, the title underline) IS the opinion; * it becomes configurable when a second consumer needs a different look, not * before. Zero external deps, worker-safe; the HTML escaping comes from * `tg-html`, which owns the same output dialect. */ import { escapeHtml } from "../tg-html/index.js"; export { escapeHtml }; /** Unwrap a leading/trailing ```…``` code fence (some models add one) and trim. */ export declare function tidyRichMarkdown(raw: string): string; /** * Render the model's rich Markdown into Telegram's strict `parse_mode=HTML` subset, * which has no headings or lists: * `#` title -> a bold UNDERLINED line + blank line (the wordmark look) * `##`..`#####` headings -> a bold line + blank line after (air between head and body) * `######` footer heading -> a bold line, no forced air (it's the last line) * bullets (`- `/`* `/`+ `) -> a `• ` prefix * blockquote (`> `) -> `
`; `>!` -> `
` * ``` fences -> `
` (contents literal; unclosed closes at EOF)
 *   `**bold**`/`*italic*`       -> ``/``; `~~strike~~` -> ``; `||spoiler||` -> ``
 *   `` `code` `` -> ``; links -> ``
 * Only `*`-based emphasis is honored (never `_`), so `snake_case` survives. Every tag
 * is balanced, so Telegram can't reject the message; unmatched markers stay literal.
 * Spacing follows the same contract as `tg-html`: every heading is followed by a
 * blank line so sections breathe — a heading hugging its bullets reads as a wall.
 */
export declare function markdownToTelegramHtml(markdown: string): string;
/**
 * Render the model's rich Markdown into rich-message HTML (the `rich_message.html`
 * field, Bot API 10.1), which supports tags `parse_mode=HTML` lacks, so headings and
 * lists survive as real structure instead of flattening:
 *   headings  (`#`..`######`)  -> `

`..`

` (level = count of `#`) * bullets (`- `/`* `/`+ `) -> `
  • …
` (consecutive items merged) * blockquote (`> `) -> `
`; `>!` -> `
` * ``` fences -> `
` (contents literal)
 * Inline emphasis/code/links reuse {@link inlineMd}. Every tag is balanced, so Telegram
 * can't reject the message; unmatched markers stay literal.
 *
 * `coverUrl` (rich path only) embeds a cover image as a standalone `` block right after
 * the title heading (title, cover, then body), matching the rich-message photo block, which
 * accepts HTTP(S) URLs only. Ignored unless it's a well-formed http(s) URL. The strict-HTML and
 * plain fallbacks have no image support, so they never carry a cover.
 */
export declare function markdownToRichHtml(markdown: string, coverUrl?: string): string;
/**
 * Strip Markdown to plain text: the fallback when Telegram rejects the rich message.
 * Removes heading/bullet markers and emphasis, unwraps links to their text, but KEEPS
 * the `>` blockquote marker on every quote line so quotes still read as quotes with no
 * formatting to lean on. Best-effort, not a full parser.
 */
export declare function toPlainText(markdown: string): string;
//# sourceMappingURL=index.d.ts.map