desirae.js/lib/render-core.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-01-23 09:52:41 +00:00
/*jshint -W054 */
;(function (exports) {
'use strict';
var PromiseA = exports.Promise || require('bluebird').Promise
;
function renderMd(contentstr/*, desi*/) {
var markitdown = (exports.markdownit || require('markdown-it'))({ html: true, linkify: true })
;
return PromiseA.resolve(
markitdown.render(contentstr)
//.replace('"', '"')
//.replace(''', "'")
//.replace('/', '/')
);
}
function renderNoop(contentstr/*, desi*/) {
// hmmm... that was easy
return PromiseA.resolve(contentstr);
}
function renderJade(contentstr, desi, options) {
options = options || {};
if (!('pretty' in options)) {
options.pretty = true;
}
var jade = (exports.jade || require('jade'))
, fn = jade.compile(contentstr, options)
, html = fn(desi)
;
return PromiseA.resolve(html);
}
exports.DesiraeRenderMarkdown = renderMd.DesiraeRenderMarkdown = renderMd;
exports.DesiraeRenderHtml = renderNoop.DesiraeRenderHtml = renderNoop;
exports.DesiraeRenderCss = renderNoop.DesiraeRenderCss = renderNoop;
exports.DesiraeRenderJs = renderNoop.DesiraeRenderJs = renderNoop;
exports.DesiraeRenderJade = renderJade.DesiraeRenderJade = renderJade;
}('undefined' !== typeof exports && exports || window));