-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix entities in SVG download #1130
Conversation
Otherwise any tree with such nodes will fail when exporting/downloading as SVG (which doesn't recognize most mnemonic HTML entities).
This should be a safer path for SVG in data URIs.
This reverts commit f5b959f.
Should we need to explore heavier client-side libraries for decoding/encoding HTML entities to XML-compatible numeric entities, one promising option is https://www.npmjs.com/package/html-entities |
Doesn't seem to work for me. I tried this tree which gives the same error as before. Clicking on the utton in Safari brings up this new page: |
@josephwb These are working for me on devtree. Please try again after clearing your browser's cache. (This can be difficult in Safari. What version are you running?) UPDATE: Hmm, I'm having trouble in Safari here too. Checking now for old script vs. bad logic... |
Ah, okay, I too can not get it to work on Safari. Works fine in Opera if that helps. |
Thanks, it looks like XMLSerializer works differently in Safari, preserving HTML entities like |
Sounds like a bug in Safari XMLSerializer . The only mention of it I found was pbakaus/domvas#11 which is rather muted. I wonder whether there is a good way to report it. |
Not so much a bug as a subtle but intended behavior, apparently. The doctype of the chosen node's parent document (in this case, the surrounding web page) is used to determine how entities are treated, as described in this WebKit test. In short, if the parent doctype is XHTML, serialization will use HTML entities that will fail in "vanilla" XML documents. Since This works for me on devtree, including in Safari, for both my preferred tree and the one @josephwb is attempting to use. I'll keep testing in other browsers, but please let me know if you see more failures on devtree! UPDATE: Both trees linked above work for me in Firefox, Chrome, and Safari. |
We've had some problems with unsupported HTML entities (typically
) in our SVG output. See this related Gitter chat for details.This change serializes the main SVG node to Unicode, which removes all entities entirely, then relies on Base64 to encode all characters in the data URI. This is working and tested on devtree, see for example this tree with unlabeled internal nodes. This should download and print with no problems. Also note that I've added some diacritical marks and challenging punctuation in the topmost tip's label
Mycôsphærëlla "zoomer" >!;
. The new solution seems to handle these characters just fine.