SVG Formatting

Discuss SVG code, accessible via the XML Editor.
Greig

SVG Formatting

Postby Greig » Fri Nov 26, 2010 1:38 am

Hello, I was hoping someone could help me with figuring out the following.

I'm not sure how this happens but I'm after a way to get Inkscape to format the SVG file in a particular way (one which at has done previously).

So as an example, I have an Inkscape generated SVG file where the tags are always on a new line as such:

<g
style="opacity:0.5;display:inline"
inkscape:label="footprint"
id="layer5"
inkscape:groupmode="layer"
sodipodi:insensitive="true">
<path
sodipodi:nodetypes="cccccccccccccccccccccccccccccccccccccccccc"
id="path3800"
d="M......z"
style="fill:#999999;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>

A colleague has managed to open this SVG file in Inkscape, save it and now the exact same section looks like this:

id="g2412" /><g
sodipodi:insensitive="true"
style="opacity:0.5;display:none"
inkscape:label="footprint"
id="layer5"
inkscape:groupmode="layer"><path
sodipodi:nodetypes="cccccccccccccccccccccccccccccccccccccccccc"
id="path3800"
d="M ..... z"
style="fill:#999999;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /></g><g

How can I force Inkscape to regenerate the XML the previous way with the opening and closing of tags on separate lines? I'm fairly sure this is possible as I managed to accidently do it at one point but haven't been able to repeat this feat since.

Greig

Re: SVG Formatting

Postby Greig » Fri Nov 26, 2010 3:01 am

I have managed to get Inkscape to generate the preferred in my case output but feel there must be a better way.

I opened the file with PSPAD, used TiDy to reformat the code. Saved the file and opened in Inkscape, then used Save As and saved either over the original file or as a new one and this gives me nicely formatted XML code with tags on new lines.

Seems as if I'm needing to force Inkscape to trigger a complete rewrite of the XML from what was perhaps an old way of creating it?

User avatar
tomh
Posts: 218
Joined: Sat Feb 14, 2009 10:14 pm

Re: SVG Formatting

Postby tomh » Sun Jan 09, 2011 9:58 am

There is Inkscape Preferences->SVG Output which should enable you adjust thow the SVG is outputted.


Return to “SVG / XML Code”