mdex icon indicating copy to clipboard operation
mdex copied to clipboard

support alerts

Open tcoopman opened this issue 1 year ago • 1 comments
trafficstars

It would be really nice if you'd support alerts

tcoopman avatar May 24 '24 10:05 tcoopman

Hey @tcoopman that will be possible soon trough AST manipulation, I have a branch with most of the work already.

leandrocp avatar Jun 24 '24 13:06 leandrocp

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: alerts

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.

leandrocp avatar Aug 22 '24 17:08 leandrocp

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!

leandrocp avatar Aug 23 '24 17:08 leandrocp

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:

tcoopman avatar Oct 14 '24 14:10 tcoopman

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?

tcoopman avatar Oct 14 '24 15:10 tcoopman

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.

leandrocp avatar Oct 14 '24 16:10 leandrocp