mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-15 12:42:45 +00:00
Add justification token testing
This commit is contained in:
@@ -372,9 +372,9 @@ const superSubScripts = {
|
|||||||
|
|
||||||
|
|
||||||
const justifiedParagraphClasses = [];
|
const justifiedParagraphClasses = [];
|
||||||
justifiedParagraphClasses[2] = 'mdParagraphJiustifyLeft';
|
justifiedParagraphClasses[2] = 'mdParagraphJustifyLeft';
|
||||||
justifiedParagraphClasses[4] = 'mdParagraphJiustifyRight';
|
justifiedParagraphClasses[4] = 'mdParagraphJustifyRight';
|
||||||
justifiedParagraphClasses[6] = 'mdParagraphJiustifyCenter';
|
justifiedParagraphClasses[6] = 'mdParagraphJustifyCenter';
|
||||||
|
|
||||||
const justifiedParagraphs = {
|
const justifiedParagraphs = {
|
||||||
name : 'justifiedParagraphs',
|
name : 'justifiedParagraphs',
|
||||||
@@ -384,7 +384,7 @@ const justifiedParagraphs = {
|
|||||||
|
|
||||||
}, // Hint to Marked.js to stop and check for a match
|
}, // Hint to Marked.js to stop and check for a match
|
||||||
tokenizer(src, tokens) {
|
tokenizer(src, tokens) {
|
||||||
const regex = /^((:- ).*)|((-: ).*)|((:-:) .*)(?:\n|$)/ym;
|
const regex = /^((:- ).*)|((-: ).*)|((:-: ).*)(?:\n|$)/ym;
|
||||||
const match = regex.exec(src);
|
const match = regex.exec(src);
|
||||||
if(match?.length) {
|
if(match?.length) {
|
||||||
let whichJustify;
|
let whichJustify;
|
||||||
|
|||||||
27
tests/markdown/justification.test.js
Normal file
27
tests/markdown/justification.test.js
Normal 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`);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user