Fix issue with images.

This commit is contained in:
Dorian 2019-07-16 00:06:53 -04:00
parent 05d9c9312e
commit faf7e8837a
2 changed files with 5 additions and 3 deletions

View File

@ -51,7 +51,7 @@ export const replacement = (match, p1, p2, p3) => {
const isImage = p1.trim() === '!'; const isImage = p1.trim() === '!';
if (isImage) { if (isImage) {
return `![${linkText}](${linkHref})`; return `<img src="${linkHref}" alt="${linkText}" />`;
} }
if (linkHref === '' || linkText === '') { if (linkHref === '' || linkText === '') {

View File

@ -43,14 +43,16 @@ describe('rookeries-links should', () => {
expect(testMarkdown.replace(markdownPattern, replacement)).to.eq(expectedOutput); expect(testMarkdown.replace(markdownPattern, replacement)).to.eq(expectedOutput);
}); });
it('when encountering an image it should leave it alone', () => { it('when encountering an image it should become an image.', () => {
const testMarkdown = "![image-alt-text](/image-url)"; const testMarkdown = "![image-alt-text](/image-url)";
const expectedOutput = "![image-alt-text](/image-url)"; const expectedOutput = "<img src=\"/image-url\" alt=\"image-alt-text\" />";
let pattern = new RegExp(markdownPattern); let pattern = new RegExp(markdownPattern);
expect(pattern.test(testMarkdown)).to.eq(true); expect(pattern.test(testMarkdown)).to.eq(true);
expect(testMarkdown.replace(markdownPattern, replacement)).to.eq(expectedOutput); expect(testMarkdown.replace(markdownPattern, replacement)).to.eq(expectedOutput);
}); });
// TODO: Fix issue of having two links close together with a test.
}); });
}); });