scour icon indicating copy to clipboard operation
scour copied to clipboard

--strip-xml-space leads to wrong spaces in <text>

Open JoKalliauer opened this issue 6 years ago • 1 comments

Processing File:Alloy_cooling_curves_mixed_crystals.svg leads to wrong spaces.

scour -i input.svg.txt -o output.svg.txt --strip-xml-space

Input

input.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<svg width="623" height="599" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
 <text x="54.81" y="27.27" font-family="Arabic Typesetting" font-size="36" letter-spacing="0" word-spacing="0">   <tspan x="54.81" y="27.27">2        3           4              5             6</tspan>  </text>
</svg>

input

Scour-Output

output.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<svg width="623" height="599" xmlns="http://www.w3.org/2000/svg">
 <text x="54.81" y="27.27" font-family="Arabic Typesetting" font-size="36" letter-spacing="0" word-spacing="0"><tspan x="54.81" y="27.27">2 3 4 5 6</tspan></text>
</svg>

output

Wanted, Desired

<svg width="623" height="599" xmlns="http://www.w3.org/2000/svg">
 <text xml:space="preserve" x="54.81" y="27.27" font-family="Arabic Typesetting" font-size="36" letter-spacing="0" word-spacing="0">   <tspan x="54.81" y="27.27" xml:space="preserve">2        3           4              5             6</tspan>  </text>
</svg>

xml:space="preserve" should be removed in the <svg-tag and applied to all child-elements. Then xml:space="preserve" should be removed from <rect, <path, circle, ellipse, image and all <g-tags only containing mentioned tags (maybe also all selfclosing tags).

Applying it to all <text which are not defined differently (xml:space="none"), would remove it from unknown tags such as <flowRoot.

Copyright

License:cc-by-sa-3.0

Author: Ra'ike

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

JoKalliauer avatar Oct 02 '18 15:10 JoKalliauer

Well, this is not a bug but documented behavior.

We could consider re-adding the xml:space="preserve" for text nodes as an enhancement in future, though.

Ede123 avatar Oct 02 '18 16:10 Ede123