Hey! I have an HTML SVG object as a string and I want to create the appropriate layers from that string. Is there a recommended way or the only solution is to parse and identify tags separately?
Thanks for the reference! Are there any plans to add an API for this functionality?
One solution to walk around this issue is to manually parse the SVG elements, but it would be painful
I agree that this would be painful. While I don’t know of any current work on such APIs (although folks from Adobe will have to answer this, there’s nothing on the roadmap), as a fallback, the suggestion by @kerrishotts in the feature request about copying the SVG to the clipboard via
require('clipboard').copyText(svg) might be a bit more realistic than trying to parse the SVG manually. I don’t know how complex your SVGs are, but I wouldn’t want to have to work on parsing this to XD . This at least ensures not having to update an SVG parser as XD’s capabilities grow…
On the other hand (trying to encourage open-source work around the ecosystem ), a community-driven open-source library for this task could be a cool thing that might be useful to many. If the community were up to it (maybe, someone has already tried doing something like this and could contribute his/her code as a start), with a few people finding it useful and willing to contribute (count me in ), it might be feasible…