NonSci output option and InkScape extension added by Aleon

This commit is contained in:
Marcus Lindvall 2023-01-31 11:02:40 +01:00
parent 0609c59676
commit a124f9f415
6 changed files with 269 additions and 12 deletions

132
extension/output_scour.inx Normal file
View file

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<name>Optimized SVG Output</name>
<id>org.inkscape.output.scour_inkscape</id>
<param name="tab" type="notebook">
<page name="Options" gui-text="Options">
<param gui-text="Number of significant digits for coordinates:"
gui-description="Specifies the number of significant digits that should be output for coordinates. Note that significant digits are *not* the number of decimals but the overall number of digits in the output. For example if a value of &quot;3&quot; is specified, the coordinate 3.14159 is output as 3.14 while the coordinate 123.675 is output as 124."
name="set-precision" type="int" min="1">5</param>
<spacer/>
<param gui-text="Shorten color values"
gui-description="Convert all color specifications to #RRGGBB (or #RGB where applicable) format."
name="simplify-colors" type="bool">true</param>
<param gui-text="Convert CSS attributes to XML attributes"
gui-description="Convert styles from style tags and inline style=&quot;&quot; declarations into XML attributes."
name="style-to-xml" type="bool">true</param>
<spacer/>
<param gui-text="Collapse groups"
gui-description="Remove useless groups, promoting their contents up one level. Requires &quot;Remove unused IDs&quot; to be set."
name="group-collapsing" type="bool">true</param>
<param gui-text="Create groups for similar attributes"
gui-description="Create groups for runs of elements having at least one attribute in common (e.g. fill-color, stroke-opacity, ...)."
name="create-groups" type="bool">true</param>
<spacer/>
<param gui-text="Keep editor data"
gui-description="Don't remove editor-specific elements and attributes. Currently supported: Inkscape, Sodipodi and Adobe Illustrator."
name="keep-editor-data" type="bool">false</param>
<param gui-text="Remove scientific notation"
gui-description="Remove scientific notation from path data."
name="nonsci-output" type="bool">false</param>
<param gui-text="Keep unreferenced definitions"
gui-description="Keep element definitions that are not currently used in the SVG"
name="keep-unreferenced-defs" type="bool">false</param>
<spacer/>
<param gui-text="Work around renderer bugs"
gui-description="Works around some common renderer bugs (mainly libRSVG) at the cost of a slightly larger SVG file."
name="renderer-workaround" type="bool">true</param>
</page>
<page name="Output" gui-text="SVG Output">
<label appearance="header">Document options</label>
<param gui-text="Remove the XML declaration"
gui-description="Removes the XML declaration (which is optional but should be provided, especially if special characters are used in the document) from the file header."
name="strip-xml-prolog" type="bool">false</param>
<param gui-text="Remove metadata"
gui-description="Remove metadata tags along with all the contained information, which may include license and author information, alternate versions for non-SVG-enabled browsers, etc."
name="remove-metadata" type="bool">false</param>
<param gui-text="Remove comments"
gui-description="Remove all XML comments from output."
name="enable-comment-stripping" type="bool">false</param>
<param gui-text="Embed raster images"
gui-description="Resolve external references to raster images and embed them as Base64-encoded data URLs."
name="embed-rasters" type="bool">true</param>
<param gui-text="Enable viewboxing"
gui-description="Set page size to 100%/100% (full width and height of the display area) and introduce a viewBox specifying the drawings dimensions."
name="enable-viewboxing" type="bool">false</param>
<spacer/>
<label appearance="header">Pretty-printing</label>
<param gui-text="Format output with line-breaks and indentation"
gui-description="Produce nicely formatted output including line-breaks. If you do not intend to hand-edit the SVG file you can disable this option to bring down the file size even more at the cost of clarity."
name="line-breaks" type="bool">true</param>
<param gui-text="Indentation characters:"
gui-description="The type of indentation used for each level of nesting in the output. Specify &quot;None&quot; to disable indentation. This option has no effect if &quot;Format output with line-breaks and indentation&quot; is disabled."
name="indent" type="optiongroup" appearance="combo">
<option value="space">Space</option>
<option value="tab">Tab</option>
<option context="Indent" value="none">None</option>
</param>
<param gui-text="Depth of indentation:"
gui-description="The depth of the chosen type of indentation. E.g. if you choose &quot;2&quot; every nesting level in the output will be indented by two additional spaces/tabs."
name="nindent" type="int">1</param>
<param gui-text="Strip the &quot;xml:space&quot; attribute from the root SVG element"
gui-description="This is useful if the input file specifies &quot;xml:space='preserve'&quot; in the root SVG element which instructs the SVG editor not to change whitespace in the document at all (and therefore overrides the options above)."
name="strip-xml-space" type="bool">false</param>
</page>
<page name="IDs" gui-text="IDs">
<param gui-text="Remove unused IDs"
gui-description="Remove all unreferenced IDs from elements. Those are not needed for rendering."
name="enable-id-stripping" type="bool">true</param>
<spacer/>
<param gui-text="Shorten IDs"
gui-description="Minimize the length of IDs using only lowercase letters, assigning the shortest values to the most-referenced elements. For instance, &quot;linearGradient5621&quot; will become &quot;a&quot; if it is the most used element."
name="shorten-ids" type="bool">false</param>
<param gui-text="Prefix shortened IDs with:"
gui-description="Prepend shortened IDs with the specified prefix."
name="shorten-ids-prefix" type="string"></param>
<spacer/>
<param gui-text="Preserve manually created IDs not ending with digits"
gui-description="Descriptive IDs which were manually created to reference or label specific elements or groups (e.g. #arrowStart, #arrowEnd or #textLabels) will be preserved while numbered IDs (as they are generated by most SVG editors including Inkscape) will be removed/shortened."
name="protect-ids-noninkscape" type="bool">true</param>
<param gui-text="Preserve the following IDs:"
gui-description="A comma-separated list of IDs that are to be preserved."
name="protect-ids-list" type="string"></param>
<param gui-text="Preserve IDs starting with:"
gui-description="Preserve all IDs that start with the specified prefix (e.g. specify &quot;flag&quot; to preserve &quot;flag-mx&quot;, &quot;flag-pt&quot;, etc.)."
name="protect-ids-prefix" type="string"></param>
</page>
<page name="About" gui-text="About">
<hbox>
<image>output_scour.svg</image>
<spacer/>
<vbox>
<spacer/>
<label>Optimized SVG Output is provided by</label>
<label appearance="header" indent="1">Scour - An SVG Scrubber</label>
<spacer/>
<label>For details please refer to</label>
<label appearance="url" indent="1">https://github.com/scour-project/scour</label>
</vbox>
</hbox>
<spacer size="expand"/>
<hbox>
<label>This version of the extension is designed for</label>
<label>Scour 0.31+</label>
</hbox>
<param name="scour-version" type="string" gui-hidden="true">0.31</param> <!-- this parameter is checked programmatically in the extension to show a warning -->
<param gui-text="Show warnings for older versions of Scour"
name="scour-version-warn-old" type="bool">true</param>
</page>
</param>
<output>
<extension>.svg</extension>
<mimetype>image/svg+xml</mimetype>
<filetypename>Optimized SVG (*.svg)</filetypename>
<filetypetooltip>Scalable Vector Graphics</filetypetooltip>
</output>
<script>
<command location="inx" interpreter="python">output_scour.py</command>
</script>
</inkscape-extension>