change how indent, returns work with xml formatting

This commit is contained in:
Ben Fry
2013-06-03 14:44:17 -04:00
parent 5684907cd6
commit 9209745631

View File

@@ -63,7 +63,7 @@ public class XML implements Serializable {
/**
* @nowebref
*/
*/
protected XML() { }
@@ -1007,11 +1007,13 @@ public class XML implements Serializable {
return singleLine;
}
// Might just be whitespace, which won't be valid XML. And in that case,
// even adding the decl to the top seems dumb, so don't spew out a decl.
// Might just be whitespace, which won't be valid XML for parsing below.
// https://github.com/processing/processing/issues/1796
// Since indent is not -1, that means they want valid XML,
// so we'll give them the single line plus the decl.
if (singleLine.trim().length() == 0) {
return "";
// You want whitespace? I've got your whitespace right here.
return singleLine;
}
// Since the indent is not -1, bring back the XML declaration
@@ -1049,6 +1051,7 @@ public class XML implements Serializable {
*/
@Override
public String toString() {
return format(2);
//return format(2);
return format(-1);
}
}