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