realms-wiki/realms/static/js/main.js

40 lines
999 B
JavaScript
Raw Normal View History

// Init highlight JS
hljs.initHighlightingOnLoad();
// Markdown Renderer
MDR = {
doc: null,
callback: WMD.convert,
2014-02-07 05:40:58 +02:00
sanitize: true, // Override
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;
});
}
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;
}
}
};