|
Cookbook /
WordWrapPreformattedTextSummary: Prevent long lines of text stretching beyond the window edge
Version:
Prerequisites:
Status:
Maintainer:
Categories: Administration
QuestionHow can I prevent long lines of text stretching beyond the window edge? AnswerLines of text which do not wrap automatically at the window edge have most likely empty spaces at the beginning of the paragraph (by design or accident), which makes pmwiki treat them as preformatted text. Preformatted text does not get wrapped by default. There are a number of approaches you can use to wrap preformatted text. MarkupYou can force word-wrapping of preformatted text with the following markup. Include it in config.php. No markup needs to be inserted in the page, and the original text does not get altered. # wrap preformatted text at max 75 characters:
Markup('^ws', 'block',
'/^(\\s+)(.*)$/e',
"'<:pre,1>$1'.wordwrap(PSS('$2'), 75, '\n$1')");
If a different maximum width is required just change the number in the markup. OverflowAnother approach uses stylesheets to add scrollbars to text that exceeds container edge. Simply add the following to your skin's stylesheet: pre
{
overflow: scroll;
}
Browser wrappingThe forthcoming CSS3 specifies pre
{
white-space: pre-wrap; /* CSS-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
No formattingFinally, if no preformatted text is wanted/needed on the site, it can be turned off all together, by setting in config.php: # turn off preformatting
Notes and Comments
See AlsoContributors
JLuk 2008-Jan-15 Does not appear to work with the current stable release pmwiki-2.1.27. Gary Levin March 02, 2006, at 01:19 PM
This recipe is not working on "pmwiki-2.1.beta20". DisableMarkup does not prevent the formatting. And the pattern in the Markup does not match. It is easy to see by making the replacement string not a legal expression, which will result in an error if the replacement is attempted and no error shows up. It appears that the start of line anchor ( Ah yes, I suspect that the problem is that this recipe interferes with the "leading whitespace rule" that was introduced in 2.1.beta1. I'll have to see about updating the recipe. (Update me) --Pm Subhash: November 11, 2006, at 7:30 PM
Wrappig works for me with pmwiki-2.2.0-beta15. Is there a suggestion how to turn off pre formatting by leading whitespace now? "Naive Users" are preformatting and don't know what to do against it. I would like to keep everything very very simple. Thanks! – Subhash (office [at] subhash [dot] at) Ian MacGregor May 23, 2007 pre If the content is clipped, the browser should display a scroll bar to see the rest of the content - scrollbar shouldn't be displayed if content isn't clipped. Using
|