Template:Code

From Audacity Wiki
Jump to: navigation, search
The Code Template is intended to enclose lines or blocks of programming code, mathematical formulas, regular expressions and similar inside a thin box with pink text of slightly larger size than the rest of the page content.


The template provides a replacement for placing code inside <code></code> tags which produces an extremely faint pink background color:

this is not distinct enough

This template also avoids the troublesome excessive line length that can result from the traditional Wiki method of showing code by adding a space in front of a line thus:

this is going to become far too long...
Wrapping code inside <code></code> tags may look better than using Template:Code if your code is inside a colored div such as provided by Template:Hint or Template:Advice.

Although part of the line length saving comes from a smaller character spacing, the text does wrap, so this template is not appropriate if the code you are representing depends on unbroken lines.


NOTE: This template should be used only for code, formulas, regular expressions and closely related content. Other templates are available for other uses, see Category:Templates.


Usage of Template:Code:

{{code|text to be formatted}}


For example, typing this:

 {{code|$c: // (-%7)}}


will cause the following to be displayed:

$c: // (-%7)


Breaks and spaces: This template is a left-indented HTML table, so:

  • text will automatically wrap round to the next line when it
    reaches the end of the line.
  • if you want to force a break in the text, use <BR> in preference,
    because entering a carriage return may give variable results.
    A carriage return will enforce a new paragraph, so give a greater
    space between lines than <BR>, but further down the table
    you may need to use two carriage returns to force a new paragraph.
  • more than one space in the text will be ignored, so use the &nbsp;
    entity to force an extra space between characters.


IMPORTANT NOTE: Wiki parsing issues mean that using some symbols inside a template "call" might cause your intended code to not display properly. The equals sign (=) is a known offender. If you have problems, enclose the text part of the call inside <nowiki></nowiki> tags. For example, to display this:

$c = (%7) + (%4)


you need to type this:

{{code|<nowiki>$c = (%7) + (%4)</nowiki>}}


or alternatively if an equals sign is the problem, type "1=" (without quotes) after the pipe:

{{code|1=$c = (%7) + (%4)}} 


Using Template:Code in bulleted or ordered lists:

Optionally you can use:

{{codelist|text to be formatted}}  

instead of Template:Code when inserting code in lists. Using the codelist template, the code will be indented a little further into the body of the page.



Ignore the following, it's only a representation of formatting and a parameter dummy.

{{{1}}}
Personal tools

Donate securely by PayPal, using your credit card or PayPal account!