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

Disable sax-js strict mode #305

Closed
wants to merge 1 commit into from
Closed

Disable sax-js strict mode #305

wants to merge 1 commit into from

Conversation

mhoffmeyerDC
Copy link

This is disabled by default in sax-js, and by their own admission makes sax-js a jerk. Having it enabled also causes bugs like #225 and #272 - breaking svgo entirely for SVG exported from Illustrator with certain settings. Seems more prudent to let some things 'slip by' with strict mode disabled rather than fail entirely.

This is disabled by default in sax-js, and [by their own admission](https://github.com/isaacs/sax-js) makes sax-js a jerk. Having it enabled also causes bugs like [#225](#225) and [#272](#272) - breaking svgo entirely for SVG exported from Illustrator with certain settings. Seems more prudent to let some things 'slip by' with strict mode disabled rather than fail entirely.
@aidansteele
Copy link
Contributor

Why was this closed?

@mhoffmeyerDC
Copy link
Author

Disabling strict mode broke many of the tests, I think it caused some rounding errors in the SVG.

@aidansteele
Copy link
Contributor

Thanks for such a quick response. Is there a solution on the horizon for the issues linked in the PR?

@mhoffmeyerDC
Copy link
Author

The original issue I was having was svgo failing over an SVG with the Adobe Illustrator "preserve editing capabilities" mode enabled . It had some weird namespace convention or character that made sax-js, in strict mode, fail. I guess another solution would be to use a regex to check for that string that sax doesn't like and replace it or delete it.

@aidansteele
Copy link
Contributor

I would suggest that such a regex-stripping solution could be implemented as a plugin, but plugins appear to be executed after sax-js rejects the file.

Given the "hackiness" of a such a regex solution, it still seems like it should be a plugin rather than core functionality - maybe the plugin architecture could be enhanced to support plugins running earlier in the pipeline? I'd be happy to write a plugin to fix this issue, but changing the plugin architecture might be better suited to someone more familiar with the codebase.

@eitanp461
Copy link

+1
I am trying to optimize SVGs created wihj Adobe illustrator and the entity references cause sax to fail, i.e. <path style="&st0;" .../>.
Is there any workaround?

@GreLI
Copy link
Member

GreLI commented Apr 13, 2015

The workaround is to save images in Illustrator with disabled options like “Preserve editing capabilities” (they don't make sense anyway if you are passing that images to svgo). Or it's possible to replace entities with their value manually, but it's suits better if you have only one or few images.

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

Successfully merging this pull request may close these issues.

4 participants