Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
2 parents 1640958 + 11e5bf7 commit c4616cae3b3b9824112888408649e0641d00a04a @deepsweet deepsweet committed Nov 30, 2012
Showing with 1,811 additions and 556 deletions.
  1. +3 −0 .jshintignore
  2. +2 −1 .jshintrc
  3. +5 −1 .svgo.yml
  4. +27 −12 CHANGELOG.md
  5. +9 −9 README.md
  6. +2 −0 examples/fromFile.js
  7. +2 −0 examples/fromStream.js
  8. +2 −0 examples/fromString.js
  9. +2 −0 lib/svgo.js
  10. +2 −0 lib/svgo/coa.js
  11. +2 −0 lib/svgo/config.js
  12. +2 −0 lib/svgo/js2svg.js
  13. +2 −0 lib/svgo/jsAPI.js
  14. +2 −0 lib/svgo/plugins.js
  15. +2 −0 lib/svgo/svg2js.js
  16. +28 −7 lib/svgo/tools.js
  17. +5 −0 logo.svg
  18. BIN logo200x200.png
  19. +3 −2 package.json
  20. +1,511 −424 plugins/_collections.js
  21. +2 −0 plugins/cleanupAttrs.js
  22. +3 −2 plugins/cleanupEnableBackground.js
  23. +47 −0 plugins/cleanupNumericValues.js
  24. +2 −0 plugins/cleanupSVGElem.js
  25. +3 −2 plugins/collapseGroups.js
  26. +2 −0 plugins/convertColors.js
  27. +34 −7 plugins/convertPathData.js
  28. +3 −2 plugins/convertStyleToAttrs.js
  29. +8 −4 plugins/convertTransform.js
  30. +4 −3 plugins/moveElemsAttrsToGroup.js
  31. +3 −2 plugins/removeComments.js
  32. +0 −26 plugins/removeDefaultPx.js
  33. +3 −2 plugins/removeDoctype.js
  34. +3 −2 plugins/removeEditorsNSData.js
  35. +3 −2 plugins/removeEmptyAttrs.js
  36. +3 −2 plugins/removeEmptyContainers.js
  37. +2 −0 plugins/removeEmptyText.js
  38. +2 −0 plugins/removeHiddenElems.js
  39. +3 −2 plugins/removeMetadata.js
  40. +28 −17 plugins/removeUnknownsAndDefaults.js
  41. +3 −2 plugins/removeUnusedNS.js
  42. +3 −2 plugins/removeViewBox.js
  43. +3 −2 plugins/removeXMLProcInst.js
  44. +2 −0 test/config/_index.js
  45. +2 −0 test/plugins/_index.js
  46. +3 −0 test/plugins/cleanupNumericValues.01.orig.svg
  47. +3 −0 test/plugins/cleanupNumericValues.01.should.svg
  48. +1 −0 test/plugins/convertPathData.03.orig.svg
  49. +2 −1 test/plugins/convertPathData.03.should.svg
  50. +1 −1 test/plugins/convertPathData.07.should.svg
  51. +4 −4 test/plugins/convertTransform.01.orig.svg
  52. +6 −6 test/plugins/convertTransform.01.should.svg
  53. +1 −1 test/plugins/convertTransform.03.should.svg
  54. +2 −0 test/plugins/convertTransform.04.orig.svg
  55. +2 −0 test/plugins/convertTransform.04.should.svg
  56. +0 −3 test/plugins/removeDefaultPx.01.orig.svg
  57. +0 −3 test/plugins/removeDefaultPx.01.should.svg
  58. +2 −0 test/svg2js/_index.js
