I want to sneak Roc into the company I work for. Starting with some small scripts for non-critical tasks.
I want to start with a Markdown manipulation script that reads a Markdown file and replaces a section of it with some new content.
Naturally the question came up, what is the state of Markdown in Roc? Do we have any packages that I'm not aware of? I searched the Zulip history and found some attempts by @Luke Boswell , but nothing concrete. I would be grateful if someone could point out something that would be valuable for someone who is about to write a Markdown parser (to do something that is already being done by a regex). :D
I was thinking of parsing the markdown into an AST to manipulate it and then rendering it back to markdown.
that's awesome! :smiley:
I don't know if anyone's written a full markdown parser in pure Roc, but there are several in Elm - e.g. this, this, or the one I think is probably the most battle-tested - and the latter two are written using elm/parser, which someone has ported to Roc (although I'm not sure how battle-tested that port is!)
Thanks for sharing!
Would lukewilliamboswell/roc-parser be a good fit to use instead of ported elm/parser? :thinking:
I don't know much about parsers, so I'm wondering if there's something that disqualifies it from the start.
oh I just suggested that because it might make porting easier
I'd expect either one to work fine!
How much functionality do you need with markdown? Could you do without embedded html? If so I could probably put a Markdown module together pretty quickly, or help you with that using roc-parser.
There has been a start made on xml parsing, but it still needs more love before it could parse html.
Or at least just parse the html into a single HmtlNode or something and leave it untouched.
Thank you for your help. Using html would be cool, but I think your single HtmlNode approach would work for now. :thumbs_up:
I would probably start by looking at Dillon's markdown implementation in elm and try to go from there.
I'll then share my first steps with you, and if you have time to take a look, I'd love to hear your feedback :)
Last updated: Jul 06 2025 at 12:14 UTC