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

removeStyleElement removes necessary CSS attributes #946

Closed
JoKalliauer opened this issue Apr 10, 2018 · 3 comments
Closed

removeStyleElement removes necessary CSS attributes #946

JoKalliauer opened this issue Apr 10, 2018 · 3 comments

Comments

@JoKalliauer
Copy link

Prozessing File:Baron_officier_maison_princes.svg with --enable=removeStyleElement leads to a removement of CSS without importing

svgo -i Baron_officier_maison_princes.svg -o output.svg --pretty --indent=1 --enable=removeStyleElement

input.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg  PUBLIC '-//W3C//DTD SVG 1.1//EN'  'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg viewBox="85000 109000 85001 109001" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <defs>
  <style type="text/css">
   .str1{stroke:#000;stroke-width:417}.fil6{fill:#ccc}.fil12{fill:#e5e5e5}
  </style>
 </defs>
 <path class="fil6 str1" d="M88923 142267h16038v3070H88923zM89081 191689h15653v3070H89081zM136119 142252h16038v3070h-16038zM136277 191673h15653v3070h-15653z"/>
 <path class="fil12 str1" d="M83894 194908h72895v5055H83894zM84213 138692h71798v3376H84213zM92196 133393h56883v5010H92196z"/>
 <path class="fil6 str1" d="M120878 121014l-31768 12084h63536l-31768-12084z"/>
</svg>

input

output.svg.txt

<svg viewBox="85000 109000 85001 109001" xmlns="http://www.w3.org/2000/svg">
 <defs/>
 <path class="fil6 str1" d="M88923 142267h16038v3070H88923zM89081 191689h15653v3070H89081zM136119 142252h16038v3070h-16038zM136277 191673h15653v3070h-15653z"/>
 <path class="fil12 str1" d="M83894 194908h72895v5055H83894zM84213 138692h71798v3376H84213zM92196 133393h56883v5010H92196z"/>
 <path class="fil6 str1" d="M120878 121014l-31768 12084h63536l-31768-12084z"/>
</svg>

output

@GreLI
Copy link
Member

GreLI commented Apr 10, 2018

Plugins are working independently. By default styles are converting to inline only if used only once (otherwise it wouldn't be optimal). Set onlyMatchedOnce: false for inlineStyles to convert styles anyway.

@ad-si
Copy link

ad-si commented Apr 25, 2018

I'm also having problems with erroneously removed CSS since the update from 0.7.2 to 1.0.x

@GreLI
Copy link
Member

GreLI commented Apr 25, 2018

removeStyleElement removes <style> elements unconditionally. So don't enable it, if it's undesired behavior. Or tune up plugins more precisely. No point in lamenting here.

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

3 participants