View
@@ -0,0 +1,3 @@
+node_modules/
+lib-cov/
+html-report/
View
@@ -6,7 +6,8 @@
"it": false
},
"node": true,
- "strict": false,
+ "globalstrict": true,
+ "expr": true,
"curly": false,
"camelcase": true,
"eqeqeq": true,
View
@@ -32,9 +32,13 @@ plugins:
active: true
type: perItem
- - name: removeDefaultPx
+ - name: cleanupNumericValues
active: true
type: perItem
+ params:
+ floatPrecision: 3
+ leadingZero: true
+ defaultPx: true
- name: removeUnknownsAndDefaults
active: true
View
@@ -1,16 +1,31 @@
-### [ [>](//github.com/svg/svgo/tree/v0.1.2) ] 0.1.2 / 24.11.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.1.3) ] 0.1.3 / 30.11.2012
+* new plugin [plugins/cleanupNumericValues](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) (close [#8](https://github.com/svg/svgo/issues/8))
+* plugins/removeDefaultPx functionality now included in plugins/removeUnknownsAndDefaults
+* plugins/removeUnknownsAndDefaults: refactoring and picking up the complete elems+attrs collection (close [#59](https://github.com/svg/svgo/issues/59))
+* plugins/convertTransform: error in matrices multiplication (fix [#58](https://github.com/svg/svgo/issues/58))
+* plugins/convertTransform: mark translate() and scale() as useless only with one param (fix [#57](https://github.com/svg/svgo/issues/57))
+* plugins/convertPathData: drastic speed improvement with huge Path data
+* plugins/convertPathData: fix the very first Mm with multiple points (fix [#56](https://github.com/svg/svgo/issues/56))
+* plugins/moveElemsAttrsToGroup: additional check for transform attr
+* brand-new project `logo.svg`
+* `.travis.yml`: build only master branch
+* global `'use strict'`
+* `.jshintignore`
+* README and CHANGELOG: minor corrections
+
+### [ [>](https://github.com/svg/svgo/tree/v0.1.2) ] 0.1.2 / 24.11.2012
* lib/svgo/svg2js: correct 'onerror' failure (fix [#51](https://github.com/svg/svgo/issues/51))
* config: disable sax-js position tracking by default (fix [#52](https://github.com/svg/svgo/issues/52))
* lib/svgo: rename 'startBytes' to 'inBytes' and 'endBytes' to 'outBytes' (close [#53](https://github.com/svg/svgo/issues/53))
* plugins/removeUnknownsAndDefaults: remove SVG id attr (close [#54](https://github.com/svg/svgo/issues/54))
-### [ [>](//github.com/svg/svgo/tree/v0.1.1) ] 0.1.1 / 23.11.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.1.1) ] 0.1.1 / 23.11.2012
* plugins/moveElemsAttrsToGroup: fix inheitable only attrs array (fix [#47](https://github.com/svg/svgo/issues/47))
* plugins/removeEmptyContainers: do not remove an empty 'svg' element (fix [#48](https://github.com/svg/svgo/issues/48))
* plugins/removeDefaultPx: should also understand a floating-numbers too (fix [#49](https://github.com/svg/svgo/issues/49))
* plugins/removeUnknownsAndDefaults: merge multiple groupDefaults attrs (close [#50](https://github.com/svg/svgo/issues/50))
-### [ [>](//github.com/svg/svgo/tree/v0.1.0) ] 0.1.0 / 22.11.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.1.0) ] 0.1.0 / 22.11.2012
* new plugin [plugins/removeUnknownsAndDefaults](https://github.com/svg/svgo/blob/master/plugins/removeUnknownsAndDefaults.js) (close [#6](https://github.com/svg/svgo/issues/6))
* plugins/convertPathData: convert straight curves into lines segments (close [#17](https://github.com/svg/svgo/issues/17)); remove an absolute coords conversions
* plugins/convertPathData: convert quadratic Bézier curveto into smooth shorthand (close [#31](https://github.com/svg/svgo/issues/31))
@@ -38,7 +53,7 @@
* update LICENSE with russian translation
* `.editorconfig`: 2 spaces for YAML
-### [ [>](//github.com/svg/svgo/tree/v0.0.9) ] 0.0.9 / 29.10.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.9) ] 0.0.9 / 29.10.2012
* [plugins how-to](https://github.com/svg/svgo/tree/master/plugins#readme) (close [#27](https://github.com/svg/svgo/issues/27))
* allow any plugin of any type to go in any order (close [#14](https://github.com/svg/svgo/issues/14))
* allow to do a multiple optimizations with one init (close [#25](https://github.com/svg/svgo/issues/25))
@@ -54,7 +69,7 @@
* plugins/collapseGroups: merge split-level transforms (fix [#13](https://github.com/svg/svgo/issues/13))
* jsdoc corrections
-### [ [>](//github.com/svg/svgo/tree/v0.0.8) ] 0.0.8 / 20.10.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.8) ] 0.0.8 / 20.10.2012
* new plugin [convertTransform](plugins/convertTransform.js) (close [#5](https://github.com/svg/svgo/issues/5))
* new plugin [removeUnusedNS](plugins/removeUnusedNS.js)
* plugins/convertPathData: remove useless segments
@@ -71,7 +86,7 @@
* update .editorconfig
* update .travis.yml with nodejs 0.9
-### [ [>](//github.com/svg/svgo/tree/v0.0.7) ] 0.0.7 / 14.10.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.7) ] 0.0.7 / 14.10.2012
* new plugin [convertPathData](plugins/convertPathData.js)
* --input data now can be a Data URI base64 string
* --output data now can be a Data URI base64 string with --datauri flag
@@ -82,33 +97,33 @@
* .svgo → config.json
* lib/phantom_wrapper.js → lib/phantom.js
-### [ [>](//github.com/svg/svgo/tree/v0.0.6) ] 0.0.6 / 04.10.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.6) ] 0.0.6 / 04.10.2012
* add --test option to make a visual comparison of two files (PhantomJS pre-required)
* update README and CHANGELOG with the correct relative urls
-### [ [>](//github.com/svg/svgo/tree/v0.0.5) ] 0.0.5 / 03.10.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.5) ] 0.0.5 / 03.10.2012
* every plugin now has [at least one test](plugins)
* removeViewBox, cleanupEnableBackground, removeEditorsNSData, convertStyleToAttrs and collapseGroups plugins fixes
* new --pretty option for the pretty printed SVG
* lib/config refactoring
-### [ [>](//github.com/svg/svgo/tree/v0.0.4) ] 0.0.4 / 30.09.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.4) ] 0.0.4 / 30.09.2012
* new plugin [removeViewBox](plugins/removeViewBox.js)
* new plugin [cleanupEnableBackground](plugins/cleanupEnableBackground.js)
* display useful info after successful optimization
* 'npm test' with 'spec' mocha output by default
-### [ [>](//github.com/svg/svgo/tree/v0.0.3) ] 0.0.3 / 29.09.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.3) ] 0.0.3 / 29.09.2012
* plugins/collapseGroups bugfix
* plugins/moveElemsAttrsToGroup bugfix
* svgo now display --help if running w/o arguments
* massive jsdoc updates
* plugins engine main filter function optimization
-### [ [>](//github.com/svg/svgo/tree/v0.0.2) ] 0.0.2 / 28.09.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.2) ] 0.0.2 / 28.09.2012
* add --disable and --enable command line options
* add an empty values rejecting to coa.js
* update README
-### [ [>](//github.com/svg/svgo/tree/v0.0.1) ] 0.0.1 / 27.09.2012
+### [ [>](https://github.com/svg/svgo/tree/v0.0.1) ] 0.0.1 / 27.09.2012
* initial public version
View
@@ -1,6 +1,6 @@
-![logo](https://raw.github.com/svg/svgo/master/logo200x200.png)
+<img src="http://soulshine.in/svgo/logo.svg?v3" width="200" height="200" alt="logo"/>
-## SVGO v0.1.2 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)
+## SVGO v0.1.3 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)
**SVG** **O**ptimizer is a Nodejs-based tool for optimizing SVG vector graphics files.
![](//mc.yandex.ru/watch/18431326)
@@ -22,20 +22,20 @@ Today we have:
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeMetadata.js) ] remove metadata
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEditorsNSData.js) ] remove editors namespaces, elements and attributes
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyAttrs.js) ] remove empty attributes
-* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeDefaultPx.js) ] remove default "px" unit
-* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeHiddenElems.js) ] remove a lot of hidden elements
+* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeHiddenElems.js) ] remove hidden elements
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyText.js) ] remove empty Text elements
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeEmptyContainers.js) ] remove empty Container elements
-* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeViewBox.js) ] remove viewBox attribute
-* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupEnableBackground.js) ] remove or cleanup enable-background attribute
+* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeViewBox.js) ] remove viewBox attribute when possible
+* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupEnableBackground.js) ] remove or cleanup enable-background attribute when possible
* [ [>](https://github.com/svg/svgo/blob/master/plugins/convertStyleToAttrs.js) ] convert styles into attributes
* [ [>](https://github.com/svg/svgo/blob/master/plugins/convertColors.js) ] convert colors (from rgb() to #rrggbb, from #rrggbb to #rgb)
* [ [>](https://github.com/svg/svgo/blob/master/plugins/convertPathData.js) ] convert Path data to relative, convert one segment to another, trim useless delimiters and much more
* [ [>](https://github.com/svg/svgo/blob/master/plugins/convertTransform.js) ] collapse multiple transforms into one, convert matrices to the short aliases and much more
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeUnknownsAndDefaults.js) ] remove unknown elements content and attributes, remove attrs with default values
* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeUnusedNS.js) ] remove unused namespaces declaration
+* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) ] round numeric values to the fixed precision, remove default 'px' units
* [ [>](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] move elements attributes to the existing group wrapper
-* [ [>](https://github.com/svg/svgo/blob/master/plugins/collapseGroups.js) ] collapse groups
+* [ [>](https://github.com/svg/svgo/blob/master/plugins/collapseGroups.js) ] collapse useless groups
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).
@@ -97,12 +97,12 @@ Arguments:
## TODO
-* [v0.1.3](https://github.com/svg/svgo/issues?milestone=5&state=open)
* [v0.1.4](https://github.com/svg/svgo/issues?milestone=6&state=open)
+* [v0.1.5](https://github.com/svg/svgo/issues?milestone=7&state=open)
## License and copyrights
This software is released under the terms of the [MIT license](https://github.com/svg/svgo/blob/master/LICENSE).
-Logo by [Yegor Bolshakov](http://xizzzy.ru/).
+Logo by [Yegor Bolshakov](http://xizzzy.ru/).
View
@@ -1,3 +1,5 @@
+'use strict';
+
var SVGO = require('../lib/svgo'),
svgo = new SVGO(/*{ custom config object }*/);
View
@@ -1,3 +1,5 @@
+'use strict';
+
var FS = require('fs'),
PATH = require('path'),
path = PATH.resolve(__dirname, '../examples/test.svg'),
View
@@ -1,3 +1,5 @@
+'use strict';
+
var SVGO = require('../lib/svgo'),
svgo = new SVGO(/*{ custom config object }*/);
View
@@ -1,3 +1,5 @@
+'use strict';
+
/**
* SVGO is a Nodejs-based tool for optimizing SVG vector graphics files.
*
View
@@ -1,3 +1,5 @@
+'use strict';
+
var FS = require('fs'),
QFS = require('q-fs'),
PATH = require('path'),
View
@@ -1,3 +1,5 @@
+'use strict';
+
var QFS = require('q-fs'),
PATH = require('path'),
YAML = require('yamljs'),
View
@@ -1,3 +1,5 @@
+'use strict';
+
var INHERIT = require('inherit'),
extend = require('./tools').extend;
View
@@ -1,3 +1,5 @@
+'use strict';
+
var INHERIT = require('inherit'),
extend = require('./tools').extend;
View
@@ -1,3 +1,5 @@
+'use strict';
+
/**
* Plugins engine.
*
View
@@ -1,3 +1,5 @@
+'use strict';
+
var Q = require('q'),
SAX = require('sax'),
JSAPI = require('./jsAPI');
View
@@ -1,3 +1,5 @@
+'use strict';
+
var datauriSVGPrefix = exports.datauriSVGPrefix = 'data:image/svg+xml;base64,';
/**
@@ -73,13 +75,7 @@ exports.cleanupOutData = function(data, params) {
// 0.5 → .5
// -0.5 → -.5
if (params.leadingZero) {
- if (item > 0 && item < 1) {
- item = ('' + item).slice(1);
- }
-
- if (item < 0 && item > -1) {
- item = '-' + ('' + item).slice(2);
- }
+ item = removeLeadingZero(item);
}
str += delimiter + item;
@@ -89,3 +85,28 @@ exports.cleanupOutData = function(data, params) {
return str;
};
+
+/**
+ * Remove floating-point numbers leading zero.
+ *
+ * @example
+ * 0.5.5
+ *
+ * @example
+ * -0.5-.5
+ *
+ * @param {Float} num input number
+ *
+ * @return {String} output number as string
+ */
+var removeLeadingZero = exports.removeLeadingZero = function(num) {
+
+ if (num > 0 && num < 1) {
+ num = ('' + num).slice(1);
+ } else if (num < 0 && num > -1) {
+ num = '-' + ('' + num).slice(2);
+ }
+
+ return num;
+
+};
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
Deleted file not rendered
View
@@ -1,6 +1,6 @@
{
"name": "svgo",
- "version": "0.1.2",
+ "version": "0.1.3",
"description": "Nodejs-based tool for optimizing SVG vector graphics files",
"keywords": [ "svgo", "svg", "optimize", "minify" ],
"homepage": "http://svg.github.com/svgo/",
@@ -33,7 +33,8 @@
},
"scripts": {
"test": "./node_modules/.bin/mocha --reporter spec --require should --recursive",
- "cover": "./node_modules/.bin/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib && ./node_modules/.bin/mocha --reporter mocha-istanbul --require should test/config test/svg2js"
+ "cover": "./node_modules/.bin/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib && ./node_modules/.bin/mocha --reporter mocha-istanbul --require should test/config test/svg2js",
+ "jshint": "jshint --show-non-errors ."
},
"dependencies": {
"sax": "~0.4",
Oops, something went wrong.

0 comments on commit c4616ca

Please sign in to comment.