Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(documented {{highlight}})
mNo edit summary
 
(16 intermediate revisions by 3 users not shown)
Line 2: Line 2:
This template will allow you to format text as a one-line code.
This template will allow you to format text as a one-line code.


== Parameters and Examples ==
== Usage ==
{| class=standard-table | style="width:100%"
<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>
|-
 
{| cellpadding="6" rules="all" style="width:100%; border:1px solid #555; background:#2D2D2D"
|- style="background:#333; color:#DFDFDF"
! Parameters
! Parameters
! {{int:listfiles_description}}
! {{int:Listfiles description}}
! {{int:apisandbox-examples}}
! {{int:Preview}}
! {{int:preview}}
|-
| align=center | {{Code|{{Param|preset}}}}
| 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.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|0}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|1}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|2}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}{{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|preset}}&#61;{{Tint|color=green|3}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Capsule|margin=4px|{{Code|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=0|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=1|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=2|Hello, World!}}}} {{Capsule|margin=4px|{{Code|preset=3|Hello, World!}}}}
|-
| align=center | {{Code|{{Param|select}}}}
| Text selection mode. Uses the {{Code|preset=1|user-select}} CSS property. Default value is {{Code|preset=1|unset}}.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|select}}&#61;{{Tint|color=green|none}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|select}}&#61;{{Tint|color=green|all}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Capsule|margin=4px|{{Code|select=none|Hello, World!}}}} {{Capsule|margin=4px|{{Code|select=all|Hello, World!}}}}
|-
|-
| align=center | {{Code|{{Param|style}}}}
| style="font-family:monospace" | {{P| <Text>}} <br> {{P| 1 | <Text>}}
| CSS styles.
| The text that will be displayed. Can contain links, templates and raw html, except when the {{Param|lang}} parameter is used.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|style}}&#61;{{Tint|color=green|color:#EF9B9B}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| style="background:#262626" | {{Code|Hello, World!}}
| {{Capsule|margin=4px|{{Code|style=color:#EF9B9B|Hello, World!}}}}
|-
|-
| align=center | {{Code|{{Param|highlight}}}}
| style="font-family:monospace" | {{P| lang | <Option>}}
| Adds syntax highlighting for the language specified by {{param|lang}}. {{Bug|Condenses code into one line.}}
| 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]].
| {{CodeBlock|margin=5px|<nowiki>{{Code|lang=c|highlight=1|int main() {return 0;} }}</nowiki>}}
| style="background:#262626" | {{Code|lang=c|int main() { return 0; } }}
| {{Capsule|margin=5px|{{Code|lang=c|highlight=1|int main() {return 0;} }}}}
|-
|-
| style="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|Colored text}}
|}
|}
== See Also ==
* {{T|CodeBlock}}
* {{T|Mono}}


{{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