Fixing my Markdown parser
Posted on 7 Apr 2026, 15:16 - Updated on 8 Apr 2026, 21:12
Hey,
I finished my previous article with "Ciao". I wanted it to be in italic to be cool, but it ended up like a list item with an * at the end.
This came from my markdown parser. I built it myself, to work on my regex skills (I love regexes) and as a challenge to understand better parsing and converting text to HTML. It's a nice library that you can find here if you're curious. I guarantee that it's with 0 dependencies.
Coming back to Ciao. I write my articles in Markdown as it's easy to store, and I convert it to HTML using rb26 (my library) to finally serve it to you when you check my website. So, the last line was *Ciao* to make it italic. The bug came from my code. I assumed that if a line started with * it was a list item. Silly me.
I made a fix for it. I found out that if a line starts with * and has an odd number of * in the line, it's a list item. As I write those lines, I realize that there is a lot of potential mistakes and edge cases where it would be wrong. Like how should it parse the following:
* Hello, **I** really like using the * character
It's starting with an *, but it doesn't have an odd number of *. There is a bold element and them a single * element that needs to be displayed. I can easily know that the I is in bold, but then, aren't the text in between the * linked and should be in italic ?
Well, that's a challenge for another day.