Template:Prettypre

Use
Similar in use to the existing preformatting tags, but with styling options. The code to call the template and the result is shown below.

Example B:

The preformatted text template Pretext is used here as a parameter of Prettypre to show the formats; the template is called for use with: Result B:

Limitations
There is a slight control of how overflow is handled, though care is still needed to shorten the preformatted text to fit the page, if it is not to project beyond the right border.

For those looking for a method to wrap long lines but preserve preformatting of other lines, the CSS Pre-wrap value of the White-space property will do this;  at present Opera 8 and beyond support the value, Firefox 3 onwards supports it, and I am uncertain about Internet Explorer 7. Please consider these browser compatibility issues before modifying the code.

Options

 * align: text alignment; left, right, or center. Default: left.
 * border: border, takes format eg; 1px solid black. Default: 0px.
 * background: block background color. Any. Default: transparent to give same as page.
 * color: font or foreground color. Any. Default: inherit from page
 * font: font family, size, style, etc. Default: inherit from page
 * overflow: sets how to handle text overflow. Visible, hidden, scroll, auto. Default: auto.
 * style: allow complete control over styling the preformatted box
 * width: block width, default 100%