Noizu.Comms.Markdown (noizu_comms v0.1.0)

Copy Markdown View Source

CommonMark subset parsed once, rendered per channel dialect.

Supported inline syntax: **bold**, *italic*, `code`, fenced code blocks (``` with optional language line), and [text](url) links. Everything else passes through as plain text.

dialectbolditaliclinkplain-text escaping
:discord**x***x*[t](u)none (native markdown)
:slack*x*_x_<u|t>& < > entity-escaped
:telegram*x*_x_[t](u)MarkdownV2 escape set
:whatsapp*x*_x_t (u)none

Summary

Functions

Parses markdown text into a segment tree (blocks flattened in order).

Renders markdown (raw text or segments) for a dialect.

Types

segment()

@type segment() ::
  {:text, String.t()}
  | {:bold, [segment()]}
  | {:italic, [segment()]}
  | {:code, String.t()}
  | {:code_block, String.t()}
  | {:link, [segment()], String.t()}

Functions

parse(md)

@spec parse(String.t()) :: [segment()]

Parses markdown text into a segment tree (blocks flattened in order).

render_to(md, dialect)

@spec render_to(String.t() | [segment()], atom()) :: String.t()

Renders markdown (raw text or segments) for a dialect.

to_discord(md)

to_slack(md)

to_telegram(md)

to_whatsapp(md)