1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2026-01-06 20:09:14 +00:00

Adding newlines to div injection for blocks

This commit is contained in:
Scott Tolksdorf
2017-02-01 23:54:20 -05:00
parent 95c91b6ba8
commit 307dd2d9ba
2 changed files with 7 additions and 4 deletions

View File

@@ -29,17 +29,17 @@ module.exports = {
const renderer = new Markdown.Renderer();
renderer.paragraph = function (text) {
const matches = text.match(blockReg);
if(!matches) return `<p>${text}</p>\n`;
if(!matches) return `\n<p>${text}</p>\n`;
let matchIndex = 0;
const res = _.reduce(text.split(blockReg), (r, text) => {
if(text) r.push(`<p>${text}</p>\n`);
if(text) r.push(`\n<p>${text}</p>\n`);
const block = matches[matchIndex];
if(block && _.startsWith(block, '{{')){
r.push(`<div class="${block.substring(2).split(',').join(' ')}">`);
r.push(`\n\n<div class="${block.substring(2).split(',').join(' ')}">`);
count++;
}
if(block == '}}' && count !== 0){
r.push('</div>');
r.push('</div>\n\n');
count--;
}
matchIndex++;

View File

@@ -88,6 +88,9 @@ describe('Brew Data', () => {
}).then((brew) => {
brew.should.have.property('title').equal('Actual Title');
});
});
it.skip('should work with "# title"', ()=>{
});
it('should use the first header found if no title provided', () => {
return BrewData.create({