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:
@ -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));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -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 |
Reference in New Issue
Block a user