Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(updated descriptions for {{{bg}}})
mNo edit summary
Line 2: Line 2:
This template will allow you to format text as a one-line code. The default style is based on Markdown.
This template will allow you to format text as a one-line code. The default style is based on Markdown.


== Parameters ==
== Parameters and Examples ==
{| class="standard-table"
{| class=standard-table | style="width:100%;"
! colspan="2" | Modifiers
|-
|-
| {{param|select}}
! Parameter
| Sets the values for the user-select parameter.<br><br>'''Values:'''
! Description
*'''{{Code|1}}''': All (one click selection);
! Example
*'''{{Code|2}}''': None (template content will not be highlighted).
! Preview
|-
|-
| {{param|color}}
| align="center" | {{Code|{{param|style}}}}
| Allows you to change the color of the text if the default style is enabled.
| The style of the template. The following styles are available:
:* {{Code|select=1|1}} - Outlined version. Does not support {{param|bg}} and {{param|color}}.
:* {{Code|select=1|2}} - Desaturated version. Does not support {{param|bg}} and {{param|color}}.
:* {{Code|select=1|3}} - Clear version. Does not support {{param|bg}} but supports {{param|color}}.
:* {{Code|style=3|Default}} - the default style is based on Markdown and supports the {{param|bg}} and {{param|color}} parameters.
| {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|style}}<nowiki>=</nowiki>{{tint|color=green|1}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|style}}<nowiki>=</nowiki>{{tint|color=green|2}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|style}}<nowiki>=</nowiki>{{tint|color=green|3}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Doc/PreviewBlock|margin=5px|{{Code|style=1|Hello, World!}}}} {{Doc/PreviewBlock|margin=5px|{{Code|style=2|Hello, World!}}}} {{Doc/PreviewBlock|margin=5px|{{Code|style=3|Hello, World!}}}}
|-
|-
| {{param|bg}}
| align="center" | {{Code|{{param|select}}}}
| Allows you to change the background color if the default style is enabled.&nbsp;It is the same to {{param|tag=kbd|background}}. {{Note|If both {{param|tag=kbd|background}} and {{param|tag=kbd|bg}} are present, {{param|tag=kbd|bg}} is preferred.}}
| Text selection mode. The following values are available:
:# {{Code|select=1|1}} - All (one click selection);
:# {{Code|select=1|2}} - None (template content will not be highlighted).
| {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|select}}<nowiki>=</nowiki>{{tint|color=green|1}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}} {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|select}}<nowiki>=</nowiki>{{tint|color=green|2}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Doc/PreviewBlock|margin=5px|{{Code|select=1|Hello, World!}}}} {{Doc/PreviewBlock|margin=5px|{{Code|select=2|Hello, World!}}}}
|-
| align="center" | {{Code|{{param|color}}}}
| Text color. <br> HSL, HEX, RGB and more are supported.
| {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|color}}<nowiki>=</nowiki>{{tint|color=green|#FFFFFF}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Doc/PreviewBlock|margin=5px|{{Code|color=#FFFFFF|Hello, World!}}}}
|-
| align="center" | {{Code|{{param|bg}}}}
| Background color. <br> HSL, HEX, RGB and more are supported.
| {{CodeBlock|&#123;&#123;Code&#124;{{tint|color=yellow|bg}}<nowiki>=</nowiki>{{tint|color=green|rgba(144,42,38,.35)}}&#124;{{tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Doc/PreviewBlock|margin=5px|{{Code|bg=rgba(144,42,38,.35)|Hello, World!}}}}
|-
|-
| {{param|style}}
| Allows you to change the style of the template from existing styles:
*'''{{Code|1}}''': less saturated version ({{param|tag=kbd|desaturated}})
*'''{{Code|2}}''': less saturated version with outline&nbsp;({{param|tag=kbd|outlined}})
*'''{{Code|3}}''': {{Code|select=1|<nowiki><kbd></nowiki>}} tag version, {{param|tag=kbd|color}} is available
*Default: default style.
|}
|}
== Examples ==
{{Code|<nowiki>{{Code|Go to [[Main Page|Main Page]]}}</nowiki>}} {{Code|<nowiki>{{Code|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{Code|Go to [[Main Page|Main Page]]}} {{Code|Go to {{hla|4}}}}}}
{{Code|<nowiki>{{Code|style=2|Go to [[Main Page|Main Page]]}}</nowiki>}} {{Code|<nowiki>{{Code|style=2|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{Code|style=2|Go to [[Main Page|Main Page]]}} {{Code|style=2|Go to {{hla|4}}}}}}
{{Code|<nowiki>{{Code|style=1|Go to [[Main Page|Main Page]]}}</nowiki>}} {{Code|<nowiki>{{Code|style=2|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{Code|style=1|Go to [[Main Page|Main Page]]}} {{Code|style=2|Go to {{hla|4}}}}}}
{{Code|<nowiki>{{Code|select=1|bg=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}}</nowiki>}} {{Code|<nowiki>{{Code|bg=rgb(40,60,100)|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{Code|select=1|bg=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}} {{Code|bg=rgb(40,60,100)|Go to {{hla|4}}}}}}


<includeonly>{{sandbox other||
<includeonly>{{sandbox other||
[[Category:Markdown]]
[[Category:Markdown]]
}}</includeonly>
}}</includeonly>

Revision as of 14:46, 23 January 2023

English (en)Deutsch (de)Esperanto (eo)Español (es)Français (fr)Suomi (fi)Hrvatski (hr)Magyar (hu)Italiano (it)日本語 (ja)한국어 (ko)Nederlands (nl)Polski (pl)Português (pt)Português do Brasil (pt-br)Русский (ru)Slovenčina (sk)Svenska (sv)Türkçe (tr)Українська (uk)Tiếng Việt (vi)中文 (zh)中文(臺灣) (zh-tw)
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. The default style is based on Markdown.

Parameters and Examples

Parameter Description Example Preview
{{{style}}} The style of the template. The following styles are available:
  • 1 - Outlined version. Does not support {{{bg}}} and {{{color}}}.
  • 2 - Desaturated version. Does not support {{{bg}}} and {{{color}}}.
  • 3 - Clear version. Does not support {{{bg}}} but supports {{{color}}}.
  • Default - the default style is based on Markdown and supports the {{{bg}}} and {{{color}}} parameters.
{{Code|style=1|Hello, World!}}
{{Code|style=2|Hello, World!}}
{{Code|style=3|Hello, World!}}
Hello, World!
Hello, World!
Hello, World!
{{{select}}} Text selection mode. The following values are available:
  1. 1 - All (one click selection);
  2. 2 - None (template content will not be highlighted).
{{Code|select=1|Hello, World!}}
{{Code|select=2|Hello, World!}}
Hello, World!
Hello, World!
{{{color}}} Text color.
HSL, HEX, RGB and more are supported.
{{Code|color=#FFFFFF|Hello, World!}}
Hello, World!
{{{bg}}} Background color.
HSL, HEX, RGB and more are supported.
{{Code|bg=rgba(144,42,38,.35)|Hello, World!}}
Hello, World!