0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-29 19:52:43 +00:00

Add justification token testing

This commit is contained in:
David Bolack
2024-11-22 20:39:31 -06:00
parent 929469d0c0
commit 440ad516df
2 changed files with 31 additions and 4 deletions

View File

@@ -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;

View File

@@ -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(`<p class=\"mdParagraphJustifyLeft\">Hello</p>`);
});
test('Right Justify', function() {
const source = '-: Hello';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p class=\"mdParagraphJustifyRight\">Hello</p>`);
});
test('Center Justify', function() {
const source = ':-: Hello';
const rendered = Markdown.render(source);
expect(rendered, `Input:\n${source}`, { showPrefix: false }).toBe(`<p class=\"mdParagraphJustifyCenter\">Hello</p>`);
});
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(`<pre><code>\n:- Hello\n</code></pre>\n`);
});
});