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

Issue with self closing element when the generated svg is embedded in html #16

Closed
ghost opened this issue Jan 8, 2019 · 5 comments
Closed

Comments

@ghost
Copy link

ghost commented Jan 8, 2019

When the generated SVG is put into an HTML document and served into a browser, many browsers will autocorrect the markup. They will find tags that are not permitted to use />, and will automatically insert a closing tag.

E.g. becomes when loaded in an HTML page in Google Chrome.

Is it possible to disable the short version and force a verbose output ?

Edit: I'm using the to_string() method of Document to convert into string

@IvanUkhov
Copy link
Member

IvanUkhov commented Jan 8, 2019

I believe the logic can be seen here. There is no way to configure this at this point.

@crabmusket
Copy link

crabmusket commented Mar 18, 2021

For future reference, here's the correct permalink where the self-closing formatting can be found:

return write!(formatter, "/>");

@IvanUkhov
Copy link
Member

Thank you for the correction. Right, one would have to distinguish two cases there: permitted to close without a closing tag or not, depending on the element. To this end, perhaps Element should be extended with some flags to communicate more about how each element behaves.

@IvanUkhov
Copy link
Member

Can anybody please provide a link to the spec that shows that certain tags are not permitted to be self-closing? If the current behavior is in accordance with the specification, nothing has to be changed.

@IvanUkhov
Copy link
Member

I leave this one as a reference and close this issue:

https://stackoverflow.com/questions/24299969/closing-svg-tags-explicit-or-self-closing

Please shout if there is a contradicting and more reliable reference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants