function getPlainTextBrief(entry, done) { var converter = new pagedown.getSanitizingConverter(), html = converter.makeHtml(entry.brief); jsdom.env({ html: '<foo>' + html + '</foo>', // empty and HTML tags throw for some obscure reason. scripts: [assets.jQuery.local], done: function(err,window){ if(err){ done(err); return; } var $ = window.$, plain = $(':root').text(); done(null,plain); } }); }
env.addFilter('toSafeHtml', function (markdown) { return (markdown) ? safeConverter.makeHtml(markdown) : markdown; });