scour-project / scour

Scour - An SVG Optimizer / Cleaner
Apache License 2.0
757 stars 61 forks source link

Indention/Line Break optimization not working #297

Open rstemmer opened 2 years ago

rstemmer commented 2 years ago

I have a svg file with empty groups and line indention (using spaces). Applying --indent=none and --no-line-breaks does not work.

Input:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
    <g transform="matrix(1,0,0,1,-325,-55)">

        <g id="StatusOpen" transform="matrix(1,0,0,1,150,0)">
            <path id="Circle" d="M185,55C190.519,55 195,59.481 195,65C195,70.519 190.519,75 185,75C179.481,75 175,70.519 175,65C175,59.481 179.481,55 185,55ZM185,57C189.415,57 193,60.585 193,65C193,69.415 189.415,73 185,73C180.585,73 177,69.415 177,65C177,60.585 180.585,57 185,57Z"/>
        </g>
        <g id="StatusActive_1">
        </g>
        <g id="StatusActive_2">
        </g>
        <g id="StatusActive_3">
        </g>
    </g>
</svg>

Output:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg  PUBLIC '-//W3C//DTD SVG 1.1//EN'  'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2" version="1.1" viewBox="0 0 20 20" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
    <g transform="translate(-325 -55)">

        <g transform="translate(150)">
            <path d="m185 55c5.519 0 10 4.481 10 10s-4.481 10-10 10-10-4.481-10-10 4.481-10 10-10zm0 2c4.415 0 8 3.585 8 8s-3.585 8-8 8-8-3.585-8-8 3.585-8 8-8z"/>
        </g>

    </g>
</svg>

Note that the leading space of the stripped groups remain as well.

scour-call:

scour -i "Input.svg" -o "Output.svg" --enable-id-stripping --enable-comment-stripping --shorten-ids --indent=none --no-line-breaks

You can find a lot of small svg files that come with this issue here in my repository. Feel free to use them for testing.

I use scour 0.38.2 with Python 3.10.4