Template:Code/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(40 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 in Markdown style.
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}} || less saturated version
! Parameters
! {{int:listfiles_description}}
! {{int:apisandbox-examples}}
! {{int:preview}}
|-
|-
| {{param|outlined}} || less saturated version with outline&nbsp;
| 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!}}}}
|-
|-
| {{param|clear}} || no style
| align=center | {{Code|{{Param|select}}}}
|}
| Text selection mode. Uses the {{Code|preset=1|user-select}} CSS property. Default value is {{Code|preset=1|unset}}.
{| class="standard-table"
| {{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;}}
! colspan="2" | Modifiers
| {{Capsule|margin=4px|{{Code|select=none|Hello, World!}}}} {{Capsule|margin=4px|{{Code|select=all|Hello, World!}}}}
|-
|-
| {{param|select}} || Sets the values for the user-select parameter.<br><br>'''Values:''' <br>'''1''' - all (one click selection), <br>'''2''' - none (template content will not be highlighted).
| 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!}}}}
|-
|-
| {{param|color}} || allows you to change the background color if the default style is enabled&nbsp;
| 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;} }}}}
|-
|-
| {{param|background}} || allows you to change the color of the text if the default style is enabled
|}
|}


== Examples ==
{{Doc/Sandbox other|
{{MdCode|<nowiki>{{MdCode|Go to [[Main Page|Main Page]]}}</nowiki>}} {{MdCode|<nowiki>{{MdCode|Go to {{hla|4}}}}</nowiki>}}
[[Category:Templates]]
{{Doc/PreviewBlock|{{MdCode|Go to [[Main Page|Main Page]]}} {{MdCode|Go to {{hla|4}}}}}}
[[Category:Formatting templates]]
 
}}
 
{{MdCode|<nowiki>{{MdCode|desaturated|Go to [[Main Page|Main Page]]}}</nowiki>}} {{MdCode|<nowiki>{{MdCode|desaturated|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{MdCode|desaturated|Go to [[Main Page|Main Page]]}} {{MdCode|desaturated|Go to {{hla|4}}}}}}
 
 
{{MdCode|<nowiki>{{MdCode|outlined|Go to [[Main Page|Main Page]]}}</nowiki>}} {{MdCode|<nowiki>{{MdCode|outlined|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{MdCode|outlined|Go to [[Main Page|Main Page]]}} {{MdCode|outlined|Go to {{hla|4}}}}}}
 
 
{{MdCode|<nowiki>{{MdCode|select=1|background=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}}</nowiki>}} {{MdCode|<nowiki>{{MdCode|background=rgb(40,60,100)|Go to {{hla|4}}}}</nowiki>}}
{{Doc/PreviewBlock|{{MdCode|select=1|background=rgb(230,230,230)|color=black|Go to '''[[Main Page|Main Page]]'''}} {{MdCode|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;}