leandrocp

leandrocp

MDEx - Fast and Extensible Markdown

MDEx is a fast and extensible Markdown parser and formatter.

Fast

Leverage Rust to parse, manipulate and render documents using:

Extensible

A Req-like API to manipulate documents in a pipeline with support for plugins, for eg mdex_mermaid

Features

More at GitHub - leandrocp/mdex: Markdown for Elixir. Fast, Extensible, Phoenix-native. AI-ready. Built on top of comrak, ammonia, and lumis. · GitHub

Most Liked

leandrocp

leandrocp

MDEx v0.9 is now available with some new cool features!

Delta format

Thanks to @Jskalc we can now convert Markdown to Delta:

Streaming

Initial (experimental) support to put incomplete fragments of Markdown into the document. Useful for AI/LLM tools:

You can see a demo (video) at Leandro Pereira on X: "Here's a short demo of Markdown streaming in MDEx 👀 Note it's still experimental and disabled by default. https://t.co/uEdEEalbb8" / X

Inspect Document as a tree

To help visualize the nodes in a document:

It can be disabled if you prefer the regular struct inspect.

Unified Document API

Removed the MDEx.Pipe module in favor of unifying all operations in the MDEx.Document. Note this is a breaking change:

I’ll be working on Support Phoenix tags? · Issue #571 · kivikakk/comrak · GitHub so we can (hopefully) get Elixir and Phoenix components rendering inside Markdown. Enjoy!

leandrocp

leandrocp

MDEx v0.7.0 is out with a new ~MD sigils supporting assigns and Elixir expressions:

import MDEx.Sigil

assigns = %{lang: "elixir", sample: "spawn(fn -> send(current, {self(), 1 + 2}) end)"}

~MD"""
## Lang: <%= String.capitalize(@lang) %>

```elixir
<%= @sample %>
```
"""

Outputs:

%MDEx.Document{
  nodes: [
    %MDEx.Heading{nodes: [%MDEx.Text{literal: "Lang: Elixir"}], level: 2, setext: false},
    %MDEx.CodeBlock{
      nodes: [],
      fenced: true,
      fence_char: "`",
      fence_length: 3,
      fence_offset: 0,
      info: "elixir",
      literal: "spawn(fn -> send(current, {self(), 1 + 2}) end)\n"
    }
  ]
}

Or using the HTML modifier:

"<h2>Lang: Elixir</h2>\n<pre class=\"athl\" style=\"color: #abb2bf; background-color: #282c34;\"><code class=\"language-elixir\" translate=\"no\" tabindex=\"0\"><span class=\"line\" data-line=\"1\"><span style=\"color: #61afef;\">spawn</span><span style=\"color: #848b98;\">(</span><span style=\"color: #c678dd;\">fn</span> <span style=\"color: #abb2bf;\">-&gt;</span> <span style=\"color: #61afef;\">send</span><span style=\"color: #848b98;\">(</span><span style=\"color: #abb2bf;\">current</span><span style=\"color: #848b98;\">,</span> <span style=\"color: #848b98;\">&lbrace;</span><span style=\"color: #61afef;\">self</span><span style=\"color: #848b98;\">(</span><span style=\"color: #848b98;\">)</span><span style=\"color: #848b98;\">,</span> <span style=\"color: #d19a66;\">1</span> <span style=\"color: #abb2bf;\">+</span> <span style=\"color: #d19a66;\">2</span><span style=\"color: #848b98;\">&rbrace;</span><span style=\"color: #848b98;\">)</span> <span style=\"color: #c678dd;\">end</span><span style=\"color: #848b98;\">)</span>\n</span></code></pre>"

That’s one step into the direction of supporting Markdown in LiveViews with components.

leandrocp

leandrocp

MDEx v0.11 is out with 2 new cool features:

  1. Initial support for Phoenix Components

Now you can render Phoenix Components inside Markdow, either inside a LiveView or just use the ~MD[...]HEEX sigil. Example:

def render(assigns) do
  ~MD"""
  Hello from MDEx :wave:

  Today is _{Calendar.strftime(DateTime.utc_now(), "%B %d, %Y")}_

  <ReqEmbed.embed url={@video_url} class="aspect-video rounded-xl my-6" />

  Built with:
  - <.link href="https://crates.io/crates/comrak">comrak</.link>
  - <.link href="https://hex.pm/packages/mdex">MDEx</.link>
  """HEEX
end

More info at Phoenix LiveView HEEx — MDEx v0.13.2

  1. Syntax Highlighter with Light/Dark themes

The syntax highlighting engine now supports dual/multi themes so you can have automatic light/dark themes:

options = [
  syntax_highlight: [
    formatter: {
      :html_multi_themes,
      themes: [light: "github_light", dark: "github_dark"],
      default_theme: "light-dark()"
    }
  ]
]

Full example at Lumis light/dark theme — MDEx v0.13.2


I’m also opening a sponsorship program if you want to support MDEx in that way please see GitHub - leandrocp/mdex: Markdown for Elixir. Fast, Extensible, Phoenix-native. AI-ready. Built on top of comrak, ammonia, and lumis. · GitHub

Where Next?

Popular in Announcing Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
maltoe
Hello! Came here to announce ChromicPDF, a pet project PDF generator I’ve been working on for the past few months. Why another PDF gener...
New
riverrun
I’ve just released version 3 of Comeonin, a password hashing library. The following small changes have been made: changes to the NIF c...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. The distributed characteristics of Elixir and the low memory footprint...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
zoltanszogyenyi
Hey everyone :waving_hand: Excited to join this forum - I am one of the founders and current project maintainers of a popular and open-s...
New
tmbb
I’ve decided to create this topic to discuss optimization possibilities for something like Phoenix LiveView. I’ve created this topic unde...
144 10187 141
New
kevinlang
Hey all, We have made an Ecto3 Adapter for SQLite3, ecto_sqlite3! We have successfully on-boarded the full suite of integration tests (...
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 10858 107
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New

We're in Beta

About us Mission Statement