2013-10-10 18:38:30 +03:00
|
|
|
// Init highlight JS
|
|
|
|
hljs.initHighlightingOnLoad();
|
|
|
|
|
|
|
|
// Markdown Renderer
|
|
|
|
MDR = {
|
|
|
|
doc: null,
|
|
|
|
callback: WMD.convert,
|
2014-02-07 05:40:58 +02:00
|
|
|
sanitize: true, // Override
|
2013-10-10 18:38:30 +03:00
|
|
|
convert: function(md, sanitize){
|
|
|
|
if (this.sanitize !== null) {
|
|
|
|
sanitize = this.sanitize;
|
|
|
|
}
|
|
|
|
this.doc = this.callback(md);
|
|
|
|
var html = this.doc.html;
|
|
|
|
if (sanitize) {
|
|
|
|
// Causes some problems with inline styles
|
2014-02-07 05:40:58 +02:00
|
|
|
html = html_sanitize(html, function(url) {
|
|
|
|
if(/^https?:\/\//.test(url)) {
|
|
|
|
return url
|
|
|
|
}
|
|
|
|
}, function(id){
|
|
|
|
return id;
|
|
|
|
});
|
2013-10-10 18:38:30 +03:00
|
|
|
}
|
|
|
|
html = this.hook(html);
|
|
|
|
return html;
|
|
|
|
},
|
|
|
|
hook: function(html) {
|
|
|
|
if (!this.doc.metadata) {
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
var template = Handlebars.compile(html);
|
|
|
|
return template(this.doc.metadata);
|
|
|
|
} catch(e) {
|
|
|
|
return html;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|