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

should keep unicode space char #1150

Closed
jaylecn opened this issue Sep 10, 2019 · 7 comments
Closed

should keep unicode space char #1150

jaylecn opened this issue Sep 10, 2019 · 7 comments

Comments

@jaylecn
Copy link

jaylecn commented Sep 10, 2019

input

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="500">
<text fill="#000000" stroke="none" font-family="sans-serif" font-size="10px" font-style="normal" font-weight="normal" text-decoration="normal" x="20" y="20" text-anchor="start" dominant-baseline="alphabetic">
test&#160;spaces&#160;&#160;&#160;😑&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;end
</text></svg>

output

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="400" height="500"><text fill="#000000" stroke="none" font-family="sans-serif" font-size="10px" font-style="normal" font-weight="normal" text-decoration="normal" x="20" y="20" text-anchor="start" dominant-baseline="alphabetic">test spaces 😑 end</text></svg>

i want keep spaces, but even i use unicode space char, it's still removed, bug ?

@GreLI
Copy link
Member

GreLI commented Sep 12, 2019

It's a parser issue, SVGO uses https://github.com/isaacs/sax-js parser, and as XML parser it eats spaces.

@jaylecn
Copy link
Author

jaylecn commented Sep 14, 2019

it's latest commit on 2017 😶 any solution? fix sax-js ?

@KrasnayaPloshchad
Copy link

Sax-js is no longer maintained after version 1.2.7 released, but I discovered a fork of this parser in their issues. This is under active maintaince, but has some differences than original one.
https://github.com/lddubeau/saxes

@strarsis
Copy link
Contributor

strarsis commented Sep 6, 2020

@KrasnayaPloshchad: So it wouldn't be that hard to replace sax.js with saxes?
When it is more or less just a drop-in replacement I could give it a try.

PR: #1281

@KrasnayaPloshchad
Copy link

KrasnayaPloshchad commented Sep 8, 2020

I think yes. But if there is regression bring by saxes itself that is impossible to fix by pull request, or saxes developer have no idea for what you need to fix, you can try other alternates anyway.

@strarsis
Copy link
Contributor

strarsis commented Sep 8, 2020

Edit: The txml parser is an excellent candidate for which a PR is ready!

@SethFalco
Copy link
Member

This was not an issue in sax, and rather was a configuration issue on our end. A contributor corrected this for us, and the fix was released in SVGO v2.1.0:

The optimizing the SVG works as expected in SVGO v3.2.0.

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

5 participants