# `Noizu.Discord.Markdown`
[🔗](https://github.com/noizu-labs-sdks/elixir-discord/blob/v0.1.0/lib/noizu/discord/markdown.ex#L1)

GFM -> Discord markdown conversion and 2000-character message chunking.

Discord renders a subset of markdown: `#`/`##`/`###` headings, `**bold**`,
`*italic*`, `__underline__`, `~~strike~~`, `` `code` ``, fenced code blocks,
`>` quotes and lists — but no tables, HTML or deeper headings. In message
**content**, masked links unfurl previews, so links are rewritten to
`text (<url>)` (angle brackets suppress the embed preview).

## `from_markdown/2` rules

  * Fenced code blocks and inline code are passed through untouched.
  * `#`, `##`, `###` kept; `####`+ become a `**bold**` line.
  * GFM `__bold__` becomes `**bold**` (Discord's `__` is underline).
  * Links: target `:content` (default) -> `text (<url>)` (or `<url>` when the text
    is the url); with `unfurl: true` -> `text (url)`. Target `:embed` keeps
    `[text](url)` (embeds render masked links without previews).
  * Images `![alt](url)` are treated as links (alt text, or the url).
  * Tables are wrapped in a fenced code block.
  * HTML tags and comments are stripped (`<br>` -> newline); `<https://…>`
    autolinks survive; `&amp; &lt; &gt; &quot; &#39; &nbsp;` are decoded.
  * Task list items become `☐` / `☑`; thematic breaks (`---`) become `───`.
  * Runs of 3+ newlines collapse to a blank line.

Opts: `:target` (`:content` | `:embed`), `:unfurl` (boolean).

# `chunk`

```elixir
@spec chunk(String.t(), pos_integer()) :: [String.t()]
```

Splits `text` into chunks of at most `limit` characters (default 2000, Discord's
message content limit), preferring paragraph boundaries, then line breaks, then
spaces. Fenced code blocks that must be split are closed and re-opened (with the
same info string) in each chunk.

# `from_markdown`

```elixir
@spec from_markdown(String.t(), keyword()) :: String.t()
```

Converts GitHub-flavoured markdown to Discord's markdown subset. See module doc.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
