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

Minification breaks/distorts a SVG path #269

Closed
anthonyfok opened this issue Nov 5, 2019 · 4 comments
Closed

Minification breaks/distorts a SVG path #269

anthonyfok opened this issue Nov 5, 2019 · 4 comments

Comments

@anthonyfok
Copy link
Contributor

@Arty2 reported at gohugoio/hugo#6475:

An inline SVG is modified (and broken) by the minifier.
See the following after .005-.372:

Original:

<svg xmlns="http://www.w3.org/2000/svg" height="0.8rem" viewBox="0 0 3.375 2.912"><path stroke-width="0" d="M.166.1L.1.63s.417.054 1.355.063c.01.22.018.471.018.797 0 .056-.002.08-.003.132h-.397l.002-.133c0-.144-.003-.252-.005-.372a16.062 16.062 0 01-.53-.023c.003.128.006.246.006.396 0 .738-.03 1.123-.05 1.322.139-.01.32-.017.539-.023.011-.138.022-.358.03-.637h.395c-.01.286-.024.508-.035.63l.263-.002c.106 0 .178.003.273.004.019-.23.04-.592.04-1.294 0-.335-.007-.582-.015-.798.135-.002.282-.003.394-.006.01.221.018.475.018.804 0 .72-.028 1.096-.047 1.3.217.005.397.013.534.022.02-.23.043-.598.043-1.322 0-.35-.008-.606-.017-.828.245-.016.364-.032.364-.032L3.209.1s-.53.066-1.521.066C.696.167.166.1.166.1z"/></svg>

Minified:

<svg xmlns="http://www.w3.org/2000/svg" height=".8rem" viewBox="0 0 3.375 2.912"><path stroke-width="0" d="M.166.1.1.63s.417.054 1.355.063c.01.22.018.471.018.797.0.056-.002.08-.003.132h-.397l.002-.133c0-.144-.003-.252-.005-.372.003.128.006.246.006.396.0.738-.03 1.123-.05 1.322.139-.01.32-.017.539-.023.011-.138.022-.358.03-.637h.395c-.01.286-.024.508-.035.63l.263-.002c.106.0.178.003.273.004.019-.23.04-.592.04-1.294.0-.335-.007-.582-.015-.798.135-.002.282-.003.394-.006.01.221.018.475.018.804.0.72-.028 1.096-.047 1.3.217.005.397.013.534.022.02-.23.043-.598.043-1.322.0-.35-.008-.606-.017-.828.245-.016.364-.032.364-.032L3.209.1s-.53.066-1.521.066C.696.167.166.1.166.1z"></path></svg>

I was able to reproduce what @Arty2 is seeing with the minify CLI tool, v2.5.2 and v2.3.8, and for my curiosity sake, here is a screenshot of the above SVGs:

Original Minified
original minified

Many thanks!

@tdewolff
Copy link
Owner

tdewolff commented Nov 5, 2019

Looks like the a command is entirely removed. I think the problem is that the coordinates for the a command are 16.062 16.062 0 01-.53-.023, where the largeArc and sweep booleans are joined as 01 which is interpreted as a number 1. I wasn't aware it is valid SVG syntax to join both booleans like that. Looks like it is allowed indeed: https://www.w3.org/TR/SVG/paths.html#PathDataBNF

I will work on incorporating this, thanks for bringing it up!

@tdewolff
Copy link
Owner

tdewolff commented Nov 6, 2019

Fixed with 0ad8cf4, 5522f26, 8555c8c

I will release a new version of minify soon, need to do some more testing.

@MeiK2333
Copy link

@tdewolff Do you have any plans to release the version recently?

@tdewolff
Copy link
Owner

Yes, but it needs to wait on some other changes I want to push through that need more testing (I fixed an urgent bug yesterday of the changes above in 75ac1f1). Hopefully in a weeks time I can release a new version.

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

3 participants