Skip to content

Commit

Permalink
Merge pull request #1 from florianeckerstorfer/only-jpg-png
Browse files Browse the repository at this point in the history
Only process .png, .jpg and .jpeg files
  • Loading branch information
florianeckerstorfer committed Oct 9, 2020
2 parents 79f21f9 + e911720 commit 487d648
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions __tests__/index.spec.js
Expand Up @@ -82,4 +82,17 @@ describe('remark-responsive-images', () => {
done();
});
});

it('should not modify node if image gif', (done) => {
const input = '![My image](foo.gif)';

processor.process(input, (_, file) => {
const result = cheerio.load(String(file));
expect(result('figure').length).toBe(0);
expect(result('img').length).toBe(1);
expect(result('img').attr('src')).toBe('foo.gif');
expect(result('img').attr('alt')).toBe('My image');
done();
});
});
});
4 changes: 3 additions & 1 deletion src/index.js
Expand Up @@ -16,7 +16,9 @@ function findMarkdownImageNodes(markdownAST) {
(node, ancestors) => {
const inLink = ancestors.some(findParentLinks);

markdownImageNodes.push({ node, inLink });
if (node.url.match(/\.(png|jpe?g)$/)) {
markdownImageNodes.push({ node, inLink });
}
}
);

Expand Down

0 comments on commit 487d648

Please sign in to comment.