Jump to content
Friksel

[AD] Designer changes layernames that start with a number when exporting to svg ids [SEEMS TO BE RIGHT AFTERALL!]

Recommended Posts

When layernames in Affinity Designer start with a number, in the SVG export Affinity decided to add an underscore ('_') as prefix to all these ids of these svg elements.

This is pretty unwanted behaviour, because we named these layers this way on purpose and want to have the same names in the export as we gave the layers. We don't want names and therefore the svg elements' ids to be changed under the hood. I can't find any good reason why Affinity should change these names;  numbers in ID attributes of svg elements are perfectly fine and allowed. Even id's with only numbers in ids are allowed in html/svg.

Because of this unwanted name change we have to rename hundred or so layers in some files by hand now and then filter out numbers from the changed layernames when using the svg at runtime by javascript again. That's not really convenient and not very efficient and in my opinion unnececary.

I understand that sometimes renaming during svg export could be nececary when layernames would result in illegal ids, but this is not one of those cases.

Please, would it be possible for Serif to remove this unwanted and unnececary renaming in the svg output?


 

Share this post


Link to post
Share on other sites

I don't know if it's relevant to this discussion or that behavior, but in HTML4 ID values must  start with an alphabetic character. Only in HTML5 did it become valid to have an ID value that starts with a numeric.


-- Walt

Windows 10 Home, version 2004 (19041.388),
   Desktop: 16GB memory, Intel Core i7-6700K @ 4.00GHz, GeForce GTX 970
   Laptop:  8GB memory, Intel Core i7-3625QM @ 2.30GHz, Intel HD Graphics 4000 or NVIDIA GeForce GT 630M
Affinity Photo 1.8.5.703 and 1.9.0.734 Beta   / Affinity Designer 1.8.5.703 and 1.9.0.734 Beta  / Affinity Publisher 1.8.5.703 and 1.9.0.742 Beta.

Share this post


Link to post
Share on other sites
53 minutes ago, walt.farrell said:

I don't know if it's relevant to this discussion or that behavior, but in HTML4 ID values must  start with an alphabetic character. Only in HTML5 did it become valid to have an ID value that starts with a numeric.

Good one @walt.farrell. Thanks for that. I didn't know there were differences between naming conventions for IDs between HTML4 and HTML5.

That said, we're not dealing with html4 nor html5, but svg spec, so I'm not sure which rules they use (didn't find it yet because the spec documents aren't always easy to follow with all kind of sublinks and all). But if they decided to take id-naming-rules like html4.0.1 in the svg 1.1 spec, then still the svg export renaming of Designer isn't right, because in html4 it wasn't allowed to start with an underscore, because it had to start with an alphabetical character. At least according to this: html4 vs html5 ids and classes

Also, not only is HTML4 stone age in internet-ages and no new website build last years should be build in html5, chances are pretty small that people working with SVG on websites now will use the svg inside a HTML4 doc. And even if they do browsers nowadays will probably accept id's by the much more flexible html5 rules anyway and be pretty forgiving.

The freedom of characters in ids is actually pretty great in html5: there are some keywords and little characters (like '#', spaces, '.' and some others ofcoarse) we are not allowed to use, but next to that almost everything is allowed, even pretty weird characters.


 

Share this post


Link to post
Share on other sites
17 minutes ago, Friksel said:

That said, we're not dealing with html4 nor html5, but svg spec, so I'm not sure which rules they use (didn't find it yet because the spec documents aren't always easy to follow with all kind of sublinks and all).

Good point. I, also, had not yet found the right SVG specification.

Searching further, from the SVG 2 specification:

Quote

A stand-alone SVG document uses XML 1.0 syntax [xml], which specifies that valid id values are XML name tokens. Valid XML 1.0 names only include designated characters (letters, digits, and a few punctuation marks), and do not start with a digit, a full stop (.) character, or a hyphen-minus (-) character.

 


-- Walt

Windows 10 Home, version 2004 (19041.388),
   Desktop: 16GB memory, Intel Core i7-6700K @ 4.00GHz, GeForce GTX 970
   Laptop:  8GB memory, Intel Core i7-3625QM @ 2.30GHz, Intel HD Graphics 4000 or NVIDIA GeForce GT 630M
Affinity Photo 1.8.5.703 and 1.9.0.734 Beta   / Affinity Designer 1.8.5.703 and 1.9.0.734 Beta  / Affinity Publisher 1.8.5.703 and 1.9.0.742 Beta.

Share this post


Link to post
Share on other sites
14 minutes ago, walt.farrell said:

A stand-alone SVG document uses XML 1.0 syntax [xml], which specifies that valid id values are XML name tokens. Valid XML 1.0 names only include designated characters (letters, digits, and a few punctuation marks), and do not start with a digit, a full stop (.) character, or a hyphen-minus (-) character.

I believe we just came to the same conclusion. I found the svg 1.1 spec here:

https://www.w3.org/TR/2008/REC-xml-20081126/#attdecls

But I think it's pretty difficult to follow at this point. But I found this in the spec:

Quote

Values of type ID MUST match the Name production. A name MUST NOT appear more than once in an XML document as a value of this type; i.e., ID values MUST uniquely identify the elements which bear them.

So they refer to the Name production, which is here:

https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name

Where these seems to be the rules for ID-names in svg 1.1:

rules.JPG.bf98ec12ccc63aa457cf09afef986091.JPG

Where it indeed looks like we are allowed to use underscores ('_') and capital or lowercase alphabetical characters and some other chars, and even a ':'. But no number to start the ID with.

So if I understand this document right the way Designer works right now is the right way indeed.

Bummer... I have hundreds of logo's that need to be called by their ID-numbers and it would make more sense to me putting them as just plain numbers under the 'logos' group instead of things like 'logo01', 'logo02' and so on.

But if this is the way the spec works... this is the way the spec works and at least Designer is exporting the right way as it seems! That's great to know!

Thanks for your help again @walt.farrell !

 


 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

Please note the Annual Company Closure section in the Terms of Use. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.