Template:Code/Doc: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
Line 24: | Line 24: | ||
{{code|lang=mediawiki|line=no|Some code}} | {{code|lang=mediawiki|line=no|Some code}} | ||
=== Template data === | |||
<templatedata> | |||
{ | |||
"description": "Display a block of code", | |||
"params": { | |||
"lang": { | |||
"label": "Programming language", | |||
"description": "The programming language used in the block of code", | |||
"type": "string", | |||
"suggested": true | |||
}, | |||
"line": { | |||
"label": "Show line numbers?", | |||
"description": "By default, the block of code will show line numbers. You can disable this by setting this value to false.", | |||
"type": "boolean" | |||
}, | |||
"highlight": { | |||
"label": "Highlight lines", | |||
"description": "You can supply a comma-delimited list of lines to highlight. E.g.: 1,7,13-15", | |||
"type": "string" | |||
}, | |||
"1": { | |||
"label": "Content", | |||
"description": "The content to be shown in the block of code", | |||
"type": "string", | |||
"required": true | |||
} | |||
} | |||
} | |||
</templatedata> |
Revision as of 17:02, 11 June 2025
Use this template to show code that has syntax highlighting.
Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]
Usage
Include this template, specifying the language and code that should be displayed:
{{code|lang=mediawiki|Some code with [[:Wikipedia:Syntax highlighting|syntax highlighting]]}}
You can disable the "Copy" button by setting the parameter to 'no':
{{code|lang=mediawiki|copy=no|Some code}}
This would result in:
Some code
You can disable line numbers by setting the line
parameter to 'no':
{{code|lang=mediawiki|line=no|Some code}}
This would result in:
Some code
Template data
Display a block of code
Parameter | Description | Type | Status | |
---|---|---|---|---|
Programming language | lang | The programming language used in the block of code | String | suggested |
Show line numbers? | line | By default, the block of code will show line numbers. You can disable this by setting this value to false. | Boolean | optional |
Highlight lines | highlight | You can supply a comma-delimited list of lines to highlight. E.g.: 1,7,13-15 | String | optional |
Content | 1 | The content to be shown in the block of code | String | required |