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