0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 10:02:43 +00:00

Created new wrapper for my markdown parser, added it to the print page

This commit is contained in:
Scott Tolksdorf
2016-06-07 09:50:50 -04:00
parent 8df4dc56b2
commit e38850f807
6 changed files with 30 additions and 19 deletions

View File

@@ -0,0 +1,21 @@
var _ = require('lodash');
var Markdown = require('marked');
var renderer = new Markdown.Renderer();
//Processes the markdown within an HTML block if it's just a class-wrapper
renderer.html = function (html) {
if(_.startsWith(_.trim(html), '<div class=') && _.endsWith(_.trim(html), '</div>')){
var openTag = html.substring(0, html.indexOf('>')+1);
html = html.substring(html.indexOf('>')+1);
html = html.substring(0, html.lastIndexOf('</div>'));
return `${openTag} ${Markdown(html)} </div>`;
}
return html;
};
module.exports = {
render : (rawText)=>{
return Markdown(rawText, {renderer : renderer})
},
marked : Markdown
};