Template:Codeblock

From Wikibooks, open books for an open world
Jump to navigation Jump to search
{{{1}}}

{{{2}}}




Use, Limitations, Parameters, and Options[edit]

Use[edit]


Makes a light grey box for listing code blocks. The main function lies in the POEM tags, and this template simply make a DIV box as a container for the code block. The default font is Fixedsys since it emphasises punctuation well. The box has options to change its appearance. Call it as follows.

{{codeblock|Heading Here|<poem><nowiki>Code Block Here</nowiki></poem>}}

NOTE THE USE OF NOWIKI AND POEM TAG PAIRS.

It looks like this:

Wikitext Code for a Colored Table

{| style="background:lightyellow; color:red; border-top:1px solid gray; border-right:1px solid black; border-bottom:1px solid black; border-left:1px solid gray;" cellspacing=0 cellpadding=5px align=left width=70%
  |+ Top Caption Goes Here
|-
  ! style="background:brown;color:white;border-bottom:1.5px solid black"|Heading 1
  ! style="background:brown;color:white;border-bottom:1.5px solid black"|Heading 2
  ! style="background:brown;color:white;border-bottom:1.5px solid black"|Heading 3
|-
  | width=33% style="border-bottom:1px solid gray"|A
  | width=33% style="border-bottom:1px solid gray"|B
  | width=33% style="border-bottom:1px solid gray"|C
|-
  | style="border-bottom:1px solid gray"|D
  | style="border-bottom:1px solid gray"|E
  | style="border-bottom:1px solid gray"|F
|-
  | style="border-bottom:1.5px solid black"|G
  | style="border-bottom:1.5px solid black"|H
  | style="border-bottom:1.5px solid black"|I
|}

Notice in particular that the long code lines have been wrapped while the other spacings have been preserved.

Limitations[edit]


The <nowiki></nowiki> tags must immediately surround the code block and <poem></poem> tags must be added outside of these.


Parameters[edit]


There are two parameters which may be called by either their numbers or their label names.

1
Parameter heading: Enter text for the top title for the code.
2
Parameter content: Enter the code block and surround it in <nowiki></nowiki> tags.


Options[edit]


width
width of the box, default auto.
align
horizontal position of the box, default left.
margin
margins of the box, default 0 0 0 0, in sequence top, right, bottom, and left.
background
the background color of the box, default rgb(230,230,230), a light grey.
color
text color, default rgb(55,55,55), a dark grey.
ff
font family, default fixedsys, since it has good clarity.
border
the perimeter border of the box, default 1px solid rgb(220,220,220), shade of grey.
padding
text padding, default 10px 15px 15px 15px in sequence top, right, bottom, left.