Experiment: Highlighting Markdown via source-mapping


Hey guys, we’re currently playing with advanced source-mapping on a new parser, and did a little experiment.

Edit: changed link, added tooltip to show tree path on hover.

This is what the CommonMark spec looks like, when highlighted with a CommonMark parser. Feel free to inspect away and change the styles, you can achieve crazy effects…

Feedback is welcome! I know highlighting isn’t what Markdown parsers were made for, but I’d say it’s still a pretty good fit, no?


CommonMark.NET also has the ability and it is used by editors to do syntax highlighting (since the other more common option is to use simple regular expressions that sort-of work). Here is the worst case I know for markdown source mapping (and decided not to handle for now):

 >  >bar*


Oooh! Thanks, I was having trouble finding CommonMark parsers with that feature.

What’s special about it? This is how it maps here:


It’s special because the emphasis maps to two separate blocks (and the inner blockquote as well). In CommonMark.NET I track only a single block for each inline/block element (for memory and performance reasons) and thus it cannot represent the source mapping correctly for this case.


This looks really good. I personally think the source-mapping is important. I hope you’re still working on it…


Thanks! We’ll announce the parser in Implementation when we’re done.


Do you have any news on this, @jmendeth?