Honestly I copied the Markdown previewer that steemit.com uses. The automatic linking for links and image links to images is something they added on top of markdown and isn't standard. Here's where most of the magic in their code happens:
https://github.com/steemit/condenser/blob/master/shared/HtmlReady.js
I actually wish that stuff wasn't in there, I think if someone wants to make something a link... they should make it a link.
Thanks