module

Autobot::Channels::MarkdownToSlackMrkdwn

Converts standard Markdown to Slack mrkdwn format.

Slack mrkdwn differences from standard Markdown:

  • Bold: text (single asterisk, not double)
  • Italic: text (same)
  • Strikethrough: ~text~ (single tilde, not double)
  • Links: <url|text> (not text)
  • Code: code and code (same, but no language hints)
  • Headers: not supported natively, converted to bold
  • Blockquotes: > text (same)

Constants

BOLD_STAR_REGEX = /\*\*(.+?)\*\*/
BOLD_UNDERSCORE_REGEX = /__(.+?)__/
BULLET_LIST_REGEX = /^[-*]\s+/m
CODE_BLOCK_PREFIX = "\u0000CB"
CODE_BLOCK_REGEX = /```(\w*)\n?([\s\S]*?)```/
HEADER_REGEX = Regex.new("^\#{1,6}\\s+(.+)$", Regex::Options::MULTILINE)
HR_REGEX = /^[-*_]{3,}\s*$/m
INLINE_CODE_PREFIX = "\u0000IC"
INLINE_CODE_REGEX = /`([^`]+)`/
LINK_REGEX = /\[([^\]]+)\]\(([^)]+)\)/
SLACK_MAX_LENGTH = 40000
STRIKETHROUGH_REGEX = /~~(.+?)~~/
SUFFIX = "\u0000"

Class methods

convert(text : String) : String
Source
split_message(text : String) : Array(String)
Source