You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
600 B
30 lines
600 B
2 years ago
|
'use strict';
|
||
|
|
||
|
const { detachNodeFromParent } = require('../lib/xast.js');
|
||
|
|
||
|
exports.name = 'removeComments';
|
||
|
exports.description = 'removes comments';
|
||
|
|
||
|
/**
|
||
|
* Remove comments.
|
||
|
*
|
||
|
* @example
|
||
|
* <!-- Generator: Adobe Illustrator 15.0.0, SVG Export
|
||
|
* Plug-In . SVG Version: 6.00 Build 0) -->
|
||
|
*
|
||
|
* @author Kir Belevich
|
||
|
*
|
||
|
* @type {import('./plugins-types').Plugin<'removeComments'>}
|
||
|
*/
|
||
|
exports.fn = () => {
|
||
|
return {
|
||
|
comment: {
|
||
|
enter: (node, parentNode) => {
|
||
|
if (node.value.charAt(0) !== '!') {
|
||
|
detachNodeFromParent(node, parentNode);
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
};
|