0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 13:02:45 +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(); const renderer = new Markdown.Renderer();
renderer.paragraph = function (text) { renderer.paragraph = function (text) {
const matches = text.match(blockReg); const matches = text.match(blockReg);
if(!matches) return `<p>${text}</p>\n`; if(!matches) return `\n<p>${text}</p>\n`;
let matchIndex = 0; let matchIndex = 0;
const res = _.reduce(text.split(blockReg), (r, text) => { 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]; const block = matches[matchIndex];
if(block && _.startsWith(block, '{{')){ 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++; count++;
} }
if(block == '}}' && count !== 0){ if(block == '}}' && count !== 0){
r.push('</div>'); r.push('</div>\n\n');
count--; count--;
} }
matchIndex++; matchIndex++;

View File

@@ -88,6 +88,9 @@ describe('Brew Data', () => {
}).then((brew) => { }).then((brew) => {
brew.should.have.property('title').equal('Actual Title'); 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', () => { it('should use the first header found if no title provided', () => {
return BrewData.create({ return BrewData.create({