svgo
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -0,1 +1,9 @@ | ||
### [ [>](https://github.com/svg/svgo/tree/v0.5.3) ] 0.5.3 / 21.06.2015 | ||
* Fixed breaking related to rounding functions in “[convertTransform](https://github.com/svg/svgo/blob/master/plugins/convertTransform.js)”. | ||
* Fixed a bug with ID in animations not being worked on by “[cleanupIDs](https://github.com/svg/svgo/blob/master/plugins/cleanupIDs.js)”. | ||
* Fixed a bug with quoted reference in `url()`. | ||
* Now, if there are several same IDs in the document, then the first one is used and others are being removed. | ||
* New command-line option `--show-plugins` displaying list of plugins. | ||
* Two new optional plugins: “[removeDimensions](removeDimensions.js)” (removes `width` and `height` if there is `viewBox`) and “[removeAttrsPlugin](removeAttrsPlugin.js)” (by @bennyschudel). | ||
### [ [>](https://github.com/svg/svgo/tree/v0.5.2) ] 0.5.2 / 24.05.2015 | ||
@@ -2,0 +10,0 @@ * Introduced new `transformPrecision` option for better image quality (defaults to 5) in “[convertTransform](https://github.com/svg/svgo/blob/master/plugins/convertTransform.js)” and “[convertPathData](https://github.com/svg/svgo/blob/master/plugins/convertPathData.js)” (for the purpose of applying transformations) plugins. |
@@ -0,1 +1,2 @@ | ||
/* jshint quotmark: false */ | ||
'use strict'; | ||
@@ -105,2 +106,7 @@ | ||
.end() | ||
.opt() | ||
.name('show-plugins').title('Show available plugins and exit') | ||
.long('show-plugins') | ||
.flag() | ||
.end() | ||
.arg() | ||
@@ -118,2 +124,10 @@ .name('input').title('Alias to --input') | ||
// --show-plugins | ||
if (opts['show-plugins']) { | ||
showAvailablePlugins(); | ||
process.exit(0); | ||
} | ||
// w/o anything | ||
@@ -128,2 +142,3 @@ if ( | ||
// --config | ||
@@ -516,1 +531,21 @@ if (opts.config) { | ||
} | ||
var showAvailablePlugins = function () { | ||
var svgo = new SVGO(); | ||
console.log('Currently available plugins:'); | ||
svgo.config.plugins.forEach(function (plugins) { | ||
plugins.forEach(function (plugin) { | ||
console.log(' [ ' + plugin.name.green + ' ] ' + plugin.description); | ||
}); | ||
}); | ||
//console.log(JSON.stringify(svgo, null, 4)); | ||
}; |
@@ -74,20 +74,28 @@ 'use strict'; | ||
key = Object.keys(item)[0]; | ||
plugin = EXTEND({}, require('../../plugins/' + key)); | ||
// name: {} | ||
if (typeof item[key] === 'object') { | ||
plugin.params = EXTEND({}, plugin.params || {}, item[key]); | ||
plugin.active = true; | ||
// custom | ||
if (typeof item[key] === 'object' && item[key].fn && typeof item[key].fn === 'function') { | ||
plugin = setupCustomPlugin(key, item[key]); | ||
// name: false | ||
} else if (item[key] === false) { | ||
plugin.active = false; | ||
} else { | ||
// name: true | ||
} else if (item[key] === true) { | ||
plugin.active = true; | ||
plugin = EXTEND({}, require('../../plugins/' + key)); | ||
// name: {} | ||
if (typeof item[key] === 'object') { | ||
plugin.params = EXTEND({}, plugin.params || {}, item[key]); | ||
plugin.active = true; | ||
// name: false | ||
} else if (item[key] === false) { | ||
plugin.active = false; | ||
// name: true | ||
} else if (item[key] === true) { | ||
plugin.active = true; | ||
} | ||
plugin.name = key; | ||
} | ||
plugin.name = key; | ||
// name | ||
@@ -128,22 +136,27 @@ } else { | ||
defaults.plugins.forEach(function(plugin) { | ||
// custom | ||
if (typeof item[key] === 'object' && item[key].fn && typeof item[key].fn === 'function') { | ||
defaults.plugins.push(setupCustomPlugin(key, item[key])); | ||
if (plugin.name === key) { | ||
// name: {} | ||
if (typeof item[key] === 'object') { | ||
plugin.params = EXTEND({}, plugin.params || {}, item[key]); | ||
plugin.active = true; | ||
} else { | ||
defaults.plugins.forEach(function(plugin) { | ||
// name: false | ||
} else if (item[key] === false) { | ||
plugin.active = false; | ||
if (plugin.name === key) { | ||
// name: {} | ||
if (typeof item[key] === 'object') { | ||
plugin.params = EXTEND({}, plugin.params || {}, item[key]); | ||
plugin.active = true; | ||
// name: true | ||
} else if (item[key] === true) { | ||
plugin.active = true; | ||
// name: false | ||
} else if (item[key] === false) { | ||
plugin.active = false; | ||
// name: true | ||
} else if (item[key] === true) { | ||
plugin.active = true; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
@@ -170,2 +183,17 @@ | ||
/** | ||
* Setup and enable a custom plugin | ||
* | ||
* @param {String} plugin name | ||
* @param {Object} custom plugin | ||
* @return {Array} enabled plugin | ||
*/ | ||
function setupCustomPlugin(name, plugin) { | ||
plugin.active = true; | ||
plugin.params = EXTEND({}, plugin.params || {}); | ||
plugin.name = name; | ||
return plugin; | ||
} | ||
/** | ||
* Try to group sequential elements of plugins array. | ||
@@ -172,0 +200,0 @@ * |
@@ -11,3 +11,3 @@ 'use strict'; | ||
value: parentNode | ||
}) | ||
}); | ||
} | ||
@@ -18,3 +18,3 @@ }; | ||
* Perform a deep clone of this node. | ||
* | ||
* | ||
* @return {Object} element | ||
@@ -40,3 +40,3 @@ */ | ||
var clonedNode = new JSAPI(nodeData, !!node.parentNode); | ||
if (node.content) { | ||
@@ -163,2 +163,3 @@ clonedNode.content = node.content.map(function(childNode) { | ||
JSAPI.prototype.computedAttr = function(name, val) { | ||
/* jshint eqnull: true */ | ||
if (!arguments.length) return; | ||
@@ -165,0 +166,0 @@ |
{ | ||
"name": "svgo", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Nodejs-based tool for optimizing SVG vector graphics files", | ||
@@ -45,3 +45,3 @@ "keywords": [ "svgo", "svg", "optimize", "minify" ], | ||
"js-yaml": "~3.3.1", | ||
"colors": "~1.1.0", | ||
"colors": "~1.1.2", | ||
"whet.extend": "~0.9.9", | ||
@@ -52,4 +52,4 @@ "mkdirp": "~0.5.1" | ||
"mocha": "~2.2.5", | ||
"should": "6.0.3", | ||
"istanbul": "~0.3.14", | ||
"should": "7.0.1", | ||
"istanbul": "~0.3.15", | ||
"mocha-istanbul": "~0.2.0", | ||
@@ -56,0 +56,0 @@ "coveralls": "~2.11.2" |
@@ -0,1 +1,2 @@ | ||
/* global a2c */ | ||
'use strict'; | ||
@@ -179,3 +180,3 @@ | ||
elem.someAttr(function(attr) { | ||
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url(') | ||
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url('); | ||
})) | ||
@@ -548,3 +549,3 @@ return path; | ||
base: prev.base | ||
} | ||
}; | ||
} else { | ||
@@ -654,2 +655,4 @@ prev.data = item.data; | ||
function processSimplex(simplex, direction) { | ||
/* jshint -W004 */ | ||
// we only need to handle to 1-simplex and 2-simplex | ||
@@ -810,2 +813,4 @@ if (simplex.length == 2) { // 1-simplex | ||
function convexHull(points) { | ||
/* jshint -W004 */ | ||
points.sort(function(a, b) { | ||
@@ -858,3 +863,3 @@ return a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]; | ||
function cross(o, a, b) { | ||
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) | ||
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]); | ||
} | ||
@@ -866,2 +871,3 @@ | ||
// jshint ignore: start | ||
function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) { | ||
@@ -947,1 +953,2 @@ // for more information of where this Math came from visit: | ||
} | ||
// jshint ignore: end |
@@ -64,3 +64,3 @@ 'use strict'; | ||
}) | ||
} | ||
}; | ||
@@ -153,3 +153,2 @@ return transforms; | ||
var a1 = mth.acos(data[0] / sx, floatPrecision), | ||
a2 = mth.asin(data[1] / (rowsSum ? sx : sy), floatPrecision), | ||
rotate = [a1.toFixed(floatPrecision) * (data[1] < 0 ? -1 : 1)]; | ||
@@ -162,3 +161,3 @@ | ||
data: [mth.atan(colsSum / (sx * sx), floatPrecision)] | ||
}) | ||
}); | ||
@@ -232,3 +231,3 @@ // rotate(a, cx, cy) can consume translate() within optional arguments cx, cy (rotation point) | ||
}; | ||
} | ||
@@ -235,0 +234,0 @@ /** |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'adds classnames to an outer <svg> element'; | ||
/** | ||
@@ -15,4 +17,4 @@ * Add classnames to an outer <svg> element. | ||
var classNames = params.classNames || [ params.className ] | ||
var svg = data.content[0] | ||
var classNames = params.classNames || [ params.className ]; | ||
var svg = data.content[0]; | ||
@@ -19,0 +21,0 @@ if (svg.isElem('svg')) { |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'cleanups attributes from newlines, trailing and repeating spaces'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ newlines: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'remove or cleanup enable-background attribute when possible'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove or cleanup enable-background attr which coincides with a width/height box. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes unused IDs and minifies used'; | ||
exports.params = { | ||
@@ -15,4 +17,5 @@ remove: true, | ||
var referencesProps = require('./_collections').referencesProps, | ||
regReferencesUrl = /^url\(#(.+?)\)$/, | ||
regReferencesUrl = /^url\(("|')?#(.+?)\1\)$/, | ||
regReferencesHref = /^#(.+?)$/, | ||
regReferencesBegin = /^(\w+?)\./, | ||
styleOrScript = ['style', 'script'], | ||
@@ -69,3 +72,7 @@ generateIDchars = [ | ||
if (attr.name === 'id') { | ||
IDs[idPrefix + attr.value] = item; | ||
if (idPrefix + attr.value in IDs) { | ||
item.removeAttr('id'); | ||
} else { | ||
IDs[idPrefix + attr.value] = item; | ||
} | ||
} | ||
@@ -78,6 +85,6 @@ | ||
if (match) { | ||
if (referencesIDs[idPrefix + match[1]]) { | ||
referencesIDs[idPrefix + match[1]].push(attr); | ||
if (referencesIDs[idPrefix + match[2]]) { | ||
referencesIDs[idPrefix + match[2]].push(attr); | ||
} else { | ||
referencesIDs[idPrefix + match[1]] = [attr]; | ||
referencesIDs[idPrefix + match[2]] = [attr]; | ||
} | ||
@@ -88,11 +95,10 @@ } | ||
// save IDs href references | ||
else if (attr.name === 'xlink:href') { | ||
match = attr.value.match(regReferencesHref); | ||
if (match) { | ||
if (referencesIDs[idPrefix + match[1]]) { | ||
referencesIDs[idPrefix + match[1]].push(attr); | ||
} else { | ||
referencesIDs[idPrefix + match[1]] = [attr]; | ||
} | ||
else if ( | ||
attr.name === 'xlink:href' && (match = attr.value.match(regReferencesHref)) || | ||
attr.name === 'begin' && (match = attr.value.match(regReferencesBegin)) | ||
) { | ||
if (referencesIDs[idPrefix + match[1]]) { | ||
referencesIDs[idPrefix + match[1]].push(attr); | ||
} else { | ||
referencesIDs[idPrefix + match[1]] = [attr]; | ||
} | ||
@@ -132,3 +138,6 @@ } | ||
referencesIDs[k].forEach(function(attr) { | ||
attr.value = attr.value.replace('#' + k.replace(idPrefix, ''), '#' + currentIDstring); | ||
k = k.replace(idPrefix, ''); | ||
attr.value = attr.value | ||
.replace('#' + k, '#' + currentIDstring) | ||
.replace(k + '.', currentIDstring + '.'); | ||
}); | ||
@@ -139,3 +148,3 @@ | ||
// don't remove referenced IDs | ||
delete IDs[k]; | ||
delete IDs[idPrefix + k]; | ||
@@ -142,0 +151,0 @@ } |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'rounds list of values to the fixed precision'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ floatPrecision: 3, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'rounds numeric values to the fixed precision, removes default ‘px’ units'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ floatPrecision: 3, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'collapses useless groups'; | ||
var animationElems = require('./_collections').elemsGroups.animation; | ||
@@ -9,0 +11,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'converts colors: rgb() to #rrggbb and #rrggbb to #rgb'; | ||
exports.params = { | ||
@@ -109,3 +111,3 @@ names2hex: true, | ||
function rgb2hex(rgb) { | ||
return '#' + ("00000" + (rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16)).slice(-6).toUpperCase(); | ||
return '#' + ('00000' + (rgb[0] << 16 | rgb[1] << 8 | rgb[2]).toString(16)).slice(-6).toUpperCase(); | ||
} |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'optimizes path data: writes in shorter form, applies transformations'; | ||
exports.params = { | ||
@@ -265,4 +267,6 @@ applyTransforms: true, | ||
var sdata; | ||
if (instruction === 's') { | ||
var sdata = [0, 0].concat(data); | ||
sdata = [0, 0].concat(data); | ||
@@ -642,3 +646,3 @@ if ('cs'.indexOf(prev.instruction) > -1) { | ||
roundData = precision > 0 ? strongRound : round; | ||
roundData = precision > 0 ? strongRound : round; // jshint ignore: line | ||
@@ -645,0 +649,0 @@ return roundData(data); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'converts basic shapes to more compact path form'; | ||
var none = { value: 0 }, | ||
@@ -105,2 +107,2 @@ regNumber = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g; | ||
}; | ||
}; |
@@ -0,1 +1,2 @@ | ||
/* jshint quotmark: false */ | ||
'use strict'; | ||
@@ -7,2 +8,4 @@ | ||
exports.description = 'converts style to attributes'; | ||
var EXTEND = require('whet.extend'), | ||
@@ -51,2 +54,3 @@ stylingProps = require('./_collections').stylingProps, | ||
exports.fn = function(item) { | ||
/* jshint boss: true */ | ||
@@ -63,3 +67,3 @@ if (item.elem && item.hasAttr('style')) { | ||
match[0] == '\\' && /[-g-z]/i.test(match[1]) ? match[1] : match; | ||
}) | ||
}); | ||
@@ -66,0 +70,0 @@ regDeclarationBlock.lastIndex = 0; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'collapses multiple transformations and optimizes it'; | ||
exports.params = { | ||
@@ -26,3 +28,6 @@ convertToShorts: true, | ||
transformsMultiply = require('./_transforms.js').transformsMultiply, | ||
matrixToTransform = require('./_transforms.js').matrixToTransform; | ||
matrixToTransform = require('./_transforms.js').matrixToTransform, | ||
degRound, | ||
floatRound, | ||
transformRound; | ||
@@ -74,22 +79,5 @@ /** | ||
function convertTransform(item, attrName, params) { | ||
var data = transform2js(item.attr(attrName).value), | ||
matrixData = data.reduce(function(a, b) { return b.name == 'matrix' ? a.concat(b.data.slice(0, 4)) : a }, []), | ||
degPrecision = params.floatPrecision, | ||
significantDigits = params.transformPrecision; | ||
var data = transform2js(item.attr(attrName).value); | ||
definePrecision(data, params); | ||
// Limit transform precision with matrix one. Calculating with larger precision doesn't add any value. | ||
if (matrixData.length) { | ||
params.transformPrecision = Math.min(params.transformPrecision, | ||
Math.max.apply(Math, matrixData.map(function(n) { | ||
return (n = String(n)).slice(n.indexOf('.')).length - 1; // Number of digits after point. 0.125 → 3 | ||
})) || params.transformPrecision); | ||
significantDigits = Math.max.apply(Math, matrixData.map(function(n) { | ||
return String(n).replace(/\D+/g, '').length; // Number of digits in number. 123.45 → 5 | ||
})); | ||
} | ||
// No sense in angle precision more then number of significant digits in matrix. | ||
if (!('degPrecision' in params)) { | ||
params.degPrecision = Math.max(0, Math.min(params.floatPrecision, significantDigits - 2)); | ||
} | ||
if (params.collapseIntoOne && data.length > 1) { | ||
@@ -115,2 +103,55 @@ data = [transformsMultiply(data)]; | ||
/** | ||
* Defines precision to work with certain parts. | ||
* transformPrecision - for scale and four first matrix parameters (needs a better precision due to multiplying), | ||
* floatPrecision - for translate including two last matrix and rotate parameters, | ||
* degPrecision - for rotate and skew. By default it's equal to (rougly) | ||
* transformPrecision - 2 or floatPrecision whichever is lower. Can be set in params. | ||
* | ||
* @param {Array} transforms input array | ||
* @param {Object} params plugin params | ||
* @return {Array} output array | ||
*/ | ||
function definePrecision(data, params) { | ||
/* jshint validthis: true */ | ||
var matrixData = data.reduce(getMatrixData, []), | ||
significantDigits = params.transformPrecision; | ||
// Limit transform precision with matrix one. Calculating with larger precision doesn't add any value. | ||
if (matrixData.length) { | ||
params.transformPrecision = Math.min(params.transformPrecision, | ||
Math.max.apply(Math, matrixData.map(floatDigits)) || params.transformPrecision); | ||
significantDigits = Math.max.apply(Math, matrixData.map(function(n) { | ||
return String(n).replace(/\D+/g, '').length; // Number of digits in a number. 123.45 → 5 | ||
})); | ||
} | ||
// No sense in angle precision more then number of significant digits in matrix. | ||
if (!('degPrecision' in params)) { | ||
params.degPrecision = Math.max(0, Math.min(params.floatPrecision, significantDigits - 2)); | ||
} | ||
degRound = params.degPrecision >= 1 ? smartRound.bind(this, params.degPrecision) : round; | ||
floatRound = params.floatPrecision >= 1 ? smartRound.bind(this, params.floatPrecision) : round; | ||
transformRound = params.transformPrecision >= 1 ? smartRound.bind(this, params.transformPrecision) : round; | ||
} | ||
/** | ||
* Gathers four first matrix parameters. | ||
* | ||
* @param {Array} a array of data | ||
* @param {Object} transform | ||
* @return {Array} output array | ||
*/ | ||
function getMatrixData(a, b) { | ||
return b.name == 'matrix' ? a.concat(b.data.slice(0, 4)) : a; | ||
} | ||
/** | ||
* Returns number of digits after the point. 0.125 → 3 | ||
*/ | ||
function floatDigits(n) { | ||
return (n = String(n)).slice(n.indexOf('.')).length - 1; | ||
} | ||
/** | ||
* Convert transforms to the shorthand alternatives. | ||
@@ -238,3 +279,3 @@ * | ||
) { | ||
return false | ||
return false; | ||
} | ||
@@ -269,30 +310,30 @@ | ||
function roundTransform(transform, params) { | ||
var floatRound = params.floatPrecision > 0 ? smartRound : round, | ||
transformRound = params.transformPrecision > 0 ? smartRound : round; | ||
function roundTransform(transform) { | ||
switch (transform.name) { | ||
case 'translate': | ||
transform.data = floatRound(transform.data, params.floatPrecision); | ||
transform.data = floatRound(transform.data); | ||
break; | ||
case 'rotate': | ||
transform.data = floatRound(transform.data.slice(0, 1), params.degPrecision) | ||
.concat(floatRound(transform.data.slice(1), params.floatPrecision)); | ||
transform.data = degRound(transform.data.slice(0, 1)).concat(floatRound(transform.data.slice(1))); | ||
break; | ||
case 'skewX': | ||
case 'skewY': | ||
transform.data = floatRound(transform.data, params.degPrecision); | ||
transform.data = degRound(transform.data); | ||
break; | ||
case 'scale': | ||
transform.data = transformRound(transform.data, params.transformPrecision); | ||
transform.data = transformRound(transform.data); | ||
break; | ||
case 'matrix': | ||
transform.data = transformRound(transform.data.slice(0, 4), params.transformPrecision) | ||
.concat(floatRound(transform.data.slice(4), params.floatPrecision)); | ||
transform.data = transformRound(transform.data.slice(0, 4)).concat(floatRound(transform.data.slice(4))); | ||
break; | ||
} | ||
return transform; | ||
} | ||
/** | ||
* Rounds numbers in array. | ||
* | ||
* @param {Array} data input data array | ||
* @return {Array} output data array | ||
*/ | ||
function round(data) { | ||
@@ -307,7 +348,7 @@ return data.map(Math.round); | ||
* | ||
* @param {Number} fixed number of decimals | ||
* @param {Array} data input data array | ||
* @param {Number} fixed number of decimals | ||
* @return {Array} output data array | ||
*/ | ||
function smartRound(data, precision) { | ||
function smartRound(precision, data) { | ||
for (var i = data.length, tolerance = Math.pow(.1, precision); i--;) { | ||
@@ -314,0 +355,0 @@ var rounded = +data[i].toFixed(precision - 1); |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'merges multiple paths in one if possible'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ collapseRepeated: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'moves elements attributes to the existing group wrapper'; | ||
var inheritableAttrs = require('./_collections').inheritableAttrs, | ||
@@ -9,0 +11,0 @@ pathElems = require('./_collections.js').pathElems; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'moves some group attributes to the content elements'; | ||
var collections = require('./_collections.js'), | ||
@@ -39,3 +41,3 @@ pathElems = collections.pathElems.concat(['g', 'text']), | ||
!item.someAttr(function(attr) { | ||
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url(') | ||
return ~referencesProps.indexOf(attr.name) && ~attr.value.indexOf('url('); | ||
}) && | ||
@@ -42,0 +44,0 @@ item.content.every(function(inner) { |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes comments'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove comments. |
@@ -11,2 +11,4 @@ 'use strict'; | ||
exports.description = 'removes <desc> (only non-meaningful by default)'; | ||
var standardDescs = /^Created with/; | ||
@@ -13,0 +15,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes doctype declaration'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove DOCTYPE declaration. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes editors namespaces, elements and attributes'; | ||
var editorNamespaces = require('./_collections').editorNamespaces, | ||
@@ -9,0 +11,0 @@ prefixes = []; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes empty attributes'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove attributes with empty values. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes empty container elements'; | ||
var container = require('./_collections').elemsGroups.container; | ||
@@ -9,0 +11,0 @@ |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes empty <text> elements'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ text: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes hidden elements (zero sized, with absent attributes)'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ displayNone: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes <metadata>'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove <metadata>. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes non-inheritable group’s presentational attributes'; | ||
var inheritableAttrs = require('./_collections').inheritableAttrs, | ||
@@ -9,0 +11,0 @@ attrsGroups = require('./_collections').attrsGroups, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes raster images (disabled by default)'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove raster images references in <image>. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes <title> (disabled by default)'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove <title>. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes unknown elements content and attributes, removes attrs with default values'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ unknownContent: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes unused namespaces declaration'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove unused namespaces declaration. |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -7,2 +7,4 @@ exports.type = 'perItem'; | ||
exports.description = 'removes elements in <defs> without id'; | ||
var nonRendering = require('./_collections').elemsGroups.nonRendering, | ||
@@ -9,0 +11,0 @@ defs; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes useless stroke and fill attributes'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ stroke: true, |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes viewBox attribute when possible (disabled by default)'; | ||
var regViewBox = /^0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/, | ||
@@ -9,0 +11,0 @@ viewBoxElems = ['svg', 'pattern']; |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'removes XML processing instructions'; | ||
/** | ||
@@ -9,0 +11,0 @@ * Remove XML Processing Instruction. |
@@ -7,2 +7,4 @@ 'use strict'; | ||
exports.description = 'sorts element attributes (disabled by default)'; | ||
exports.params = { | ||
@@ -9,0 +11,0 @@ order: [ |
@@ -11,2 +11,4 @@ 'use strict'; | ||
exports.description = 'performs a set of operations on SVG with one path inside (disabled by default)'; | ||
exports.params = { | ||
@@ -13,0 +15,0 @@ // width and height to resize SVG and rescale inner Path |
@@ -25,3 +25,3 @@ **english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md) | ||
* [ [ removeComments](https://github.com/svg/svgo/blob/master/plugins/removeComments.js) ] remove comments | ||
* [ [ removeMetaData](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] remove `<metadata>` | ||
* [ [ removeMetadata](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] remove `<metadata>` | ||
* [ [ removeTitle](https://github.com/svg/svgo/blob/master/plugins/removeTitle.js) ] remove `<title>` (disabled by default) | ||
@@ -55,2 +55,5 @@ * [ [ removeDesc](https://github.com/svg/svgo/blob/master/plugins/removeDesc.js) ] remove `<desc>` (only non-meaningful by default) | ||
* [ [ transformsWithOnePath](https://github.com/svg/svgo/blob/master/plugins/transformsWithOnePath.js) ] apply transforms, crop by real width, center vertical alignment and resize SVG with one Path inside (disabled by default) | ||
* [ [ removeDimensions](https://github.com/svg/svgo/blob/master/plugins/removeDimensions.js) ] remove width/height attributes if viewBox is present (disabled by default) | ||
* [ [ removeAttrs](https://github.com/svg/svgo/blob/master/plugins/removeAttrs.js) ] remove attributes by pattern (disabled by default) | ||
* [ [ addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) ] add classnames to an outer `<svg>` element (disabled by default) | ||
@@ -83,2 +86,3 @@ Want to know how it works and how to write your own plugin? [Of course you want to](https://github.com/svg/svgo/blob/master/docs/how-it-works/en.md). | ||
--pretty : Make SVG pretty printed | ||
--show-plugins : Show available plugins and exit | ||
@@ -135,2 +139,3 @@ Arguments: | ||
* as an OSX Folder Action – [svgo-osx-folder-action](https://github.com/svg/svgo-osx-folder-action) | ||
* as a webpack loader – [image-webpack-loader](https://github.com/tcoopman/image-webpack-loader) | ||
@@ -137,0 +142,0 @@ ## Donate |
@@ -54,2 +54,5 @@ [english](https://github.com/svg/svgo/blob/master/README.md) | **русский** | ||
* [ [ transformsWithOnePath](https://github.com/svg/svgo/blob/master/plugins/transformsWithOnePath.js) ] применение трансформаций, обрезка по реальной ширине, вертикальное выравнивание по центру и изменение размеров SVG с одним Path внутри | ||
* [ [ removeDimensions](https://github.com/svg/svgo/blob/master/plugins/removeDimensions.js) ] удаляет атрибуты width/height при наличии viewBox (выключено по умолчанию) | ||
* [ [ removeAttrs](https://github.com/svg/svgo/blob/master/plugins/removeAttrs.js) ] удаляет атрибуты по указанному паттерну (выключено по умолчанию) | ||
* [ [ addClassesToSVGElement](https://github.com/svg/svgo/blob/master/plugins/addClassesToSVGElement.js) ] добавляет имена классов корневому элементу `<svg>` (выключено по умолчанию) | ||
@@ -82,2 +85,3 @@ Хотите узнать, как это работает и как написать свой плагин? [Конечно же, да!](https://github.com/svg/svgo/blob/master/docs/how-it-works/ru.md). | ||
--pretty : Удобочитаемое форматирование SVG | ||
--show-plugins : доступные плагины | ||
@@ -84,0 +88,0 @@ Аргументы: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
301770
57
8062
147
Updatedcolors@~1.1.2