/* global Showdown, Handlebars, html_sanitize*/ import cajaSanitizers from 'ghost/utils/caja-sanitizers'; var showdown = new Showdown.converter({extensions: ['ghostimagepreview', 'ghostgfm']}); var formatMarkdown = Ember.Handlebars.makeBoundHelper(function (markdown) { var escapedhtml = ''; // convert markdown to HTML escapedhtml = showdown.makeHtml(markdown || ''); // replace script and iFrame escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/script>/gi, '
Embedded JavaScript
'); escapedhtml = escapedhtml.replace(/)<[^<]*)*<\/iframe>/gi, '
Embedded iFrame
'); // sanitize html escapedhtml = html_sanitize(escapedhtml, cajaSanitizers.url, cajaSanitizers.id); return new Handlebars.SafeString(escapedhtml); }); export default formatMarkdown;