Merge branch lp:~louis-simard/scour/rework. Summary of changes:

scour.py, scour.inkscape.py, scour.inx:
 * Add options --quiet, --enable-comment-stripping, --shorten-ids, --remove-metadata, --renderer-workaround.
scour.py:
 * Optimisations in time (so Scour runs faster) and space (so Scour allocates less memory, less often).
 * Change #E+# to #e#, #E-# to #e-#, 0.# to .# and -0.# into -.# in path/polygon/polyline data + lengths, if renderer workarounds are disabled. Use spaces instead of commas in path/polygon/polyline data. Use lower-case #rrggbb and #rgb instead of upper-case. All of this makes gzip work better, since the rest of SVG documents mostly has lower-case letters in tag names and spaces to separate XML attributes etc.
 * Fix a bug whereby an SVG document would become filled with black if all elements had the same fill color.
 * Fix a bug whereby a path's second command would not start at the right coordinates if the first command was a relative moveto 'm' with at least 1 implied lineto.
 * Fix a bug whereby a path's absolute lineto 'L' commands would not become the right relative lineto 'l' commands.
 * Allow the implicit linetos after a path's moveto 'M'/'m' to be converted into relative horizontal linetos 'h' and vertical 'v' too.
scour.inx:
 * Fix help typos. Make options more descriptive in the plugin option window. Add something about enable-group-collapsing requiring enable-id-stripping.
testscour.py:
 * Rework tests that relied on #E+#, #E-#, 0.# and -0.# so that they accept the changes to scour.py. Add unit tests for strip-xml-prolog, enable-comment-stripping and remove-metadata.
This commit is contained in:
Cynthia Gauthier 2010-06-15 20:58:57 -04:00
parent 00804fb833
commit f4cca44faf
9 changed files with 1153 additions and 518 deletions

View file

@ -7,16 +7,20 @@
<dependency type="executable" location="extensions">yocto_css.py</dependency>
<param name="tab" type="notebook">
<page name="Options" _gui-text="Options">
<param name="simplify-colors" type="boolean" _gui-text="Simplify colors">true</param>
<param name="style-to-xml" type="boolean" _gui-text="Style to xml">true</param>
<param name="simplify-colors" type="boolean" _gui-text="Shorten color values">true</param>
<param name="style-to-xml" type="boolean" _gui-text="Convert CSS attributes to XML attributes">true</param>
<param name="group-collapsing" type="boolean" _gui-text="Group collapsing">true</param>
<param name="enable-id-stripping" type="boolean" _gui-text="Enable id stripping">false</param>
<param name="enable-id-stripping" type="boolean" _gui-text="Remove unused ID names for elements">false</param>
<param name="shorten-ids" type="boolean" _gui-text="Shorten IDs">false</param>
<param name="embed-rasters" type="boolean" _gui-text="Embed rasters">true</param>
<param name="keep-editor-data" type="boolean" _gui-text="Keep editor data">false</param>
<param name="remove-metadata" type="boolean" _gui-text="Remove metadata">false</param>
<param name="enable-comment-stripping" type="boolean" _gui-text="Remove comments">false</param>
<param name="renderer-workaround" type="boolean" _gui-text="Work around renderer bugs">false</param>
<param name="enable-viewboxing" type="boolean" _gui-text="Enable viewboxing">false</param>
<param name="strip-xml-prolog" type="boolean" _gui-text="Strip xml prolog">false</param>
<param name="set-precision" type="int" _gui-text="Set precision">5</param>
<param name="indent" type="enum" _gui-text="Indent">
<param name="strip-xml-prolog" type="boolean" _gui-text="Remove the <?xml?> declaration">false</param>
<param name="set-precision" type="int" _gui-text="Number of significant digits for coords">5</param>
<param name="indent" type="enum" _gui-text="XML indentation (pretty-printing)">
<_item value="space">Space</_item>
<_item value="tab">Tab</_item>
<_item value="none">None</_item>
@ -24,16 +28,19 @@
</page>
<page name="Help" _gui-text="Help">
<_param name="instructions" type="description" xml:space="preserve">This extension optimizes the SVG file according to the following options:
* Simplify colors: convert all colors to #RRGGBB format.
* Style to xml: convert styles into XML attributes.
* Group collapsing: collapse group elements.
* Enable id stripping: remove all un-referenced ID attributes.
* Embed rasters: embed rasters as base64-encoded data.
* Shorten color names: convert all colors to #RRGGBB or #RGB format.
* Convert CSS attributes to XML attributes: convert styles from <style> tags and inline style="" declarations into XML attributes.
* Group collapsing: removes useless <g> elements, promoting their contents up one level. Requires "Remove unused ID names for elements" to be set.
* Remove unused ID names for elements: remove all unreferenced ID attributes.
* Shorten IDs: reduce the length of all ID attributes, assigning the shortest to the most-referenced elements. For instance, #linearGradient5621, referenced 100 times, can become #a.
* Embed rasters: embed raster images as base64-encoded data URLs.
* Keep editor data: don't remove Inkscape, Sodipodi or Adobe Illustrator elements and attributes.
* Enable viewboxing: size image to 100%/100% and introduce a viewBox
* Strip xml prolog: don't output the xml prolog.
* Set precision: set number of significant digits (default: 5).
* Indent: indentation of the output: none, space, tab (default: space).</_param>
* Remove metadata: remove &lt;metadata&gt; tags along with all the information in them, which may include license metadata, alternate versions for non-SVG-enabled browsers, etc.
* Remove comments: remove &lt;!-- --&gt; tags.
* Work around renderer bugs: emits slightly larger SVG data, but works around a bug in librsvg's renderer, which is used in Eye of GNOME and other various applications.
* Enable viewboxing: size image to 100%/100% and introduce a viewBox.
* Number of significant digits for coords: all coordinates are output with that number of significant digits. For example, if 3 is specified, the coordinate 3.5153 is output as 3.51 and the coordinate 471.55 is output as 472.
* XML indentation (pretty-printing): either None for no indentation, Space to use one space per nesting level, or Tab to use one tab per nesting level.</_param>
</page>
</param>
<output>