Templat:Prettypre
Use, Limitations, and Options
[sunting]Use
[sunting]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 A | Result A | |
---|---|---|
{{Prettypre||border=1px solid gray|background:lightyellow|font=monospace|color=green|
a b c d e |
a b c d e f g h i j k l m n o p q r s t u v w x y z |
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:
[[:Templat:Pretext]]
Limitations
[sunting]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
[sunting]- 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%