Re: Multiple spaces converted into one

Multiple spaces (typed or pasted) being converted into some sequence of 
normal and non-breaking spaces is really just one more example of 
converting the users input into a form which can be represented in XHTML 
in such a way that the editor and/or browser can properly display what 
was typed (or pasted). This is really no different than typing (or 
pasting) the character sequence "<&>", which will be converted into 
"&lt;&amp;&gt;" for representation in the XHTML document. If this text 
is then highlighted in the Amaya editor, copied to the clipboard, and 
pasted into a text editor (such as notepad), you get the original 
character sequence "<&>".

The same thing should be true when the user types the character sequence 
"123   456" (with three spaces between the "3" and the "4". If the user 
types (or pastes) a string with multiple spaces, then I think the 
multiple spaces should be converted to some combination of normal and 
non-breaking spaces so that the multiple spaces are preserved. I tried 
this with the Nvu editor, and found the three spaces were converted to " 
&nbsp; " (i.e. space, non-breaking-space, space). I don't know if this 
is the best sequence to use, but it displays as three spaces. When the 
text is copied to the clipboard, the three spaces get converted back to 
three normal spaces.

IMHO, how to handle spaces between sentences is a completely different 
issue, and is best handled by the browser with or without help from CSS. 
This is a complex issue which goes way beyond simply adding extra space 
after a period. What about sentences ending with "!" or "?", 
abbreviations within sentences, decimal points within numbers, etc.?

Don't forget that one of the primary reasons that X/HTML collapses 
multiple white spaces into a single space is to let us format X/HTML 
documents nicely as ASCII text files with indenting to show the 
structure of the nested block level elements, and to allow keeping the 
line lengths reasonably short to make editing the document easier with a 
text editor. But true XHTML editors should try to "hide" things like 
&gt; and &lt; from the user. They should also try to "hide" &nbsp; from 
the user when it is necessary to represent multiple spaces. The user 
should only have to worry about non-breaking spaces when making a 
conscience effort to avoid inappropriate line breaks, such as in the 
string "125 lbs.", or similar cases.

Keith Rubow
P.S. Amaya is still my favorite HTML editor.

Received on Tuesday, 5 September 2006 17:24:04 UTC