Template:Code: Difference between revisions
No edit summary |
Fix HTML escaping in code blocks: ensure > is preserved in Template:Code |
||
| Line 1: | Line 1: | ||
<includeonly> | <includeonly><syntaxhighlight lang="{{{lang|text}}}" {{#if:{{{line|}}}|line=""}} {{#if:{{{highlight|}}}|highlight={{{highlight}}}}} {{#ifeq:{{{copy|yes}}}|yes|copy=""}}>{{{1}}}</syntaxhighlight></includeonly><noinclude>{{Documentation}}</noinclude> | ||
Revision as of 14:39, 1 April 2026
Template Documentation [edit source| uses| help]
Use this template to show code that has syntax highlighting.
{{{1}}}Usage
Include this template, specifying the language and code that should be displayed:
{{{1}}}You can disable the "Copy" button by setting the parameter to 'no':
{{{1}}}This would result in:
{{{1}}}You can disable line numbers by setting the line parameter to 'no':
{{{1}}}This would result in:
{{{1}}}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 'no'.
| Boolean | optional |
| Show copy button? | copy | By default, a 'Copy' button will be shown in the top right corner; you can override this setting by setting its value to 'no'.
| 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 |