Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E-notated numbers in paths not recognised #63

Closed
sambeau opened this issue Dec 6, 2012 · 5 comments
Closed

E-notated numbers in paths not recognised #63

sambeau opened this issue Dec 6, 2012 · 5 comments
Assignees
Labels
Milestone

Comments

@sambeau
Copy link

sambeau commented Dec 6, 2012

I have files with e -numbers in them that are getting mangled:

<path d="M 185,-3.05176e-005L 207,-3.05176e-005C 209.761,-3.05176e-005 212,2.23853 212,4.99997L 212,27C 212,29.7614 209.761,32 207,32L 185,32C 182.239,32 180,29.7614 180,27L 180,4.99997C 180,2.23853 182.239,-3.05176e-005 185,-3.05176e-005 Z " fill-rule="nonzero" fill-opacity="0" stroke="#000000" stroke-opacity="1" stroke-width="1" />

becomes:

<path d="M185 NaNl-190 NaN 212 NaN-212 NaN 7.239 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaNz" fill-opacity="0" stroke="#000"/>

see: http://www.w3.org/TR/SVG/types.html#DataTypeNumber

number ::= integer ([Ee] integer)?
           | [+-]? [0-9]* "." [0-9]+ ([Ee] integer)?
@sambeau
Copy link
Author

sambeau commented Dec 6, 2012

Here's the problem, I think!

https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js

var regNumericValues = /^([\-+]?\d*\.?\d+)(px|pt|pc|mm|cm|m|in|ft|em|ex|%)?$/,

@ghost ghost assigned deepsweet Dec 6, 2012
@deepsweet
Copy link
Member

i got it, thank you! trying to fix.

@deepsweet
Copy link
Member

appeared in v0.1.5, please update.

@sambeau
Copy link
Author

sambeau commented Dec 7, 2012

That seems to have fixed everything, thanks!

Here are my results:
~40% reduction on my bigger files. Very impressive.

tall.svg:
0.366 KiB - 3.2% = 0.354 KiB

test_1.svg:
1 KiB - 39.1% = 0.609 KiB

test_10.svg:
16.464 KiB - 30% = 11.526 KiB

test_11.svg:
6.816 KiB - 41.7% = 3.976 KiB

test_12.svg:
2.434 KiB - 34.3% = 1.6 KiB

test_13.svg:
2.283 KiB - 39.6% = 1.379 KiB

test_14.svg:
1.168 KiB - 40.4% = 0.696 KiB

test_15.svg:
1.52 KiB - 37.6% = 0.948 KiB

test_16.svg:
1.145 KiB - 38.8% = 0.7 KiB

test_17.svg:
5.179 KiB - 43.7% = 2.916 KiB

test_19.svg:
8.062 KiB - 33.2% = 5.383 KiB

test_2.svg:
1.084 KiB - 40.8% = 0.642 KiB

test_20.svg:
2.192 KiB - 56.3% = 0.957 KiB

test_21.svg:
1.995 KiB - 46.7% = 1.063 KiB

test_22.svg:
3.914 KiB - 35.5% = 2.524 KiB

test_3.svg:
8.688 KiB - 52% = 4.171 KiB

test_4.svg:
3.184 KiB - 36.1% = 2.034 KiB

test_5.svg:
5.287 KiB - 33.4% = 3.523 KiB

test_6.svg:
7.733 KiB - 52.3% = 3.687 KiB

test_7.svg:
2.738 KiB - 39.3% = 1.662 KiB

wide.svg:
0.367 KiB - 3.2% = 0.355 KiB

test_9.svg:
12.55 KiB - 34.8% = 8.188 KiB

test_0.svg:
101.75 KiB - 41.2% = 59.837 KiB

test_18.svg:
109.01 KiB - 40.8% = 64.538 KiB

test_8.svg:
850.881 KiB - 46.3% = 457.088 KiB

@deepsweet
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants