Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
775 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | const { detachNodeFromParent } = require('../lib/xast.js');
|
---|
4 |
|
---|
5 | exports.name = 'removeRasterImages';
|
---|
6 | exports.type = 'visitor';
|
---|
7 | exports.active = false;
|
---|
8 | exports.description = 'removes raster images (disabled by default)';
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Remove raster images references in <image>.
|
---|
12 | *
|
---|
13 | * @see https://bugs.webkit.org/show_bug.cgi?id=63548
|
---|
14 | *
|
---|
15 | * @author Kir Belevich
|
---|
16 | *
|
---|
17 | * @type {import('../lib/types').Plugin<void>}
|
---|
18 | */
|
---|
19 | exports.fn = () => {
|
---|
20 | return {
|
---|
21 | element: {
|
---|
22 | enter: (node, parentNode) => {
|
---|
23 | if (
|
---|
24 | node.name === 'image' &&
|
---|
25 | node.attributes['xlink:href'] != null &&
|
---|
26 | /(\.|image\/)(jpg|png|gif)/.test(node.attributes['xlink:href'])
|
---|
27 | ) {
|
---|
28 | detachNodeFromParent(node, parentNode);
|
---|
29 | }
|
---|
30 | },
|
---|
31 | },
|
---|
32 | };
|
---|
33 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.