Template:Code: Difference between revisions
Jump to navigation
Jump to search
en.wikipedia>Bsherr m (adding comment) |
(Undo revision 4546304 by 79.120.171.89 (talk)) |
||
Line 1: | Line 1: | ||
{{#if:{{{inline|}}}|<code {{#if:{{{class|}}}|class="{{{class}}}"}} {{#if:{{{id|}}}|id="{{{id}}}"}} {{#if:{{{style|}}}|style="{{{style}}}"}}>{{#tag:syntaxhighlight|{{{code|{{{1}}}}}}|lang="{{{lang|{{{2|text}}}}}}"|inline=true}}</code>|{{#if:{{{header|}}}|<u><small>{{{header}}}</small></u>}}{{#tag:syntaxhighlight |
|||
{{#tag:syntaxhighlight|{{{code|{{{1}}}}}}|lang={{{lang|{{{2|text}}}}}}|class={{{class|}}}|id={{{id|}}}|style={{{style|}}}|inline=1}}<noinclude> |
|||
|{{{code|{{{1}}}}}} |
|||
|lang={{{lang|{{{2|bash}}}}}} |
|||
}}}}<noinclude> |
|||
{{documentation}} |
{{documentation}} |
||
<!-- Add categories to the /doc subpage, interwikis to Wikidata, not here --> |
|||
</noinclude> |
</noinclude> |
Revision as of 19:56, 26 April 2021
{{{1}}}
File:Test Template Info-Icon - Version (2).svg Template documentation[view] [edit] [history] [purge]
Usage
This is a semantic markup wrapper template for the HTML element <code>...</code>
. It can be used without a parameter to wrap code in a formatted block, with syntax highlighting, or with Template:Para for a leaner presentation.
Example:
{{code|lang=css|font-family: 'Times New Roman', serif;}}
produces:
font-family: 'Times New Roman', serif;
Inline:
{{code|inline=y|lang=css|font-family: 'Times New Roman', serif;}}
produces:
font-family: 'Times New Roman', serif;
and is equivalent to:
<syntaxhighlight inline lang="css">font-family: 'Times New Roman', serif;</syntaxhighlight>
TemplateData
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. Click here to see a monthly parameter usage report for this template in articles based on this TemplateData.
TemplateData for Code
A block or inline source code string.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Language | lang 2 | The programming language of the source code. List of valid values is at: Extension:SyntaxHighlight#Supported_languages
| String | suggested |
Inline? | inline | Whether to use inline formatting
| String | optional |
Class | class | Applies only if `inline=true` | String | optional |
ID | id | Applies only if `inline=true` | String | optional |
CSS Style | style | Applies only if `inline=true` | String | optional |
Header | header | Applies only if `inline` is not set | Line | optional |
Code | 1 code | The code to display. | String | required |
See also
- {{inline-code}}