} else if (curIndex == length) {
curIndex = --length;
}
-// Temporary until leading space problem in 1.0 fixed
-// System.out.println("\n\nremove called: ca = \"" +
-// new String(ca) + "\", length/node length: " + length
-// + ", " + ca.length);
}
if (firstInlineChild != null) {
boolean bInWS = false;
boolean bPrevWasLF = false;
+
+ /* bSeenNonWSYet is an indicator used for trimming all leading
+ whitespace for the first inline child of the block
+ */
+ boolean bSeenNonWSYet = false;
RecursiveCharIterator charIter =
new RecursiveCharIterator(this, firstInlineChild);
LFchecker lfCheck = new LFchecker(charIter);
&& (bPrevWasLF || lfCheck.nextIsLF()))) {
charIter.remove();
} else {
+ // this is to retain a single space between words
bInWS = true;
+ // remove the space if no word in block
+ // encountered yet
+ if (!bSeenNonWSYet) {
+ charIter.remove();
+ }
}
}
break;
} else {
if (bWScollapse) {
bInWS = true;
+ // remove the linefeed if no word in block
+ // encountered yet
+ if (!bSeenNonWSYet) {
+ charIter.remove();
+ }
}
charIter.replaceChar('\u0020');
}
case CharUtilities.NONWHITESPACE:
/* Any other character */
bInWS = bPrevWasLF = false;
+ bSeenNonWSYet = true;
lfCheck.reset();
break;
}