Tweaks to svgToString() to produce slightly tidier output
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@209 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
a676614787
commit
6b7bd3eaf8
|
@ -222,22 +222,26 @@ function SvgCanvas(c)
|
|||
}
|
||||
}
|
||||
if (elem.hasChildNodes()) {
|
||||
out += ">\n";
|
||||
out += ">";
|
||||
indent++;
|
||||
var bOneLine = false;
|
||||
for (i=0; i<childs.length; i++)
|
||||
{
|
||||
if (childs.item(i).nodeType == 1) { // element node
|
||||
out = out + svgToString(childs.item(i), indent);
|
||||
out += "\n" + svgToString(childs.item(i), indent);
|
||||
} else if (childs.item(i).nodeType == 3) { // text node
|
||||
for (j=0; j<indent; j++) out += " ";
|
||||
bOneLine = true;
|
||||
out += childs.item(i).nodeValue + "";
|
||||
}
|
||||
}
|
||||
indent--;
|
||||
if (!bOneLine) {
|
||||
out += "\n";
|
||||
for (i=0; i<indent; i++) out += " ";
|
||||
out += "</" + elem.nodeName + ">\n";
|
||||
}
|
||||
out += "</" + elem.nodeName + ">";
|
||||
} else {
|
||||
out += " />\n";
|
||||
out += "/>";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
|
@ -882,7 +886,8 @@ function SvgCanvas(c)
|
|||
// remove the selected outline before serializing
|
||||
this.selectNone();
|
||||
var str = "<?xml version=\"1.0\" standalone=\"no\"?>\n";
|
||||
str += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
||||
// see http://jwatt.org/svg/authoring/#doctype-declaration
|
||||
// str += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
|
||||
str += svgToString(svgroot, 0);
|
||||
this.saveHandler(str);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue