I see what you mean, but at the same time it worked okay on my "generate markdown toc" script after removing all comments.
I'm surprised that it did so well.
The initial paragraph is wrong though. It takes markdown headings as input, it doesn't generate markdown headings.
This confusion makes it a lot less trustworthy.