mirror of
https://github.com/svg/svgo.git
synced 2026-01-27 07:02:06 +03:00
30 lines
600 B
JavaScript
30 lines
600 B
JavaScript
'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);
|
|
}
|
|
},
|
|
},
|
|
};
|
|
};
|