diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 2cc5e3ad0..71c267108 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -395,7 +395,9 @@ const definitionListsSingleLine = { .map((emoji)=>firstLine = firstLine.replace(emoji.raw, 'x'.repeat(emoji.raw.length))); const newMatch = /^([^\n]*?)::([^\n]*)(?:\n|$)/ym.exec(firstLine); - if(newMatch) { + if((newMatch) && ((newMatch[2].length > 0) && newMatch[2][0] != ':')) { + // Test the length to handle two : paragraph breaks exception + // Test the first position on the dictionary term to handle three + paragraph breaks exception definitions.push({ dt : this.lexer.inlineTokens(originalLine.slice(0, newMatch[1].length).trim()), dd : this.lexer.inlineTokens(originalLine.slice(newMatch[1].length + 2).trim()) @@ -856,8 +858,7 @@ module.exports = { varsQueue = []; //Could move into MarkedVariables() globalPageNumber = pageNumber; - rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n
\n`) - .replace(/^(:+)$/gm, (match)=>`${`:\n\n`.repeat(match.length)}\n`); + rawBrewText = rawBrewText.replace(/^\\column$/gm, `\n
\n`); const opts = Marked.defaults; rawBrewText = opts.hooks.preprocess(rawBrewText); diff --git a/tests/markdown/hardbreaks.test.js b/tests/markdown/hardbreaks.test.js index b27c6859c..4728e7674 100644 --- a/tests/markdown/hardbreaks.test.js +++ b/tests/markdown/hardbreaks.test.js @@ -12,12 +12,19 @@ describe('Hard Breaks', ()=>{ test('Double Break', function() { const source = '::\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
\n
'); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
'); }); test('Triple Break', function() { const source = ':::\n\n'; const rendered = Markdown.render(source).trim(); - expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
\n
\n
'); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
'); }); + + test('Ignored inside a code block', function() { + const source = '```\n\n:\n\n```\n'; + const rendered = Markdown.render(source).trim(); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe('
\n:\n
'); + }); + });