Skip to content

Add style argument which can convert SVG attributes to CSS Style attribute (the opposite of style_to_xml.)

Jonathan Neuhauser requested to merge github/fork/doom-goober/master into master

Created by: doom-goober

Currently, scour allows the user two options when it comes to SVG Attributes versus CSS Style: They can either convert everything to SVG Attributes or leave all the attributes as they were originally encoded. Obviously, there is a third option, which is currently missing: convert everything to CSS Style.

While SVG Attributes are generally preferred for various CSS overriding reasons, some tools don't handle them well and prefer CSS Style. For example, Inkscape's "Save As HTML 5 Canvas" doesn't support SVG Attributes but does support CSS Style. For this reason, tools like Illustrator allow the user to choose between "Inline" or "Presentational Attributes" (or a third option, "Internal CSS" which is out of scope for this discussion.) The eventual goal of this change would be to add an option to Inkscape so it behaves somewhat like Illustrator with three options: "Preserve", "Presentational Attributes", "Inline".

This pull request adds the option to convert styling all to CSS Style through --style=inline. The other options are --style=none, --style=attributes, --style=preserve.

The backwards compatibility logic is slightly annoying. If you specify a --style other than "none", then that style will be used. If you specify --style=none (or specify nothing, as none is the default) then --disable-style-to-xml or --style-to-xml will decide the behavior. Perhaps "none" could renamed "default?"

Merge request reports

Loading