[thelist] soft-wrap unbreaking long words
sam foster
potatosculptor at gmail.com
Tue Aug 22 07:54:47 CDT 2006
Does anyone have a good algorithm / routine for manipulating text to
ensure the browser can wrap it. In my case this is for labels in a
tree control, where width is not flexible, and
longwordslikethisthatdontcontainspaces blow out. This is to *reduce*
the likelihood of problems, not a silver bullet (it wont account for
varying font-sizes or character widths).
I made a start myself, but its a surpisingly subtle problem. My goal
is to add ­ or <wbr/> at or around a given maxcolumns. I need to
handle escape entities correctly (i.e. count é as one
character, and also html so <b>B</b> is also one character). Ideally,
the wrap would happen after punctuation, and more ideally, at the end
of a series of punctuation characters. E.g. wrap http://
www.somedomain.com
not http:/
/www.somedomain.com
and com.company.package.
name
not com.company.pack
age.name
This could be server-side or client-side code. I did a couple searches
on Krugle - reasoning that it must have been written before - but
didn't turn much up. Its a java environment on the server-side fwiw.
thanks
Sam
More information about the thelist
mailing list