1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

Remove standard descriptions. Resolves #302

This commit is contained in:
GreLI
2015-03-16 15:09:15 +03:00
parent d935bd0dd3
commit 9b8250d6c4
2 changed files with 14 additions and 6 deletions

View File

@ -2,11 +2,18 @@
exports.type = 'perItem'; exports.type = 'perItem';
exports.active = false; exports.active = true;
exports.params = {
removeAny: false
};
var standardDescs = /^Created with/;
/** /**
* Remove <desc>. * Removes <desc>.
* Disabled by default cause it may be used for accessibility. * Removes only standard editors content or empty elements 'cause it can be used for accessibility.
* Enable parameter 'removeAny' to remove any description.
* *
* https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc * https://developer.mozilla.org/en-US/docs/Web/SVG/Element/desc
* *
@ -15,8 +22,9 @@ exports.active = false;
* *
* @author Daniel Wabyick * @author Daniel Wabyick
*/ */
exports.fn = function(item) { exports.fn = function(item, params) {
return !item.isElem('desc'); return !item.isElem('desc') || !(params.removeAny || item.isEmpty() ||
standardDescs.test(item.content[0].text));
}; };

View File

@ -1,5 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<desc>...</desc> <desc>Created with Sketch.</desc>
<g/> <g/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 158 B