Parsing Markdown by alternating on odd and even
I worked through boot.dev’s Build a Static Site Generator, a guided project that has you write the thing that turns **bold** into <b>bold</b>. The architecture is the course’s: a TextNode type for chunks of formatted text, an HTMLNode tree to render, and separate passes for block-level and inline parsing.
This is a write-up of the piece I found most elegant, not something I invented. The inline parser is a genuinely neat idea, and it took me a while to see why it works, so it seemed worth explaining properly.