1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-01 18:46:52 +03:00

added removeDesc plugin

This commit is contained in:
Daniel Wabyick
2014-09-26 10:17:51 -07:00
parent c351ab0de8
commit 06f084d8e7
4 changed files with 35 additions and 1 deletions

View File

@ -45,3 +45,4 @@ plugins:
- transformsWithOnePath
- sortAttrs
- removeTitle
- removeDesc

View File

@ -23,7 +23,8 @@ SVGO имеет расширяемую архитектуру, в которой
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeXMLProcInst.js) ] удаление XML-инструкций
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeComments.js) ] удаление комментариев
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] удаление `<metadata>`
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) ] удаление `<title>`
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) ] удаление `<title>` (отключена по умолчанию)
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeDesc.js) ] удаление `<desc>` (отключена по умолчанию)
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEditorsNSData.js) ] удаление пространств имён различных редакторов, их элементов и атрибутов
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyAttrs.js) ] удаление пустых атрибутов
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeHiddenElems.js) ] удаление скрытых элементов

22
plugins/removeDesc.js Normal file
View File

@ -0,0 +1,22 @@
'use strict';
exports.type = 'perItem';
exports.active = false;
/**
* Remove <desc>.
* Disabled by default cause it may be used for accessibility.
*
* https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc
*
* @param {Object} item current iteration item
* @return {Boolean} if false, item will be filtered out
*
* @author Daniel Wabyick
*/
exports.fn = function(item) {
return !item.isElem('desc');
};

View File

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg">
<desc>...</desc>
<g/>
</svg>
@@@
<svg xmlns="http://www.w3.org/2000/svg">
<g/>
</svg>

After

Width:  |  Height:  |  Size: 141 B