Skip to content

leifgehrmann/svg-attrs-to-style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

svg-attrs-to-style

An SVGO plugin that converts presentation attributes to inline-style properties.

<g fill="#000" color="#fff" style="-webkit-blah: blah">
             ⬇
<g style="fill:#000;color:#fff;-webkit-blah: blah">

Why?

This is a tool to work around a bug in the Inkscape beta. In Inkscape, if one runs "Stroke to Path" on an object, in certain peculiar edge cases, the stroke colors are not transferred if the color is specified by the stroke attribute. A workaround is to use the inline style attribute instead.

But there of course may be other useful applications for this!

Note: This plugin will not work well if one uses <style> elements in the SVG, as the inline style attribute will override it.

Installation/Usage

If SVGO is already installed

Just drag and drop convertAttrsToStyle.js into the plugins directory of SVGO.

For development

  1. Clone this repository
  2. Install Node.js (See Installing Node.js via package manager)
  3. Run
    make install_locally
    
  4. Copy the plugin into SVGO's plugin directory
    cp plugins/convertAttrsToStyle.js svgo/plugins/
    

Testing

make test

About

An SVGO plugin that converts presentation attributes to style properties

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published