You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
684 B
19 lines
684 B
12 years ago
|
// From https://gist.github.com/1343518, modified to not load showdown
|
||
|
(function boom(){
|
||
|
|
||
|
[].forEach.call( document.querySelectorAll('[data-markdown]'), function fn(elem){
|
||
|
|
||
|
// strip leading whitespace so it isn't evaluated as code
|
||
|
var text = elem.innerHTML.replace(/\n\s*\n/g,'\n'),
|
||
|
// set indentation level so your markdown can be indented within your HTML
|
||
|
leadingws = text.match(/^\n?(\s*)/)[1].length,
|
||
|
regex = new RegExp('\\n?\\s{' + leadingws + '}','g'),
|
||
|
md = text.replace(regex,'\n'),
|
||
|
html = (new Showdown.converter()).makeHtml(md);
|
||
|
|
||
|
// here, have sum HTML
|
||
|
elem.innerHTML = html;
|
||
|
|
||
|
});
|
||
|
|
||
|
}());
|