Template:Code/doc

Usage
This template wraps a short span of text in  tags (see SyntaxHighlight extension). This template should be used for short samples; longer content should use  or  tags directly. See the wiki markup help page for an explanation of what the various tags do.

If the content includes an equality sign, you must specify the parameter name explicitly as  , as in.

The template uses the tag, indicating that it contains only a single line of code rather than an entire code block. This works like the combination of the  tags, applied to the expanded wikitext. For example, will not render the word "wiki" in bold, and will render the tripled single-quotes as typed:


 * some wiki text

However, will still invoke the Example template:


 * The template call

To prevent this from occurring, as in the case of writing documentation pages that need code examples of what certain wikitext template invocations should look like, use  tags around the template name to avoid this problem:



When used inline with regular text, generally looks best and is easiest to read when it is explicitly spaced apart from the surrounding words on both sides:
 * foo bar baz quux.

…is well spaced…
 * foo bar baz  quux.

…versus…
 * foo bar baz quux

…which is going to be visually confusing for many…
 * foo bar baz quux

…because "foo" and "bar" will seem more closely associated than "bar" and "baz". This stems from the fact that the width of the space character in a monospaced font is almost always larger than in a proportional font.

Use the 2 parameter (unnamed, as 2, or more explicitly as lang) to specify a source code language for the SyntaxHighlight extension. This option defaults to plain text, i.e. with no colored highlighting. There is no highlighting option for wikitext as a markup language, though html4strict and html5 are valid values, as are php, perl, css, javascript, mysql and many others. Attempting to use an invalid one causes a list of valid ones to be displayed in place of the template output, when the page is previewed or saved.

This template does not need to be substituted.

Examples
{|

Included templates
Embedded templates do not function as expected inside Code; for longer, free-form blocks of code, which can contain templates such as Var and Samp, use  tags as a wrapper instead of this template.

Templates used inside Code expose the rendered HTML—this can be useful. For example: The above example shows the HTML rendered by the Citation template, including the hidden metadata.