Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
 
(35 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<noinclude>{{doc|0}}</noinclude>__NOTOC__
{{Doc/subpage}}__NOTOC__
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.


== Parameters ==
== Parameters and Examples ==
{| class="standard-table"
{| class=standard-table | style="width:100%"
! colspan="2" | Styles
|-
|-
| {{param|desaturated}}
! Parameters
| less saturated version
! {{int:listfiles_description}}
! {{int:apisandbox-examples}}
! {{int:preview}}
|-
|-
| {{param|outlined}}
| align=center | {{Code|{{Param|preset}}}}
| less saturated version with outline&nbsp;
| 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!}}}}
|-
|-
| {{param|clear}}
| align=center | {{Code|{{Param|select}}}}
| no style
| 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;}}
{| class="standard-table"
| {{Capsule|margin=4px|{{Code|select=none|Hello, World!}}}} {{Capsule|margin=4px|{{Code|select=all|Hello, World!}}}}
! colspan="2" | Modifiers
|-
|-
| {{param|select}}
| align=center | {{Code|{{Param|style}}}}
| Sets the values for the user-select parameter.<br><br>'''Values:'''
| CSS styles.
*'''{{Code|1}}''': All (one click selection);  
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|style}}&#61;{{Tint|color=green|color:#EF9B9B}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
*'''{{Code|2}}''': None (template content will not be highlighted);  
| {{Capsule|margin=4px|{{Code|style=color:#EF9B9B|Hello, World!}}}}
*'''{{Code|oneclick}}''': The same to {{Code|1}}. This is to be compatible with templates that are still using old parameters.
|-
|-
| {{param|color}}
| align=center | {{Code|{{Param|highlight}}}}
| allows you to change the color of the text if the default style is enabled
| Adds syntax highlighting for the language specified. {{Bug|Condenses code into one line.}}
| {{CodeBlock|margin=5px|<nowiki>{{Code|highlight=c|int main() {return 0;} }}</nowiki>}}
| {{Capsule|margin=5px|{{Code|highlight=c|int main() {return 0;} }}}}
|-
|-
| {{param|background}}
| allows you to change the background color if the default style is enabled&nbsp;
|}
|}


== Examples ==
{{Doc/Sandbox other|
{{code|<nowiki>{{code|Go to [[Main Page|Main Page]]}}</nowiki>}} {{code|<nowiki>{{code|Go to {{hla|4}}}}</nowiki>}}
[[Category:Templates]]
{{Doc/PreviewBlock|{{code|Go to [[Main Page|Main Page]]}} {{code|Go to {{hla|4}}}}}}
[[Category:Formatting templates]]
 
}}
 
{{code|<nowiki>{{code|desaturated|Go to [[Main Page|Main Page]]}}</nowiki>}} {{code|<nowiki>{{code|desaturated|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{code|desaturated|Go to [[Main Page|Main Page]]}} {{code|desaturated|Go to {{hla|4}}}}}}
 
 
{{code|<nowiki>{{code|outlined|Go to [[Main Page|Main Page]]}}</nowiki>}} {{code|<nowiki>{{code|outlined|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{code|outlined|Go to [[Main Page|Main Page]]}} {{code|outlined|Go to {{hla|4}}}}}}
 
 
{{code|<nowiki>{{code|select=1|background=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}}</nowiki>}} {{code|<nowiki>{{code|background=rgb(40,60,100)|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{code|select=1|background=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}} {{code|background=rgb(40,60,100)|Go to {{hla|4}}}}}}
 
<includeonly>{{sandbox other||
[[Category:Markdown]]
}}</includeonly>

Latest revision as of 19:36, 14 August 2023

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.

Parameters and Examples

Parameters Description Examples Preview
{{{preset}}} Preset Template Styles. The following presets are available:
  • Default – The default style is based on Markdown;
  • 0 – Clear version;
  • 1 – Desaturated version;
  • 2 – Outlined version;
  • 3 – A brighter outlined version.
{{Code|Hello, World!}}
{{Code|preset=0|Hello, World!}}
{{Code|preset=1|Hello, World!}}
{{Code|preset=2|Hello, World!}}
{{Code|preset=3|Hello, World!}}
Hello, World!
Hello, World!
Hello, World!
Hello, World!
Hello, World!
{{{select}}} Text selection mode. Uses the user-select CSS property. Default value is unset.
{{Code|select=none|Hello, World!}}
{{Code|select=all|Hello, World!}}
Hello, World!
Hello, World!
{{{style}}} CSS styles.
{{Code|style=color:#EF9B9B|Hello, World!}}
Hello, World!
{{{highlight}}} Adds syntax highlighting for the language specified.
Icon-Bug.pngBug:Condenses code into one line.  [todo tested in ?]
{{Code|highlight=c|int main() {return 0;} }}
int main() {return 0;}