Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{Documentation subpage}} <!-- Please place categories where indicated at the bottom of this page.) --> ;Description This template wraps the text provided to it in code tags....")
 
No edit summary
 
(41 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Doc/subpage}}__NOTOC__
<!-- Please place categories where indicated at the bottom of this page.) -->
This template will allow you to format text as a one-line code.
;Description
This template wraps the text provided to it in code tags. Taken from the [https://www.pcgamingwiki.com/wiki/Template:Code/Documentation PCGamingWiki] template.


;Arguments
== Parameters and Examples ==
* <code>1</code> - text used.
{| class=standard-table | style="width:100%"
|-
! Parameters
! {{int:listfiles_description}}
! {{int:apisandbox-examples}}
! {{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}}}}
| CSS styles.
| {{CodeBlock|&#123;&#123;Code&#124;{{Tint|color=yellow|style}}&#61;{{Tint|color=green|color:#EF9B9B}}&#124;{{Tint|color=comment|Hello, World!}}&#125;&#125;}}
| {{Capsule|margin=4px|{{Code|style=color:#EF9B9B|Hello, World!}}}}
|-
| align=center | {{Code|{{Param|highlight}}}}
| 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;} }}}}
|-
|}


;Syntax
{{Doc/Sandbox other|
<pre><nowiki>{{Code|1}}</nowiki></pre>
[[Category:Templates]]
 
[[Category:Formatting templates]]
 
}}
<includeonly>{{sandbox other||
<!-- Categories below this line, please -->
 
}}</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;}