module

Ark::Slack::Mrkdwn

Constants

BACKTICK_RE = /`([^`]+)`/
BLANK_LINES_RE = /\n{3,}/
BOLD_RE = /\*\*(.+?)\*\*/
BROADCAST_RE = /<![^>]*>/

Slack control tokens that could trigger mass notifications or impersonate mentions.

CODE_FENCE_RE = /```[\s\S]*?```/
HEADING_RE = Regex.new("^\\\#{1,6}\\s+([^\\n]+)$", Regex::Options::MULTILINE)
ITALIC_RE = /(?<!\*)\*([^*]+)\*(?!\*)/
LINK_RE = /\[([^\]]+)\]\(([^)]+)\)/
LINK_SCHEME_RE = /\A(?:https?:\/\/|mailto:)/i
MENTION_CAPTURE_RE = /<@(\w+)>/
STRIKE_RE = /~~(.+?)~~/
USER_MENTION_RE = /<@[^>]*>/

Class methods

convert(text : String) : String

Converts common markdown to Slack mrkdwn format, preserving code blocks. Neutralizes Slack control tokens to prevent mention/broadcast injection.

Source
format_sources(sources : Array(String)) : String

Renders source names as a bulleted list.

Source
resolve_mentions(text : String, &resolver : String -> String | Nil) : String

Replaces <@USERID> mentions with @Name using the provided resolver.

Source
sanitize(text : String) : String

Escapes Slack control tokens that could trigger notifications or impersonate users.

Source
split_message(text : String, max_len : Int32 = MAX_MESSAGE_LEN) : Array(String)

Splits text at paragraph boundaries if it exceeds max_len.

Source
strip_markdown(text : String) : String

Strips markdown formatting, returning plain text.

Source
strip_mention(text : String, user_id : String) : String

Strips a specific user's @mention from message text.

Source