If you're interested in this, you should also know about Showdown.js, a library that converts markdown into HTML client-side: https://github.com/coreyti/showdown
For an example use, view the source of http://dergachev.github.com/pin-screenshot-bookmarklet