How to parse Markdown?

I’ve been trying to understand the Parser module, and hitting difficulties with the loop concept. In particular, I asked myself how I would implement a simple Markdown parser with * for bold and _ for italic only. They could appear multiple times in a string, could be nested legally or illegally.

I’ve implemented this using a non-Parser solution, but I figure using Parser would be simpler and more elegant. But I can’t get the concept of how to do this, even after reading several examples of Parser in action.

Can anyone point me towards a solution to this?

I would suggest having a look at the code in Matthew Griffith’s elm-markup: https://github.com/mdgriffith/elm-markup

2 Likes

There is also https://package.elm-lang.org/packages/terezka/yaml/latest/ which might be interesting for learning how to use elm/parser

1 Like

Thanks to both of you. Just what I was looking for.

I have made a complete example: https://ellie-app.com/4ppPxdKpLDta1 . I hope this also helps you!

2 Likes

Many thanks. That’s a great framework for me to build on.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.