Template:Codebox
Displays a block element containing code, optionally providing syntax highlighting. A list of recognized languages for syntax highlighting can be found here.
{{#msg:template-important|Codebox}}
Your contents may contain special characters (
Your contents may contain special characters (
|
or =
) that break the MediaWiki templating system. You have these options to put the contents (in order from preferred to rather-not-use) if you need to escape these characters:
{{CodeBox|1=contents}}
{{CodeBox|<nowiki>contents</nowiki>}}
{{CodeBox|<pre>contents</pre>}}
(Syntax highlighting is broken using this invocation!)
Parameters
Parameter name | Required? | Default value | Description |
---|---|---|---|
Anonymous parameter 1 |
Yes | (n/a) | Code |
title |
No | (n/a) | Additional title to display in the box header |
lang |
No | text |
Language of the contents, used for syntax highlighting |
Usage
See the template's testcases:
No parameter | |
---|---|
Wiki code | {{CodeBox}}
|
Main version | Codebox}} {{{1}}} |
Sandbox version | Template:CodeBox/sandbox |
Parameters: 1=Some code. | |
---|---|
Wiki code | {{CodeBox|1=Some code.}}
|
Main version | Codebox}} Some code. |
Sandbox version | Codebox}} Some code. |
Parameters: title=CodeBox example with title, 1=And with some code. | |
---|---|
Wiki code | {{CodeBox|title=CodeBox example with title|1=And with some code.}}
|
Main version | Codebox}} CodeBox example with tileAnd with some code. |
Sandbox version | Codebox}} CodeBox example with titleSome code. |
Parameters: title=CodeBox example with title, lang=bash, 1=#!/bin/bash echo "Hello, world!" | |
---|---|
Wiki code | {{CodeBox|title=CodeBox example with title|lang=bash|1=#!/bin/bash
echo "Hello, world!"
}}
|
Main version | Codebox}} CodeBox example with title
|
Sandbox version | Codebox}} CodeBox example with title
|
See also
The above documentation is transcluded from Template:Codebox/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |