Svgo: What options can change to hid prefix class of svg file?

Created on 29 Nov 2018  路  8Comments  路  Source: svg/svgo

2018-11-29 11 50 13

The className of text tag has named virtualBox_TextInSvg, but it carry a prefix that is filename after outputed, What should I do?

I want to keep the same classname in svgfile

2018-11-29 11 49 45

Most helpful comment

Is there a way to _only_ prefix IDs, but not classes? I have a case where the classes should stay as is, but IDs prefixed to avoid conflicts.

Since the config option is named prefixIds you'd think it would only affect IDs in the first place.

All 8 comments

svgo --disable=prefixIds should disable the prefixIds plugin that prefixes IDs + classes.

Is there a way to _only_ prefix IDs, but not classes? I have a case where the classes should stay as is, but IDs prefixed to avoid conflicts.

Since the config option is named prefixIds you'd think it would only affect IDs in the first place.

How to use prefix only for class ?

@litinskii: Hm, this would probably require code changes in the prefixIds plugin.
Only one method would have to be called then, addPrefixToClassAttr.
However, the other functions that handle attribute values like href have to skip the ID part, too.

@strarsis Thanks for answer. I'm asking this, because I'm trying to migrate from https://github.com/jkphl/svg-sprite, and there was an option like
image
(https://github.com/jkphl/svg-sprite/blob/master/docs/configuration.md)

and it was very useful, I mean allow to specify if you want to add namespace only for class for example.

I thinks it would be cool if we have some king of options for prefixIds plugin. @strarsis What you think about this ?

@litinskii: You can try the PR here: https://github.com/svg/svgo/pull/1106
Options prefixIds and prefixClassNames, which both default to true,
(so nothing of existing default prefixIds behaviour changes) can be set to false:
https://github.com/svg/svgo/pull/1106/files#diff-623dc50b643d62febf2af73ea1856b51R9

@strarsis Thanks will try.

@strarsis seems it work for my case. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wuz picture wuz  路  3Comments

elidupuis picture elidupuis  路  5Comments

onlymega picture onlymega  路  6Comments

bmcminn picture bmcminn  路  4Comments

ai picture ai  路  5Comments