clean-html icon indicating copy to clipboard operation
clean-html copied to clipboard

Self-closing path has slash/closing tag stripped

Open kate-hall opened this issue 6 years ago • 3 comments

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="...">.

kate-hall avatar Jul 24 '18 16:07 kate-hall

I can confirm the same issue

tujoworker avatar Aug 22 '18 05:08 tujoworker

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/>?

dave-kennedy avatar Sep 10 '18 07:09 dave-kennedy

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

kate-hall avatar Sep 10 '18 09:09 kate-hall

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.

dave-kennedy avatar Apr 07 '23 04:04 dave-kennedy