0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-19 03:22:45 +00:00

Removed dep on marked, added in a definition list for list types

This commit is contained in:
Scott Tolksdorf
2017-06-04 12:39:42 -04:00
parent c28647726a
commit 7e7428504e
5 changed files with 1336 additions and 58 deletions

View File

@@ -1,5 +1,6 @@
const _ = require('lodash');
const Markdown = require('marked');
//const Markdown = require('marked');
const Markdown = require('./marked.lib.js');
const renderer = new Markdown.Renderer();
@@ -25,19 +26,27 @@ renderer.paragraph = function(text){
}, []).join('\n');
return res;
};
renderer.image = function(href, title, text){
return `<img src="${href}" class="${text.split(',').join(' ')}"></img>`;
};
renderer.list = function(list, isOrdered, isDef){
if(isDef) return `<ul class='def'>${list}</ul>`;
if(isOrdered) return `<ol>${list}</ol>`;
return `<ul>${list}</ul>`;
}
module.exports = {
marked : Markdown,
render : (rawBrewText)=>{
blockCount = 0;
rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}')
rawBrewText = rawBrewText.replace(/\\column/g, '{{columnSplit }}');
let html = Markdown(rawBrewText,{renderer : renderer, sanitize: true});
let html = Markdown(rawBrewText, {renderer : renderer, sanitize: true});
//Close all hanging block tags
html += _.times(blockCount, ()=>{return '</div>'}).join('\n');
return html;