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

htmlmin produces invalid inline SVG #19

Closed
alefteris opened this issue Apr 11, 2013 · 3 comments
Closed

htmlmin produces invalid inline SVG #19

alefteris opened this issue Apr 11, 2013 · 3 comments

Comments

@alefteris
Copy link

This is the original SVG in my HTML:

<body>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20">
    <rect width="20" height="3" y="2" fill="#fff"/>
    <rect width="20" height="3" y="8.5" fill="#fff"/>
    <rect width="20" height="3" y="15" fill="#fff"/>
</svg>
</body>

And here is the result after htmlmin:

<body>
<svg xmlns="http://www.w3.org/2000/svg" width=20 height=20>
    <rect width=20 height=3 y=2 fill="#fff">
    <rect width=20 height=3 y=8.5 fill="#fff">
    <rect width=20 height=3 y=15 fill="#fff">
</svg>

The SVG will not display properly any more (only the first rect is displayed). If I add ending slashes in the rect elements, it will display property, but it's still not valid SVG.

So maybe htmlmin should not removeAttributeQuotes and slashes at least or generally not minimize inline SVGs at all?

Also, is there an option to disable the removal of the slashes? Or I'll have to not use htmlmin all all?

@sindresorhus
Copy link
Member

From readme:

Minifies HTML using html-minifier. Bugs regarding the output should be reported here.

^ html-minifier shouldn't touch SVG. If you can't find an existing ticket, create a new one there.

@alefteris
Copy link
Author

Sorry about that, reported it at kangax/html-minifier#45

@Soviut
Copy link

Soviut commented Mar 10, 2014

This issue has been solved by adding an option to keepClosingSlash for singleton tags. The PR exists here kangax/html-minifier#122

I've opened another issue to add support for this option to grunt-contrib-htmlmin here #58

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