Template:Code

From Terraria Wiki
Jump to navigation Jump to search
Template-info.svg Documentation The documentation below is transcluded from Template:Code/doc. (edit | history)

This template displays some short code in a monospace font to make it stand out from surrounding text. Using the <code></code> tags instead of this template is generally preferable. The template is based on Template:Code from Wikipedia.

Usage

{{ code | <code to display> | class = <CSS class> | style = <custom styling> | id = <ID attribute> | lang = <programming language> }}

First unnamed parameter

The code to display.

class

Additional class or classes for styling the resulting element via CSS.

style

Custom inline styling of the resulting element.

id

ID attribute of the resulting element.

lang

Programming language of the code. The code will be highlighted accordingly, using the Pygments syntax highlighter. A full list of available languages can be found in the Pygments documentation. The values listed under "Short names" for each of the languages there are the values that can be used for this parameter. For example, to highlight the code according to C# syntax, the possible values are csharp, c#, and cs.

Examples

Code Result
{{code|Hello world}} Hello world
{{code|lang=css|border:1px solid #fff}} border:1px solid #fff