Skip to main content

Module markdown

Module markdown 

Source
Expand description

The portable Markdown subset a message’s text is written in, and its translations.

Inline: **bold**, *italic* or _italic_, `code`, [text](url) and backslash escapes (\*). Lines: a line starting with - or * is a bullet; other lines are text, kept as written (line breaks matter in chat). There are no headings and no tables: the title is separate.

Core escapes every value a template interpolates (escape), so a value containing * or _ stays literal. Each destination translates with one of the to_* functions.

Enums§

Inline
Line

Functions§

escape
s with every character that means something in the subset backslash-escaped.
fit
text (portable Markdown) translated with translate, fitting in max characters: when the translation is too long, whole lines are dropped from the end of the source before translating, so a cut never lands inside the dialect’s markup, and marker (already in the dialect) is appended. The second value says whether it was cut.
html_escape
t safe as HTML text or an attribute value.
parse
Parse text line by line.
to_google_chat
Google Chat’s text formatting (the same marks as Slack’s).
to_html
An HTML fragment: lines become paragraphs (consecutive lines joined by <br>), bullets a list.
to_plain
Plain text: marks removed, links as text (url), bullets as - .
to_slack
Slack’s mrkdwn, which has no escapes: &, < and > become entities, and literal *, ~ and ` become look-alikes so they can’t start formatting.
to_teams
The Markdown Microsoft Teams renders in an Adaptive Card text block.
truncate
text cut to at most max characters including marker, at a line break when one is close enough; None when it already fits.