Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:


== Parameters and Examples ==
== Parameters and Examples ==
{| class=standard-table | style="width:100%"
{| class="standard-table" | style="width:100%"
|-
|-
! style="width:10%" | Parameters
! style="width:12%" | Parameters
! {{int:listfiles_description}}
! {{int:listfiles_description}}
! colspan="2" style="width:20%" | {{int:apisandbox-examples}}
! style="width:20%" | {{int:preview}}
! colspan="2" style="width:20%" | {{int:preview}}
|-
|-
| rowspan="2" style="vertical-align:top; text-align:center" | <code>{{param|1}}</code>
| style="padding:10px; background:#222; font-family:monospace" | {{P| <Text>}} <br> {{P| 1 | <Text>}}
| rowspan="2" style="vertical-align:top" | Text.
| The text that will be displayed. Can contain links, templates and raw html, except when the {{Param|lang}} parameter is used.
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| Hello, World!</pre>
| style="background:#262626" | {{Code|Hello, World!}}
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|Hello, World!}}</nowiki>" | (?)
| rowspan="2" style="background-color:#262626" | {{Code|Hello, World!}}
|-
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| 1 = Hello, World!</pre>
| style="padding:10px; background:#222; font-family:monospace" | {{P| lang | <Option>}}
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|1=Hello, World!}}</nowiki>" | (?)
| Adds syntax highlighting for the language specified using [[mw:Extension:SyntaxHighlight|syntaxhighlight]] tag with [[mw:Extension:SyntaxHighlight#inline|inline]] attribute. <br> [[mw:Extension:SyntaxHighlight#Supported_languages|List of Supported languages]].
|-
| style="background:#262626" | {{Code|lang=c|int main() {return 0;} }}
| rowspan="5" style="vertical-align:top; text-align:center" | <code>{{param|preset}}</code>
| rowspan="5" style="vertical-align:top" | Preset Template Styles. The following presets are available:
:* {{Code|preset=0|Default}} – The default style is based on Markdown;
:* {{Code|preset=1|0}} – Clear version;
:* {{Code|preset=1|1}} – Desaturated version;
:* {{Code|preset=1|2}} – Outlined version;
:* {{Code|preset=1|3}} – A brighter outlined version.
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| preset = 0</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|preset=0|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|preset=0|Hello, World!}}
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| preset = 1</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|preset=1|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|preset=1|Hello, World!}}
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| preset = 2</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|preset=2|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|preset=2|Hello, World!}}
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| preset = 3</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|preset=3|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|preset=3|Hello, World!}}
|-
| rowspan="3" style="vertical-align:top; text-align:center" | <code>{{param|select}}</code>
| rowspan="3" style="vertical-align:top" | Text selection mode.
 
Uses the {{Code|preset=1|user-select}} CSS property.
 
Default value is {{Code|preset=1|unset}}.
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| select = none</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|select=none|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|select=none|Hello, World!}}
|-
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| select = all</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|select=all|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|select=all|Hello, World!}}
|-
| style="vertical-align:top; text-align:center" | <code>{{param|style}}</code>
| style="vertical-align:top" | CSS styles.
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| style = color:#EF9B9B</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|style=color:#EF9B9B|Hello, World!}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|style=color:#EF9B9B|Hello, World!}}
|-
| style="vertical-align:top; text-align:center" | <code>{{param|highlight}}</code>
| style="vertical-align:top" | Adds syntax highlighting for the language specified. {{Bug|Condenses code into one line.|hidetested=true}}
| style="background-color:#1f1f1f; border-right:0; font-family:monospace" | <pre style="margin:0">| highlight = c</pre>
| style="background-color:#1f1f1f; border-left:0; font-family:monospace; text-align:center; color:#8d8c8b; cursor:help" title="<nowiki>{{Code|highlight=c|int main() {return 0;}}}</nowiki>" | (?)
| style="background-color:#262626" | {{Code|highlight=c|int main() {return 0;} }}
|-
|-
| style="padding:10px; background:#222; font-family:monospace" | {{P| style | <CSS>}}
| CSS styles. Note that some styles require {{Code|!important}} to be specified.
| style="background:#262626" | {{Code|style=color:#EF9B9B !important|Hello, World!}}
|}
|}



Revision as of 10:45, 16 October 2025

Edit-copy.png
This is a documentation subpage for Template:Code.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This template will allow you to format text as a one-line code.

Usage

This template is usually written in a single line. To use it, insert {{Code}} into the desired page and specify the parameters to the right of the template name in the following format: {{Code|parameter 1 = value|parameter 2 = value}}.

Parameters and Examples

Parameters Description Preview
| <Text>
| 1 = <Text>
The text that will be displayed. Can contain links, templates and raw html, except when the {{{lang}}} parameter is used. Hello, World!
| lang = <Option> Adds syntax highlighting for the language specified using syntaxhighlight tag with inline attribute.
List of Supported languages.
int main() {return 0;}
| style = <CSS> CSS styles. Note that some styles require !important to be specified. Hello, World!

See Also