dave-kennedy / clean-html

HTML cleaner and beautifier for Node
The Unlicense
47 stars 10 forks source link

Self-closing path has slash/closing tag stripped #16

Closed kate-hall closed 1 year ago

kate-hall commented 6 years ago

Edited for clarity.

For instance, <path d="..."/> becomes <path d="..."> (which is breaking, since the tag doesn't close).

Even <path d="..."> </path> becomes <path d="...">.

tujoworker commented 6 years ago

I can confirm the same issue

dave-kennedy commented 6 years ago

Sorry it's taken me a while to get around to looking at this. I'm a little rusty, so help me out. path is a void element, right? Is it somehow different from other void elements, in that it needs the closing slash? In other words, <br> and <br/> are the same, but not <path> and <path/>?

kate-hall commented 6 years ago

path is not a void element (SVG is not HTML). https://www.w3.org/TR/html/syntax.html#writing-html-documents-elements

It can be self-closing, but the self-closing needs to be explicit for SVG paths. This Stack Overflow thread might be helpful: https://stackoverflow.com/a/31120364/631345

dave-kennedy commented 1 year ago

I think this is a good use case for the new preserve-tags option added in 6a1cc0d, e.g. --preserve-tags math,svg.

I'll add those to the list of defaults.