mdex
mdex copied to clipboard
support alerts
Hey @tcoopman that will be possible soon trough AST manipulation, I have a branch with most of the work already.
Hey @tcoopman I just opened this pull request that allows AST manipulation like I mentioned before. You can find an example to render blockquotes as alerts as described on the github doc and it looks like this:
The functions we have at this moment are pretty low-level but in the upcoming versions we'll have a high level API to manipulate the AST and to attach plugins, either way now it's possible to render alerts.
Please give it a try on that branch and let me know if you find issues.
https://github.com/leandrocp/mdex/pull/58 merged so I'm closing this one now. Eventually we'll have a plugin system (probably based on Req) so it will be much easier to share steps to manipulate the AST, but in the mean time https://github.com/leandrocp/mdex/blob/main/examples/alerts.exs is the way to go. Thanks for the suggestion to support alerts!
This works fine. I only happened to try this out just at the time you changed the syntax of some thing, so I was confused for a bit :smile:
Hmm, I do still have a question.
How would I use this if I want to add a link in the alert?
I think I know how to update the pattern match, but have no clue on how to handle the ast. Ideally I should be able to first convert the ast to rendered html and insert that html into the template?
Hey @tcoopman I just updated the example to allow rendering markdown and html in the alert content. Manipulating the AST is not always super fun but eventually we'll have a high-level API to make it easier.
changed the syntax of some thing
In main now the attrs are represented as maps instead of list of tuples, so keep that in mind. I'll release that change soon.