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

Incompatible with some SVGO output #1

Closed
fregante opened this issue Dec 6, 2014 · 3 comments
Closed

Incompatible with some SVGO output #1

fregante opened this issue Dec 6, 2014 · 3 comments

Comments

@fregante
Copy link

fregante commented Dec 6, 2014

This path is reported as "malformed path data", but hughsk/svg-path-parser parses it without errors

M.157 15.32c-.105-.1-.157-.18-.157-.23 0-.057.063-.147.19-.262.595-1.882 5.684-8.786 14.875-8.786 9.798 0 14.935 7.846 14.935 9.09 0 1.244-5.137 9.09-14.935 9.09-9.39 0-14.5-7.207-14.908-8.902zm0 0c.93.895 5.97 3.49 14.778 3.49 9.798 0 14.935-3.21 14.935-3.72 0-.51-5.137-3.72-14.935-3.72-8.71 0-13.737 2.537-14.746 3.458-.04.124-.06.227-.06.304 0 .052.01.115.027.188z
@soswow
Copy link

soswow commented Jul 31, 2015

Yeah, when I read http://www.w3.org/TR/SVG/paths.html#PathData I understood it's not as simple and decided to look for solution that can handle exactly this example )

@Sphinxxxx
Copy link

The problem is that the regex in parseValues() gets confused by decimal numbers with no spaces between, e.g. .052.01.115.027.188. I propose two alternatives to fix this:

  1. Before the regex matching, alter the input string to add a space between such numbers: args = args.replace(/(\.\d+)(?=\.)/g, '$1 ');
  2. Change the regex pattern itself (tested only with @bfred-it's example): args = args.match(/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig);

Test: https://jsfiddle.net/b28cu6ac/

@jkroso
Copy link
Owner

jkroso commented Mar 13, 2016

I'd favour option 2

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

No branches or pull requests

4 participants