ivo Welch ivo Welch - 1 year ago 164
Markdown Question

markdown in browser via showdown

I am wondering whether I can create my new website in markdown instead of in html. showdown.js at https://github.com/coreyti/showdown seems to be a plugin that can do this.

I am thinking something like

<script type="text/javascript" src="/js/showdown-starter.js" />
<link rel="StyleSheet" href="mystylesheet.css" type="text/css" />


# Welcome

Hello. Welcome to my website.


Presumably, the client javascript would transform this into html that the browser likes.

Answer Source

Sure you can.

Here's an example how:

<div id="content">
# Welcome

Hello.  Welcome to my **website**.
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.4.0/showdown.min.js"></script>
var conv = new showdown.Converter();
var txt = document.getElementById('content').innerHTML;
document.getElementById('content').innerHTML = conv.makeHtml(txt);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download