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:
@@ -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++;
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user