# _

Fast. Extensible. Phoenix-native. AI-ready.

iex> Interactive Elixir
[-] [o] [x]
_

powered by comrak | ammonia | autumnus

// mix.exs
def deps do
  [{:mdex, "~> 0.11"}]
end
$ Terminal
$ mix igniter.install mdex

## See It In Action

Markdown in. Everything out.

# Markdown Input
[-][o][x]
# Welcome to **MDEx**

Features:
- Fast
- Extensible
- Phoenix-ready

```elixir
MDEx.to_html!("# Hello")
```
>> Output
<h1>Welcome to <strong>MDEx</strong></h1>
<p>Features:</p>
<ul>
  <li>Fast</li>
  <li>Extensible</li>
  <li>Phoenix-ready</li>
</ul>
<pre class="athl" style="...">
  <code class="language-elixir">
    <div class="line" data-line="1"><span style="...">
      MDEx.to_html!("# Hello")
    </span></div>
  </code>
</pre>

## Blazingly Fast

Light on memory. Heavy on throughput.

>> MDEx 0 ops/s
[x] fastest
Alternatives 0 ops/s 31x slower
average of Elixir markdown parsers
* Benchmarked on Apple M1 Pro [benchmark.exs]
3,506x
less memory than alternatives
0.00184 MB vs 6.45 MB

## Features

+ + + +

{*} Phoenix HEEx Integration

docs →

Native rendering to Phoenix.LiveView.Rendered for LiveView integration.

~MD[# {@title}]HEEX
+ + + +

[#] Syntax Highlighting

docs →

100+ themes and 70+ languages powered by Tree-sitter and Neovim. Code blocks look beautiful out of the box.

>> autumnus.dev
+ + + +

</> Document Manipulation

docs →

Full AST with Enumerable, Collectable, and Access protocols. Parse, traverse, and transform.

MDEx.Document
+ + + +

[+] Plugin System

docs →

Extend functionality with custom plugins. Process documents at any stage of the pipeline.

GFM, Mermaid, KaTeX
+ + + +

>>> AI Streaming Support

docs →

Process incomplete markdown fragments progressively. Perfect for ChatGPT-style interfaces.

streaming: true
+ + + +

<-> Multiple Output Formats

docs →

Output to HTML, HEEx, JSON, XML, Quill Delta, and Markdown. One parser, many outputs.

to_{html,json,xml,delta,markdown}
+ + + +

[!] Safety & Sanitization

docs →

Built-in XSS protection with configurable sanitization. Safely render untrusted markdown content.

MDEx.Document.default_sanitize_options()
+ + + +

``` Code Block Decorators

docs →

Override themes, highlight lines, and add CSS classes to code blocks with inline attributes.

```js theme=nord highlight_lines="2-3"
+ + + +

:) Emoji Built-in

docs →

Shortcode support for emoji conversion. Write :rocket: and get the actual 🚀 emoji.

shortcodes: true

## Phoenix LiveView Ready

Write markdown with HEEx components. Render directly to LiveView.

// page_live.ex [-][o][x]
def render(assigns) do
  ~MD"""
  # Welcome, {@user.name}!

  <.button phx-click="upgrade">
    Upgrade to Pro
  </.button>

  Your plan: **{@plan}**
  """HEEX
end

Welcome, John!

Your plan: Free

## Built for AI Applications

Stream incomplete markdown fragments as they arrive. Perfect for ChatGPT-style interfaces.

[*] AI Assistant [-][o][x]

>> Write a poem about Elixir

_
// How it works
MDEx.new(streaming: true)
|> MDEx.Document.put_markdown("**The Rust")
|> MDEx.to_html!()
# => "<p><strong>The Rust</strong></p>"
Feature MDEx Earmark md cmark
Active [x] [x] [x] [ ]
Pure Elixir [ ] [x] [x] [ ]
Extensible [x] [x] [x] [ ]
Syntax Highlighting [x] [ ] [ ] [ ]
Code Block Decorators [x] [ ] [ ] [ ]
Streaming (fragments) [x] [ ] [ ] [ ]
Phoenix HEEx components [x] [ ] [ ] [ ]
AST [x] [x] [x] [ ]
AST to Markdown [x] [~]2 [ ] [ ]
To HTML [x] [x] [x] [x]
To JSON [x] [ ] [ ] [ ]
To XML [x] [ ] [ ] [x]
To Manpage [ ] [ ] [ ] [x]
To LaTeX [ ] [ ] [ ] [x]
To Quill Delta [x] [ ] [ ] [ ]
Emoji [x] [ ] [ ] [ ]
GFM3 [x] [x] [ ] [ ]
GLFM4 [x] [ ] [ ] [ ]
Discord5 [~]1 [ ] [ ] [ ]

1 Partial support

2 Possible with earmark_reversal

3 GitHub Flavored Markdown

4 GitLab Flavored Markdown

5 Discord Flavored Markdown

# Ready?

Get started with MDEx in under a minute.

$ mix igniter.install mdex