I have spent most of this week trying to sort out the persistent
whitespace bugs in Composer. I tried rewriting the ConvertWhitespace
algorithm, but this turns out to be insufficient. If I had a few more
weeks, I could probably sort it out, but I haven't.
The ConvertWhitespace code interacts with several other things:
1 - The way this algorithm is deployed, perhaps on a range which is
adjacent to other whitespace.
2 - The line-wrapping function of the HTML serializer during file
save.
3 - The way the file is scanned when it is read, to be converted
to Composer's internal data structure.
4 - Also the "View HTML Source" function, which changes the data
in memory, and I believe, can break one node into multiple
nodes. Don't trust "View HTML Source"!
Please read:
http://bugzilla.mozilla.org/show_bug.cgi?id=61228
and my third file which documents and demonstrates some whitespace bugs:
http://gair.firstpr.com.au/public-files/mozilla-bugs/mb-comp-space-3.html
This also discusses the current ConvertWhitespace algorithm:
Number of spaces: - = space
n = non-breaking space
1 -
2 -n
3 -n-
4 -nn-
5 -n-n-
6 -nn-n-
7 -n-n-n- etc.
and a new one I wrote, which is the same as N4.x, I think:
1 - or n if this is the first char of the search area.
2 n-
3 nn-
4 nnn-
5 nnnn- etc.
That directory also includes source code for this algorithm, and some
earlier example files.
- Robin