ietf-822
[Top] [All Lists]

Algorithm for splitting long lines

1996-07-22 03:19:19
We have all seen e-mail pages which look something like this:

Jack and Jill went up the hill. Jack fell down and Jill came
tumbling after.
This is the second line of the original text which was split
because of line
length into several lines as shown above.

Text like this is *not* very neat to read. I developed, many
years ago, a much better algorithm for splitting long lines.

My algorithm was very simple: Find the middle of the long
line. Find the word break which is closest to the middle, which
sometimes is before and sometimes after the line break. Split
at that point. Because of the randomness that the split is
sometimes before the middle, sometimes after, there is no
disturbing regularity to the result.

The example above will look like this with my algorithm:

Jack and Jill went up the hill. Jack
fell down and Jill came tumbling after.
This is the second line of the original
text which was split because of line
length into several lines as shown above. 

------------------------------------------------------------------------
Jacob Palme <jpalme(_at_)dsv(_dot_)su(_dot_)se> (Stockholm University and KTH)
for more info see URL: http://www.dsv.su.se/~jpalme

<Prev in Thread] Current Thread [Next in Thread>