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:
21
shared/naturalcrit/markdown.js
Normal file
21
shared/naturalcrit/markdown.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user