Pathtoglory.quest

I'm on a quest to learn and understand things.

Markdown parsing vol.2

Posted on 8 Apr 2026, 21:37 - Updated on 9 Apr 2026, 21:13

Understanding my issue

I had a lot of Markdown parsing in the past days. A bit more than what I thought at first.

My first implementation of escaping characters was sloppy and didn't worked in each situation. I realized I have to rely on the character before a special character to be sure that it's not escaped. For the italic for example, at first I did it like this:


/([^\\|\*]|^)?\*(?[^\*|\n|\\]+)\*(?[^\*]{0,1})

I checked that there wasn't a "" character or a * before the first *. I didn't worked if there was a space before the *, and I also lost a character in my parsing. The detected character would be removed. In this Hello *world* would be parsed as Helloworld. Not ideal.

To fix that, I capture the first character, and add it later in the parsing.


(?^|[^\\|\*]{1})

I capture it if it's the beginning of the line, not a character or not a * character. I need to capture 1 character otherwise the regex get lazy and not capture the escaping character. I'll then put the captured character before the capturing group.

Generating tests

To be sure of my implementation, I created some news tests. But I got lazy. So I used the help of Codex for it. I generated all the testing values for each case, I wrote the test for one element and asked him to generate the tests for the other elements using the same shape of my written test.

I'm doing all those projects by myself to train and experiment, but writing repetitive tests is definitely a task I would give to AI with proper guidance to generate the tests.

What's next?

I'm working on a design for my website. I'm tired of it looking like a hideous text thing. I'll start with a design system and global styles. I'll do specifics later.

Ciao

PS: Now it looks exactly as it should ;-)