This is a cajoled version of Attack Lab's Showdown (http://attacklab.net/showdown/), a JavaScript Markdown (http://daringfireball.net/projects/markdown/syntax) renderer. The only changes to their original source were removing the PHP tags in a comment and removing the dependence on a single use of RegExp.$1.
Note that the rendering of the Markdown has been sanitized by Caja, so links are merely highlighted and images are not loaded, even though the original code would have produced these.