Urara-Blog/node_modules/.pnpm-store/v3/files/a2/5b7c0a09b1fc0228045bd87befa7cf46612f826be17aab3321d0e547b9441f58976714c21a5ad448346dbadacdde2f48eb03772d39a8b169b6f1a449ba1e9e
2022-08-14 01:14:53 +08:00

33 lines
775 B
Text

'use strict';
const { detachNodeFromParent } = require('../lib/xast.js');
exports.name = 'removeRasterImages';
exports.type = 'visitor';
exports.active = false;
exports.description = 'removes raster images (disabled by default)';
/**
* Remove raster images references in <image>.
*
* @see https://bugs.webkit.org/show_bug.cgi?id=63548
*
* @author Kir Belevich
*
* @type {import('../lib/types').Plugin<void>}
*/
exports.fn = () => {
return {
element: {
enter: (node, parentNode) => {
if (
node.name === 'image' &&
node.attributes['xlink:href'] != null &&
/(\.|image\/)(jpg|png|gif)/.test(node.attributes['xlink:href'])
) {
detachNodeFromParent(node, parentNode);
}
},
},
};
};