What breaks when you hand-roll a Markdown renderer (and how I fixed it in one sitting)
Every developer eventually writes "a quick little Markdown parser." Mine started as 40 lines and turned into a lesson about every edge case I'd been taking for granted. Quillmark (https://github.com/contentclipsstudios-s
Every developer eventually writes "a quick little Markdown parser." Mine started as 40 lines and turned into a lesson about every edge case I'd been taking for granted. Quillmark (https://github.com/contentclipsstudios-svg/Quillmark) is the result: a single-file, zero-dependency CLI that turns a Markdown file into a finished, dark-mode-ready HTML page in one command.
Here's what broke along the way, and what fixed it.
1. Double-escaped entities.
My first version escaped HTML, then escaped it again on a later pass. & became & became &. The fix sounds obvious once you've been bitten: escape exactly once, at exactly one layer, and sanitize raw HTML input instead of trying to be clever about it. If your renderer ever shows & to users, this is why.
2. Nested lists via regex.
Regex-based list parsing works until someone writes a three-deep nested list, and then your <ul> tags come out unbalanced. The fix: track depth with an explicit stack. Push on indent, pop on dedent. It's the difference between a parser and a coincidence generator.
3. Front-matter everyone guesses at.
People expect title: in front-matter to set the page title. Supporting it took four lines. Not supporting it generated confused issues. Small affordances matter more than features.
4. "It works on my file" is not testing.
I added verify.js β an adversarial suite that throws pathological input at the renderer: nested quotes, raw HTML, unicode dashes, unbalanced markers. v1.1.0 exists because that suite found four real defects, including one where an unclosed code fence swallowed the rest of the document silently.
Why zero dependencies, on purpose.
Every dependency is a supply-chain decision you inherit. A docs tool that pulls 300 transitive packages to format text is a maintenance burden you inherit. Quillmark is one file you can read in one sitting, on any Node 18+ machine, with nothing to install.
One command:
node quillmark.js my-notes.md -o index.html --title "My Site"
Output is a single portable HTML file: GitHub Pages, Netlify, or a USB stick. Your content stays plain Markdown, versioned in git, yours.
The CLI is free and MIT: https://github.com/contentclipsstudios-svg/Quillmark
And if docs tooling is a chore you'd rather skip entirely, I set up Quillmark on your repo and deploy your docs site for you β done within 24h, $79, 30-day money-back guarantee. Full details on my Gumroad page (link on my profile).
What's the edge case that bit your hand-rolled renderer? I'm collecting war stories β the worst ones usually end up in verify.js.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.