diff --git a/shared/naturalcrit/markdown.js b/shared/naturalcrit/markdown.js index 6dfc64d25..5e81be3f0 100644 --- a/shared/naturalcrit/markdown.js +++ b/shared/naturalcrit/markdown.js @@ -372,9 +372,9 @@ const superSubScripts = { const justifiedParagraphClasses = []; -justifiedParagraphClasses[2] = 'mdParagraphJiustifyLeft'; -justifiedParagraphClasses[4] = 'mdParagraphJiustifyRight'; -justifiedParagraphClasses[6] = 'mdParagraphJiustifyCenter'; +justifiedParagraphClasses[2] = 'mdParagraphJustifyLeft'; +justifiedParagraphClasses[4] = 'mdParagraphJustifyRight'; +justifiedParagraphClasses[6] = 'mdParagraphJustifyCenter'; const justifiedParagraphs = { name : 'justifiedParagraphs', @@ -384,7 +384,7 @@ const justifiedParagraphs = { }, // Hint to Marked.js to stop and check for a match tokenizer(src, tokens) { - const regex = /^((:- ).*)|((-: ).*)|((:-:) .*)(?:\n|$)/ym; + const regex = /^((:- ).*)|((-: ).*)|((:-: ).*)(?:\n|$)/ym; const match = regex.exec(src); if(match?.length) { let whichJustify; diff --git a/tests/markdown/justification.test.js b/tests/markdown/justification.test.js new file mode 100644 index 000000000..e3639eb81 --- /dev/null +++ b/tests/markdown/justification.test.js @@ -0,0 +1,27 @@ +/* eslint-disable max-lines */ + +import Markdown from 'naturalcrit/markdown.js'; + +describe('Justification', ()=>{ + test('Left Justify', function() { + const source = ':- Hello'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Hello

`); + }); + test('Right Justify', function() { + const source = '-: Hello'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Hello

`); + }); + test('Center Justify', function() { + const source = ':-: Hello'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`

Hello

`); + }); + + test('Ignored inside a code block', function() { + const source = '```\n\n:- Hello\n\n```\n'; + const rendered = Markdown.render(source); + expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`
\n:- Hello\n
\n`); + }); +});