mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Add --show-plugins option
This commit is contained in:
@ -78,6 +78,7 @@ Options:
|
|||||||
--enable=ENABLE : Enable plugin by name
|
--enable=ENABLE : Enable plugin by name
|
||||||
--datauri=DATAURI : Output as Data URI string (base64, URI encoded or unencoded)
|
--datauri=DATAURI : Output as Data URI string (base64, URI encoded or unencoded)
|
||||||
--pretty : Make SVG pretty printed
|
--pretty : Make SVG pretty printed
|
||||||
|
--show-plugins : Show available plugins and exit
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
INPUT : Alias to --input
|
INPUT : Alias to --input
|
||||||
|
@ -78,6 +78,7 @@ $ [sudo] npm install -g svgo
|
|||||||
--enable=ENABLE : Включение плагина по имени
|
--enable=ENABLE : Включение плагина по имени
|
||||||
--datauri=DATAURI : Результат в виде строки Data URI (base64, URI encoded или unencoded)
|
--datauri=DATAURI : Результат в виде строки Data URI (base64, URI encoded или unencoded)
|
||||||
--pretty : Удобочитаемое форматирование SVG
|
--pretty : Удобочитаемое форматирование SVG
|
||||||
|
--show-plugins : доступные плагины
|
||||||
|
|
||||||
Аргументы:
|
Аргументы:
|
||||||
INPUT : Аналогично --input
|
INPUT : Аналогично --input
|
||||||
|
@ -102,6 +102,11 @@ module.exports = require('coa').Cmd()
|
|||||||
.long('pretty')
|
.long('pretty')
|
||||||
.flag()
|
.flag()
|
||||||
.end()
|
.end()
|
||||||
|
.opt()
|
||||||
|
.name('show-plugins').title('Show available plugins and exit')
|
||||||
|
.long('show-plugins')
|
||||||
|
.flag()
|
||||||
|
.end()
|
||||||
.arg()
|
.arg()
|
||||||
.name('input').title('Alias to --input')
|
.name('input').title('Alias to --input')
|
||||||
.end()
|
.end()
|
||||||
@ -114,6 +119,14 @@ module.exports = require('coa').Cmd()
|
|||||||
output = args && args.output ? args.output : opts.output,
|
output = args && args.output ? args.output : opts.output,
|
||||||
config = {};
|
config = {};
|
||||||
|
|
||||||
|
// --show-plugins
|
||||||
|
if (opts['show-plugins']) {
|
||||||
|
|
||||||
|
showAvailablePlugins();
|
||||||
|
process.exit(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// w/o anything
|
// w/o anything
|
||||||
if (
|
if (
|
||||||
(!input || input === '-') &&
|
(!input || input === '-') &&
|
||||||
@ -123,6 +136,7 @@ module.exports = require('coa').Cmd()
|
|||||||
process.stdin.isTTY
|
process.stdin.isTTY
|
||||||
) return this.usage();
|
) return this.usage();
|
||||||
|
|
||||||
|
|
||||||
// --config
|
// --config
|
||||||
if (opts.config) {
|
if (opts.config) {
|
||||||
|
|
||||||
@ -510,3 +524,23 @@ function optimizeFolder(dir, config, output) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
};
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'full';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'Add classnames to an outer <svg> element.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add classnames to an outer <svg> element.
|
* Add classnames to an outer <svg> element.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'cleanup attributes from newlines, trailing and repeating spaces';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
newlines: true,
|
newlines: true,
|
||||||
trim: true,
|
trim: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'full';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove or cleanup enable-background attribute when possible';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove or cleanup enable-background attr which coincides with a width/height box.
|
* Remove or cleanup enable-background attr which coincides with a width/height box.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'full';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove unused and minify used IDs';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
remove: true,
|
remove: true,
|
||||||
minify: true,
|
minify: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'Round list of values to the fixed precision';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
floatPrecision: 3,
|
floatPrecision: 3,
|
||||||
leadingZero: true,
|
leadingZero: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'round numeric values to the fixed precision, remove default \'px\' units';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
floatPrecision: 3,
|
floatPrecision: 3,
|
||||||
leadingZero: true,
|
leadingZero: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItemReverse';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'collapse useless groups';
|
||||||
|
|
||||||
var animationElems = require('./_collections').elemsGroups.animation;
|
var animationElems = require('./_collections').elemsGroups.animation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'convert colors (from rgb() to #rrggbb, from #rrggbb to #rgb)';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
names2hex: true,
|
names2hex: true,
|
||||||
rgb2hex: true,
|
rgb2hex: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'convert Path data to relative or absolute whichever is shorter, convert one segment to another, trim useless delimiters, smart rounding and much more';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
applyTransforms: true,
|
applyTransforms: true,
|
||||||
applyTransformsStroked: true,
|
applyTransformsStroked: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'convert some basic shapes to path';
|
||||||
|
|
||||||
var none = { value: 0 },
|
var none = { value: 0 },
|
||||||
regNumber = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;
|
regNumber = /[-+]?(?:\d*\.\d+|\d+\.?)(?:[eE][-+]?\d+)?/g;
|
||||||
|
|
||||||
@ -101,4 +103,4 @@ exports.fn = function(item) {
|
|||||||
.removeAttr('points');
|
.removeAttr('points');
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'Convert style in attributes. Cleanups comments and illegal declarations (without colon) as a side effect';
|
||||||
|
|
||||||
var EXTEND = require('whet.extend'),
|
var EXTEND = require('whet.extend'),
|
||||||
stylingProps = require('./_collections').stylingProps,
|
stylingProps = require('./_collections').stylingProps,
|
||||||
rEscape = '\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)', // Like \" or \2051. Code points consume one space.
|
rEscape = '\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)', // Like \" or \2051. Code points consume one space.
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'collapse multiple transforms into one, convert matrices to the short aliases and much more';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
convertToShorts: true,
|
convertToShorts: true,
|
||||||
// degPrecision: 3, // transformPrecision (or matrix precision) - 2 by default
|
// degPrecision: 3, // transformPrecision (or matrix precision) - 2 by default
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'merge multiple Paths into one';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
collapseRepeated: true,
|
collapseRepeated: true,
|
||||||
leadingZero: true,
|
leadingZero: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItemReverse';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'move elements attributes to the existing group wrapper';
|
||||||
|
|
||||||
var inheritableAttrs = require('./_collections').inheritableAttrs,
|
var inheritableAttrs = require('./_collections').inheritableAttrs,
|
||||||
pathElems = require('./_collections.js').pathElems;
|
pathElems = require('./_collections.js').pathElems;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'move some group attributes to the content elements';
|
||||||
|
|
||||||
var collections = require('./_collections.js'),
|
var collections = require('./_collections.js'),
|
||||||
pathElems = collections.pathElems.concat(['g', 'text']),
|
pathElems = collections.pathElems.concat(['g', 'text']),
|
||||||
referencesProps = collections.referencesProps;
|
referencesProps = collections.referencesProps;
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove comments';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove comments.
|
* Remove comments.
|
||||||
*
|
*
|
||||||
|
@ -8,6 +8,8 @@ exports.params = {
|
|||||||
removeAny: false
|
removeAny: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.description = 'remove <desc> (only non-meaningful by default)';
|
||||||
|
|
||||||
var standardDescs = /^Created with/;
|
var standardDescs = /^Created with/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove doctype declaration';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove DOCTYPE declaration.
|
* Remove DOCTYPE declaration.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove editors namespaces, elements and attributes';
|
||||||
|
|
||||||
var editorNamespaces = require('./_collections').editorNamespaces,
|
var editorNamespaces = require('./_collections').editorNamespaces,
|
||||||
prefixes = [];
|
prefixes = [];
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove empty attributes';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove attributes with empty values.
|
* Remove attributes with empty values.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItemReverse';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove empty Container elements';
|
||||||
|
|
||||||
var container = require('./_collections').elemsGroups.container;
|
var container = require('./_collections').elemsGroups.container;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove empty Text elements';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
text: true,
|
text: true,
|
||||||
tspan: true,
|
tspan: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove hidden elements';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
displayNone: true,
|
displayNone: true,
|
||||||
opacity0: true,
|
opacity0: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove <metadata>';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove <metadata>.
|
* Remove <metadata>.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove non-inheritable group\'s "presentation" attributes';
|
||||||
|
|
||||||
var inheritableAttrs = require('./_collections').inheritableAttrs,
|
var inheritableAttrs = require('./_collections').inheritableAttrs,
|
||||||
attrsGroups = require('./_collections').attrsGroups,
|
attrsGroups = require('./_collections').attrsGroups,
|
||||||
excludedAttrs = ['display', 'opacity'];
|
excludedAttrs = ['display', 'opacity'];
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'remove raster images (disabled by default)';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove raster images references in <image>.
|
* Remove raster images references in <image>.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'remove <title> (disabled by default)';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove <title>.
|
* Remove <title>.
|
||||||
* Disabled by default cause it may be used for accessibility.
|
* Disabled by default cause it may be used for accessibility.
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove unknown elements content and attributes, remove attrs with default values';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
unknownContent: true,
|
unknownContent: true,
|
||||||
unknownAttrs: true,
|
unknownAttrs: true,
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'full';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove unused namespaces declaration';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove unused namespaces declaration.
|
* Remove unused namespaces declaration.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove elements of <defs> without id';
|
||||||
|
|
||||||
var nonRendering = require('./_collections').elemsGroups.nonRendering,
|
var nonRendering = require('./_collections').elemsGroups.nonRendering,
|
||||||
defs;
|
defs;
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove useless stroke and fill attrs';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
stroke: true,
|
stroke: true,
|
||||||
fill: true
|
fill: true
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'remove viewBox attribute when possible (disabled by default)';
|
||||||
|
|
||||||
var regViewBox = /^0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/,
|
var regViewBox = /^0\s0\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)\s([\-+]?\d*\.?\d+([eE][\-+]?\d+)?)$/,
|
||||||
viewBoxElems = ['svg', 'pattern'];
|
viewBoxElems = ['svg', 'pattern'];
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = true;
|
exports.active = true;
|
||||||
|
|
||||||
|
exports.description = 'remove XML processing instructions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove XML Processing Instruction.
|
* Remove XML Processing Instruction.
|
||||||
*
|
*
|
||||||
|
@ -4,6 +4,8 @@ exports.type = 'perItem';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'sort element attributes for epic readability (disabled by default)';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
order: [
|
order: [
|
||||||
'xmlns',
|
'xmlns',
|
||||||
|
@ -8,6 +8,8 @@ exports.type = 'full';
|
|||||||
|
|
||||||
exports.active = false;
|
exports.active = false;
|
||||||
|
|
||||||
|
exports.description = 'apply transforms, crop by real width, center vertical alignment and resize SVG with one Path inside (disabled by default)';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
// width and height to resize SVG and rescale inner Path
|
// width and height to resize SVG and rescale inner Path
|
||||||
width: false,
|
width: false,
|
||||||
|
Reference in New Issue
Block a user