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):
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.