svgo
Advanced tools
Comparing version 0.6.3 to 0.6.4
@@ -0,1 +1,7 @@ | ||
### [ [>](https://github.com/svg/svgo/tree/v0.6.4) ] 0.6.4 / 05.04.2016 | ||
* Fixed bug in “[convertStyleToAttrs](https://github.com/svg/svgo/blob/master/plugins/convertStyleToAttrs.js)” plugin with converting styling properties to non-existent attributes (which are normally removed later by `removeUnknownsAndDefaults`). | ||
* Added `--indent` option to style pretty-printed SVG. (e.g. `--indent 2`) (by @scurker). | ||
* Added `currentColor` param to `convertColors` plugin for converting values like `fill` and `stroke` to `currentColor` (by @scurker). | ||
* Bumped CSSO to the current version and used [its new shiny API](https://github.com/css/csso#api) (thanks to @lahmatiy). | ||
### [ [>](https://github.com/svg/svgo/tree/v0.6.3) ] 0.6.3 / 20.03.2016 | ||
@@ -2,0 +8,0 @@ * Smart rounding (introduced in 0.4.5) now applies only when rounding is needed, thus making subsequent passes more stable. |
@@ -110,2 +110,9 @@ /* jshint quotmark: false */ | ||
.opt() | ||
.name('indent').title('Indent number when pretty printing SVGs') | ||
.long('indent') | ||
.val(function(val) { | ||
return !isNaN(val) ? val : this.reject("Option '--indent' must be an integer number"); | ||
}) | ||
.end() | ||
.opt() | ||
.name('quiet').title('Only output error messages, not regular status messages') | ||
@@ -220,2 +227,5 @@ .short('q').long('quiet') | ||
config.js2svg.pretty = true; | ||
if (opts.indent) { | ||
config.js2svg.indent = parseInt(opts.indent, 10); | ||
} | ||
@@ -222,0 +232,0 @@ } |
@@ -25,3 +25,3 @@ 'use strict'; | ||
textEnd: '', | ||
indent: ' ', | ||
indent: 4, | ||
regEntities: /[&'"<>]/g, | ||
@@ -64,2 +64,10 @@ regValEntities: /[&"<>]/g, | ||
var indent = this.config.indent; | ||
if (typeof indent == 'number' && !isNaN(indent)) { | ||
this.config.indent = ''; | ||
for (var i = indent; i-- > 0;) this.config.indent += ' '; | ||
} else if (typeof indent != 'string') { | ||
this.config.indent = ' '; | ||
} | ||
if (this.config.pretty) { | ||
@@ -66,0 +74,0 @@ this.config.doctypeEnd += '\n'; |
{ | ||
"name": "svgo", | ||
"version": "0.6.3", | ||
"version": "0.6.4", | ||
"description": "Nodejs-based tool for optimizing SVG vector graphics files", | ||
@@ -50,16 +50,16 @@ "keywords": [ | ||
"dependencies": { | ||
"sax": "~1.1.6", | ||
"sax": "~1.2.1", | ||
"coa": "~1.0.1", | ||
"js-yaml": "~3.5.3", | ||
"js-yaml": "~3.5.5", | ||
"colors": "~1.1.2", | ||
"whet.extend": "~0.9.9", | ||
"mkdirp": "~0.5.1", | ||
"csso": "~1.6.4" | ||
"csso": "~1.8.1" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~2.4.5", | ||
"should": "8.2.2", | ||
"should": "8.3.0", | ||
"istanbul": "~0.4.2", | ||
"mocha-istanbul": "~0.2.0", | ||
"coveralls": "~2.11.8" | ||
"coveralls": "~2.11.9" | ||
}, | ||
@@ -66,0 +66,0 @@ "engines": { |
@@ -2299,75 +2299,2 @@ 'use strict'; | ||
// http://www.w3.org/TR/SVG/styling.html#SVGStylingProperties | ||
exports.stylingProps = [ | ||
'font', | ||
'font-family', | ||
'font-size', | ||
'font-size-adjust', | ||
'font-stretch', | ||
'font-style', | ||
'font-variant', | ||
'font-weight', | ||
'direction', | ||
'letter-spacing', | ||
'text-decoration', | ||
'unicode-bidi', | ||
'white-space', | ||
'word-spacing', | ||
'clip', | ||
'color', | ||
'cursor', | ||
'display', | ||
'overflow', | ||
'visibility', | ||
'clip-path', | ||
'clip-rule', | ||
'mask', | ||
'opacity', | ||
'enable-background', | ||
'filter', | ||
'flood-color', | ||
'flood-opacity', | ||
'lighting-color', | ||
'solid-color', | ||
'solid-opacity', | ||
'stop-color', | ||
'stop-opacity', | ||
'pointer-events', | ||
'buffered-rendering', | ||
'color-interpolation', | ||
'color-interpolation-filters', | ||
'color-profile', | ||
'color-rendering', | ||
'fill', | ||
'fill-opacity', | ||
'fill-rule', | ||
'image-rendering', | ||
'marker', | ||
'marker-end', | ||
'marker-mid', | ||
'marker-start', | ||
'shape-rendering', | ||
'stroke', | ||
'stroke-dasharray', | ||
'stroke-dashoffset', | ||
'stroke-linecap', | ||
'stroke-linejoin', | ||
'stroke-miterlimit', | ||
'stroke-opacity', | ||
'stroke-width', | ||
'paint-order', | ||
'vector-effect', | ||
'viewport-fill', | ||
'viewport-fill-opacity', | ||
'text-rendering', | ||
'alignment-baseline', | ||
'baseline-shift', | ||
'dominant-baseline', | ||
'glyph-orientation-horizontal', | ||
'glyph-orientation-vertical', | ||
'kerning', | ||
'text-anchor', | ||
'writing-mode' | ||
]; | ||
// http://www.w3.org/TR/SVG/propidx.html | ||
@@ -2374,0 +2301,0 @@ exports.inheritableAttrs = [ |
@@ -10,2 +10,3 @@ 'use strict'; | ||
exports.params = { | ||
currentColor: false, | ||
names2hex: true, | ||
@@ -21,3 +22,4 @@ rgb2hex: true, | ||
regRGB = new RegExp('^rgb\\(\\s*' + rNumber + rComma + rNumber + rComma + rNumber + '\\s*\\)$'), | ||
regHEX = /^\#(([a-fA-F0-9])\2){3}$/; | ||
regHEX = /^\#(([a-fA-F0-9])\2){3}$/, | ||
none = /\bnone\b/i; | ||
@@ -61,2 +63,7 @@ /** | ||
// Convert colors to currentColor | ||
if (params.currentColor && (match = !val.match(none))) { | ||
val = 'currentColor'; | ||
} | ||
// Convert color name keyword to long hex | ||
@@ -63,0 +70,0 @@ if (params.names2hex && val.toLowerCase() in collections.colorsNames) { |
@@ -11,3 +11,3 @@ /* jshint quotmark: false */ | ||
var EXTEND = require('whet.extend'), | ||
stylingProps = require('./_collections').stylingProps, | ||
stylingProps = require('./_collections').attrsGroups.presentation, | ||
rEscape = '\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)', // Like \" or \2051. Code points consume one space. | ||
@@ -14,0 +14,0 @@ rAttr = '\\s*(' + g('[^:;\\\\]', rEscape) + '*?)\\s*', // attribute name like ‘fill’ |
@@ -15,21 +15,2 @@ 'use strict'; | ||
// wraps css rules into a selector to make it parseable | ||
var rulesToDummySelector = function(str) { | ||
return '.dummy { ' + str + ' }'; | ||
}; | ||
// helper to extract css rules from full css selector | ||
var extractRuleCss = function(str) { | ||
var strEx = str.match(/\.dummy{(.*)}/i)[1]; | ||
return strEx; | ||
}; | ||
// minifies css using csso | ||
var minifyCss = function(css, options) { | ||
return csso.minify(css, options); | ||
}; | ||
/** | ||
@@ -50,3 +31,3 @@ * Minifies styles (<style> element + style attribute) using svgo | ||
if(styleCss.length > 0) { | ||
var styleCssMinified = minifyCss(styleCss, svgoOptions); | ||
var styleCssMinified = csso.minify(styleCss, svgoOptions); | ||
item.content[0][DATA] = styleCssMinified; | ||
@@ -59,11 +40,3 @@ } | ||
if(itemCss.length > 0) { | ||
var itemCssMinified = | ||
extractRuleCss( | ||
minifyCss( | ||
rulesToDummySelector( | ||
itemCss | ||
), | ||
svgoOptions | ||
) | ||
); | ||
var itemCssMinified = csso.minifyBlock(itemCss, svgoOptions); | ||
item.attr('style').value = itemCssMinified; | ||
@@ -70,0 +43,0 @@ } |
@@ -7,3 +7,3 @@ 'use strict'; | ||
exports.description = 'removes <style>'; | ||
exports.description = 'removes <style> element (disabled by default)'; | ||
@@ -10,0 +10,0 @@ /** |
@@ -47,2 +47,3 @@ **english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md) | ||
* [ [ cleanupNumericValues](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) ] round numeric values to the fixed precision, remove default 'px' units | ||
* [ [ cleanupListOfValues](https://github.com/svg/svgo/blob/master/plugins/cleanupListOfValues.js) ] round numeric values in attributes that take a list of numbers, like `viewBox` or `enableBackground` | ||
* [ [ moveElemsAttrsToGroup](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] move elements attributes to the existing group wrapper | ||
@@ -49,0 +50,0 @@ * [ [ moveGroupAttrsToElems](https://github.com/svg/svgo/blob/master/plugins/moveGroupAttrsToElems.js) ] move some group attributes to the content elements |
@@ -47,2 +47,3 @@ [english](https://github.com/svg/svgo/blob/master/README.md) | **русский** | ||
* [ [ cleanupNumericValues](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) ] округление дробных чисел до заданной точности, удаление `px` как единицы измерения по-умолчанию | ||
* [ [ cleanupListOfValues](https://github.com/svg/svgo/blob/master/plugins/cleanupListOfValues.js) ] округление числовых значений в атрибутах со списком чисел, таких как `viewBox` или `enableBackground` | ||
* [ [ moveElemsAttrsToGroup](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] перемещение совпадающих атрибутов у всех элементов внутри группы `<g>` | ||
@@ -49,0 +50,0 @@ * [ [ moveGroupAttrsToElems](https://github.com/svg/svgo/blob/master/plugins/moveGroupAttrsToElems.js) ] перемещение некоторых атрибутов группы на элементы внутри |
151
325708
8494
+ Addedcsso@1.8.2(transitive)
+ Addedsax@1.2.4(transitive)
- Removedcsso@1.6.4(transitive)
- Removedsax@1.1.6(transitive)
Updatedcsso@~1.8.1
Updatedjs-yaml@~3.5.5
Updatedsax@~1.2.1