markdown-it-imagination
Version:
Plugin for markdown-it image size support
39 lines (31 loc) • 982 B
JavaScript
const { strictEqual: same } = require('assert');
const md = require('markdown-it')({
html: true,
linkify: true,
typographer: true
});
md.use(require('.'));
same(
md.renderInline(``),
`<img src="foo.jpg" alt="foo" loading="lazy">`
);
same(
md.renderInline(``),
`<img src="foo.jpg" alt="foo" width="100" height="80" loading="lazy">`
);
same(
md.renderInline(``),
`<img src="foo.jpg" alt="foo" width="100" loading="lazy">`
);
same(
md.renderInline(``),
`<img src="foo.jpg" alt="foo" height="80" loading="lazy">`
);
same(
md.renderInline(``),
`<figure><img src="foo.jpg" alt="foo" loading="lazy"><figcaption>My caption</figcaption></figure>`
);
same(
md.renderInline(``),
`<figure><img src="foo.jpg" alt="foo" width="100" height="80" loading="lazy"><figcaption>Some caption</figcaption></figure>`
);