Various methods to handle long lines of text

Sometimes the lines inside <source> elements are too wide, which can make the resulting pages too wide to view on screen or to print. The width of the long source line causes the whole page layout to be that same width. A web page that is wider than the screen is a complete bastard to read - you have to scroll right and left all the time. And printing in landscape orientation is not very nice either. (See Bugzilla report 23796.)

We need to find a way to consistently split lines that are too wide. Here are demonstrations of various solutions. Each one has pros and cons. Please help to enhance these solutions so that one can soon be implemented. (See Notes below.)

Of course, there is the workaround solution to edit the offending source elements to specifically break long lines. Not good for automated solutions or separation of concerns.

The following examples are deliberately extreme to ensure that the issues are triggered.

Using no special handling

No special handling was done for the <source> elements. The content is wrapped with a <pre> element. Note the long right-left scrollbar.

Using the "split.xsl" stylesheet

All <source> elements had their long lines split by the included split.xsl stylesheet. The content is wrapped with a <pre> element.

Note: In past Cocoons this stylesheet has been reported to be a memory hog on certain Java JDKs. How does it go for you?

Using the "wrap2para.xsl" stylesheet

Only <source> elements that did not contain an xml content model, had their long lines handled by the included wrap2para.xsl stylesheet. Such lines are each wrapped with a styled <p> element.

Other notes

Suggested enhancements include: using the @type attribute; "content sniff"; ...

There may be some other solutions. Suggestions include the Chaperon Block and maybe the Slop Block.

See the Bugzilla report and the cocoon-dev and forrest-dev mail lists.

Some testcase documents ...