Strip Markdown from document

I’m using CM6 with Markdown syntax highlighting. For parts of my application, e.g., to render summaries, I need all Markdown tokens stripped from the content.

Currently, I’m using an external library for that. But since CM comes with a Markdown parser, I’m wondering if I could use that to strip, as well.

You probably could (see syntaxTree and Tree.iterate), but it’d require a bunch of custom code, since Markdown rendering isn’t something the editor itself does.