cvkmohan

cvkmohan

Recently came across this great library leandrocp/mdex: A fast 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter for Elixir. by our @leandrocp
I wanted to discuss about the library and realized there is no forum post introducing the library.
So, creating this thread. In the Phoenix LiveView, I just called Mdx.to_html() and voila - live preview is available.
Please explore.

Showing Posts 1 to 10

mayel

mayel

Use it and love it :+1:

leandrocp

leandrocp

The reason I’m not talking much about that library yet is because I’m still working on the API to manipulate AST and consequently allow extending it, think of how Req works but for Markdown. I’m glad it works for you!

leandrocp

leandrocp

Yep it’s in the pipeline. As soon as I solve AST manipulation it will be possible to format to HTML, HEEX, and even call arbitrary Elixir code. For context, https://mdxjs.com is a big inspiration for this library.

dkuku

dkuku

I’m waiting for a elixir formatter plugin that will format my docs. I always have to redeploy to hex due to broken formatting :slight_smile:

cvkmohan

cvkmohan OP

BTW @leandrocp, how do we extend the library? am-kantox/md: Stream-aware markdown parser with custom syntax setting (github.com) and mudasobwa/markright: A customizable markdown parser in Elixir: pure pattern matching. (github.com) look two interesting projects.
One question I have is - if we want to support hashtags (#) or mentions (@) - is it better to go to Javascript libraries like Tiptap, Quill etc. or is there anything we can try using your sort of libraries?
Sorry - if the question is very naive.

leandrocp

leandrocp

@cvkmohan I’ve considered md and others but none of them did the job for my needs. I got excited with md and its extension capabilities but quoting its readme “If one needs to perfectly parse the common markdown, Md is probably not the correct choice” so that was a major blocker.

Regarding extending MDEx that’s what I have in mind: RFC - Extension API · Issue #37 · leandrocp/mdex · GitHub - the first part which is parsing the document (AST) and formatting to HTML is half way done (Elixir and Rust), so it’s in progress.

if we want to support hashtags (#) or mentions (@)

I’m not sure I follow your question, both Tiptap and Quill are rich text editors while MDEx is a Markdown parser/formatter. With MDEx you’ll be able to manipulate the document after it was written, either with Tiptap or any other editor. So let’s say for example you want to add a link to every tag in your document, ie: transform #tag_a to [#tag_a](link) you’ll be able to traverse the AST and transform a text node into a link node. See RFC - Extension API · Issue #37 · leandrocp/mdex · GitHub for an example.

Does it make sense?

leandrocp

leandrocp

Hi @dkuku what kind of broken formatting you get publishing to hex? I’ve had an issue or two with earmark but in overall it works fine.

The “formatter” in “A fast 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter.” means converting markdown to HTML and potentially other formats, but I’m assuming you’re talking about a mix format plugin, right? Can you elaborate a bit more?

cvkmohan

cvkmohan OP

Thanks @leandrocp. Yes, you answered even my imaginary question. :slight_smile:

Yes, I am looking at something like transforming text node into a link node. By using it - I intend to avoid using a Rich Text Editor. MDEx looks sufficiently fast - and - a split text box with source on the left - and - parsed results on the right should make Rich Text Editor unnecessary. And once you bring slab/delta-elixir: Simple yet expressive format to describe contents and changes :card_file_box: (github.com) into the mix, may be collaborative editing is possible entirely in the Elixir world!
Thanks for the answer. Will be looking forward to future releases.

mayel

mayel

If you’re looking for a way to parse and transform mentions, hashtags, and links: GitHub - bonfire-networks/linkify: Linkify is a basic package for turning website names into links. · GitHub

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 92995 915
New
caslu
I want to open this thread for you all to discuss and help those who really like Ash but are still hesitant to use it in a real project. ...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
GES233
I’m posting this in response to Jose’s recent tweet (Cr. link) : People are sleeping on Elixir for a coding harness: Hot-code swappi...
New
_mfierro
Hello, I wrote Stop My Hand, a Scattergories-like web application using Phoenix/LiveView as my learning project for Elixir (after readin...
New
marciol
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
durvia
Anyone running long-lived stateful processes on BEAM? We’re building an AI agent runtime and would love to compare notes. We’re a small ...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews