I am trying to write a Markdown to HTML converter in regex (+ some Lua) for something I'm working on.
For the most part, it works (simple find & replaces like emphasis, headlines, etc.)
But more advanced syntax like links with "detached" destinations are starting to worry me a little.
Maybe I'll just make a subset and only support that, who knows.
@admicos Why not write a parser?
@cadadr I've never written a proper parser before, so I don't really know how I would do it. And even with that, it would require me to choose one of these:
- Use a pure Lua parser library
- Pass a Rust parser library through into the embedded Lua VM
- Make my own parser library
Also, with regexes, I don't need any extra dependencies (I use regexes elsewhere) and I can optimize a little bit more (caching compiled regexes)
Though, I'll probably look into that as well. But maybe tomorrow.
Shouldn't be that hard to just write a... IIRC they were called recursive descent parser? They are rather easy to write manually, only using the IO facilities of the language.
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!