You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we put them in one document, the second svg won't display correctly, because there are two g elements with the same id. Could you consider adding an option that allow people to add a prefix to the id attribute in a svg?
The text was updated successfully, but these errors were encountered:
There's already a similar feature request (#234). It's on my list but not of very high priority because you can post-process the SVG files and replace the IDs with your own ones or just prefix them, e.g. with a short Python script or sed.
A proper implementation in dvisvgm is not that easy and requires quite a few changes. So, I'm afraid, this won't be implemented in the next few releases.
Understood, and will look for some alternate options, but just for the record, and to make sure I am following this issue, I will mention that I also have this issue.
in case anyone is using typescript for this kind of thing, here is a function I have found to work:
addRandomPrefixToIds(svgStr: string){functiongenerateRandomPrefix(){letletters="abcdefghijklmnopqrstuvwxyz";letters+=letters.toUpperCase();letprefix="";for(leti=0;i<4;i++){prefix+=letters[Math.floor(Math.random()*letters.length)];}returnprefix;}// Generate a random 4-letter prefixconstrandomPrefix=generateRandomPrefix();// Replace the id substringsletupdatedSvgStr=svgStr.toString().replace(/xlink:href='#g/g,`xlink:href='#g${randomPrefix}`);updatedSvgStr=updatedSvgStr.toString().replace(/<path id='g/g,`<path id='g${randomPrefix}`);returnupdatedSvgStr;}
Consider the following two svg:
If we put them in one document, the second svg won't display correctly, because there are two
g
elements with the same id. Could you consider adding an option that allow people to add a prefix to the id attribute in a svg?The text was updated successfully, but these errors were encountered: