Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Formats and conversion

The input format is what the caller says the body is written in (-i, the server’s format field, Message::format). The service format is what the service renders (its default or ?format=). When they differ, mercurio converts the body. With no input format declared nothing is converted: the body passes through as the service’s own format.

InputMeaning
nonepassthrough: no conversion, no Markdown repair
textplain text; escaped when a service renders HTML or Markdown
markdownCommonMark (with GFM tables); rendered to HTML where needed
htmlHTML; reduced to text or Markdown where needed

The CLI and the HTTP server declare none unless -i or format is given; the library uses Message::format, else Asset::body_format.

Conversion table

From \ Totexthtmlmarkdown
textunchangedHTML-escaped, newlines become <br/>syntax characters backslash-escaped
htmltags removed, block elements become line breaks, entities decodedunchangedconverted to Markdown
markdownunchanged (no converter)rendered (CommonMark, GFM tables, soft breaks as <br />)unchanged

For services without a title field, the title is converted the same way and merged into the body (see the pipeline).

Service formats

Each service declares its formats, the first being its default; the service pages list them under “Body formats”. Most services are text only; e-mail and the mail APIs default to HTML; Slack, Google Chat, Webex Teams, Rocket.Chat and others take Markdown. ?format= picks one (resolution rules). Markdown input to a text-only service is sent unchanged.

Dialects

Some services have their own markup and convert each piece after the generic conversion (Notify::convert):

ServiceDialect
SlackSlack mrkdwn (*bold*, <url|text> links)
Google ChatGoogle Chat text formatting
TelegramTelegram HTML (reduced tag set) or MarkdownV1/V2
MatrixHTML (formatted_body); Slack-style text in Slack mode
PushoverPushover’s HTML subset
Signal APISignal styled text ranges
Evolution API (WhatsApp)WhatsApp formatting
KOOKKMarkdown
MastodonMastodon text

Dialect conversion only runs for a declared input format. Because the converted text can be longer, size limits are applied again: with overflow=split the converted piece is re-split, with truncate it is cut to fit.

Markdown rendering

Markdown is rendered with pulldown-cmark (CommonMark plus GFM tables); HTML to text and HTML to Markdown use a small HTML tokenizer. When a split cuts Markdown, mercurio repairs unclosed emphasis, code fences and link syntax.