How to parse Markdown?


#1

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?


#2

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


#3

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


#4

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


#5

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


#6

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


#7

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