scour icon indicating copy to clipboard operation
scour copied to clipboard

add option --keepDefaults

Open JoKalliauer opened this issue 5 years ago • 2 comments

Processing File:Comparison_satellite_navigation_orbits.svg:

scour Input.svg.txt Output.svg.txt

Input

Input.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<svg font-family="Helvetica,Arial,sans-serif" font-size="40px" version="1.1" viewBox="-123.73 -429.12 549.32 69.014" xmlns="http://www.w3.org/2000/svg">
 <style type="text/css">#main{text-anchor:end}</style>
 <g id="main">
  <text x="150" y="-400" style="fill:#f00">Graveyard orbit<tspan x="230" y="-366" font-size="28px">(GEO+300 km)</tspan></text>
  <text x="150" y="-400" style="fill:#000;text-anchor:start">Graveyard orbit<tspan x="230" y="-366" font-size="28px">(GEO+300 km)</tspan></text>
 </g>
</svg>

Input

Output

Output.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<svg font-family="Helvetica,Arial,sans-serif" font-size="40px" version="1.1" viewBox="-123.73 -429.12 549.32 69.014" xmlns="http://www.w3.org/2000/svg">
 <style type="text/css">#main{text-anchor:end}</style>
 <g id="main">
  <text x="150" y="-400" style="fill:#f00">Graveyard orbit<tspan x="230" y="-366" font-size="28px">(GEO+300 km)</tspan></text>
  <text x="150" y="-400">Graveyard orbit<tspan x="230" y="-366" font-size="28px">(GEO+300 km)</tspan></text>
 </g>
</svg>

Output

Not duplicate of #174

There might be several resons why you would like to keep default values, therfore it is independed to CSS.

Copyright

source: https://commons.wikimedia.org/wiki/File:Comparison_satellite_navigation_orbits.svg

author: Cmglee, Geo Swan

license: CC-BY-SA 3.0

JoKalliauer avatar Jul 06 '19 20:07 JoKalliauer

There might be several resons why you would like to keep default values, therfore it is independed to CSS.

Can you mention a few?

As long as inheritance rules are properly cascaded (and that is #174), default attributes would be kept if necessary and this specific issue would not occur.

Are there any valid reasons why we would like to keep unnecessary default attributes (which this issue seems to request)?

Ede123 avatar Jul 06 '19 21:07 Ede123

Can you mention a few?

Are there any valid reasons why we would like to keep unnecessary default attributes (which this issue seems to request)?

To be honest I did not think about it, and I personally would not use it (except for bug-avoiding), but

  • svgo has an optional plugin to delete defaults https://github.com/svg/svgo/blob/master/plugins/removeUnknownsAndDefaults.js so I assume there will be reasons for it.
  • you copy parts from one SVG to anther one, and you want that this part behaves identical
  • you would like to modify some options in a group, (e.g. the color of the text, but some text should always be black, independend on the default group-color.)
  • you write a (buggy) script that can only handle available definitins, if a definition is missing the script will fail (e.g. https://github.com/JoKalliauer/cleanupSVG/blob/master/FFlow2TextBySed.py might only work if flowRoot contains font-size, otherwise it might not convert FlowRoot2Text)
  • the file should be human-readable, and because inherit's options might be difficult to find out (expecially in a >1GB-file, where you "can't" scroll in many editors any more, it might be better to repeat them (e.g. you grep for all lines containing <text and what to ensure that they have a minimum font-size)

JoKalliauer avatar Jul 06 '19 21:07 JoKalliauer