Skip to content
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

decide whether to support <style> element; or explicitly error out #296

Open
anthrotype opened this issue May 23, 2023 · 5 comments
Open

Comments

@anthrotype
Copy link
Member

currently we only support style attributes but not a <style> element. When the latter is present, picosvg ignores it silently but then produces incorrect results (e.g. if the fill attributes are defined within the embedded stylesheet, then the paths will appear black).

I propose for now we raise an error and request the user to fix the input.

@NightFurySL2001
Copy link
Contributor

Side note: this only happens if <style> is in <defs>. If <style> is not in <defs> (e.g. Adobe Illustrator "Save As" option, see file attached below) then a ValueError is raised:

ValueError: Unable to convert to picosvg: BadElement: /svg[0]/style[0]

uni91cd.svg

@anthrotype
Copy link
Member Author

oh, thanks for that. Yeah, the idea is that it is not supported. The fact that we silently gloss over it if it is inside defs was unintended.

@NightFurySL2001
Copy link
Contributor

It would be good to set it to be ignorable instead of raising erro for some use cases. E.g. all files generated by Adobe Illustrator (as far as I've seen) always have one <style> block.

@anthrotype
Copy link
Member Author

is it always there even if empty? Can you configure Illustrator to instead write the declaration as inlined style attributes?

The thing is we don't have a full CSS parser so we don't support parsing the stylesheet, only individual css declaration inlined in style attributes. That style element may actually contain something important and ignoring it may lead to unexpectedly missing some piece of data. Remember that picosvg main goal was to simplify svg for the sake of producing color fonts.

@NightFurySL2001
Copy link
Contributor

Ai always have a colour CSS even if not used, but yes there is a configuration to use inline style (but quite hidden in export for web menu). I do hope someday the style attribute will be parsed correctly 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants