Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
 
(11 intermediate revisions by 2 users not shown)
Line 3: Line 3:


== Usage ==
== Usage ==
{{Template usage example|inline}}
<div style="margin:-6px 0 6px"><span style="display:inline-block; width:22px; height:16px; background:#FFF; vertical-align:text-bottom; clip-path:path('M0 4v8H1V4ZM9 4v8h1V4ZM3 6v4H7V6Zm9 0v4h4V6Z')"></span>This template prefers inline formatting of parameters</div>


== Parameters and Examples ==
{| cellpadding="6" rules="all" style="width:100%; border:1px solid #555; background:#2D2D2D"
{| class=standard-table | style="width:100%"
|- style="background:#333; color:#DFDFDF"
|-
! Parameters
! Parameters
! {{int:listfiles_description}}
! {{int:Listfiles description}}
! {{int:apisandbox-examples}}
! {{int:Preview}}
! {{int:preview}}
|-
|-
| rowspan="2" style="text-align:center" | <code>{{param|1}}</code>
| style="font-family:monospace" | {{P| <Text>}} <br> {{P| 1 | <Text>}}
| rowspan="2" | 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; font-family:monospace" | <pre style="margin:0">| Hello, World!</pre>
| style="background:#262626" | {{Code|Hello, World!}}
| rowspan="2" style="background-color:#262626" | {{Code|Hello, World!}}
|-
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| 1 = Hello, World!</pre>
| style="font-family:monospace" | {{P| lang | <Option>}}
| 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="text-align:center" | <code>{{Param|preset}}</code>
| style="font-family:monospace" | {{P| style | <CSS>}}
| rowspan="5" | Preset Template Styles. The following presets are available:
| CSS styles. Note that some styles require {{Code|!important}} to be specified.
:* {{code|preset=0|Default}} – The default style is based on Markdown;
| style="background:#262626" | {{Code|style=color:#EF9B9B !important|Colored text}}
:* {{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; font-family:monospace" | <pre style="margin:0">| preset = 0</pre>
| style="background-color:#262626" | {{code|preset=0|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 1</pre>
| style="background-color:#262626" | {{code|preset=1|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 2</pre>
| style="background-color:#262626" | {{code|preset=2|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| preset = 3</pre>
| style="background-color:#262626" | {{code|preset=3|Hello, World!}}
|-
| rowspan="3" style="text-align:center" | <code>{{Param|select}}</code>
| rowspan="3" | Text selection mode.
 
Uses the {{code|preset=1|user-select}} CSS property.


Default value is {{code|preset=1|unset}}.
== See Also ==
|-
* {{T|CodeBlock}}
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| select = none</pre>
* {{T|Mono}}
| style="background-color:#262626" | {{code|select=none|Hello, World!}}
|-
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| select = all</pre>
| style="background-color:#262626" | {{code|select=all|Hello, World!}}
|-
| style="text-align:center" | <code>{{Param|style}}</code>
| CSS styles.
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| style = color:#EF9B9B</pre>
| style="background-color:#262626" | {{code|style=color:#EF9B9B|Hello, World!}}
|-
| style="text-align:center" | <code>{{Param|highlight}}</code>
| Adds syntax highlighting for the language specified. {{Bug|Condenses code into one line.}}
| style="background-color:#1f1f1f; font-family:monospace" | <pre style="margin:0">| highlight = c</pre>
| style="background-color:#262626" | {{code|highlight=c|int main() {return 0;} }}
|-
|}


{{Doc/Sandbox other|
{{Doc/Sandbox other|

Latest revision as of 08:22, 21 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 prefers inline formatting of parameters
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. Colored text

See Also