svgo: [Bug]Path compression lost space

Original svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 1125">
    <path d="M448.6,997.7c.2,5.6,16.6,9.4,36.5,8.4s35.8-6.2,35.5-11.8a1.7,1.7,0,0,0-.1-.7c-1.5-5.2-17.3-8.6-36.4-7.7s-34.4,5.8-35.5,11.1Z" fill="green" />
</svg>

After svgo compression, the spaces are removed, and an error will be reported:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 750 1125">
    <path d="M448.6 997.7c.2 5.6 16.6 9.4 36.5 8.4s35.8-6.2 35.5-11.8a1.7 1.7 0 00-.1-.7c-1.5-5.2-17.3-8.6-36.4-7.7s-34.4 5.8-35.5 11.1z" fill="green" />
</svg>

Use svgcleaner

<svg viewBox="0 0 750 1125" xmlns="http://www.w3.org/2000/svg">
  <path d="m448.6 997.7c.2 5.6 16.6 9.4 36.5 8.4s35.8-6.2 35.5-11.8a1.7 1.7 0 0 0 -.1-.7c-1.5-5.2-17.3-8.6-36.4-7.7s-34.4 5.8-35.5 11.1z" fill="#008000"/>
</svg>

00-.1 Spaces are required here.

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 18 (14 by maintainers)

Most upvoted comments

In fact, the compressed SVG has a very subtle position change in the browser. Re importing sketch will also have problems. We should ensure good compatibility in non browser environments.