Template:Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Ah... screw it, I'm tired.)
mNo edit summary
 
(33 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Doc}}<includeonly><onlyinclude><kbd style="color:{{{color|currentcolor}}}; border-radius:3px; user-select:{{#switch:{{{select|}}}|#default=text|0=none|1=all}}; background-color:{{#switch:{{{style}}}
See Also: [[Template:CodeBlock]]
|#default = {{{bg|rgb(0,0,0,.35)}}}; padding:2px 3px">
{{doc}}
|1 = {{{bg|rgba(0,0,0,.16)}}}; border:1px solid rgba(255,255,255,.1); padding:1px 3px">
 
|2 = {{{bg|rgba(0,0,0,.16)}}}; padding:2px 3px">
<includeonly><onlyinclude><span style="font-family:monospace; {{#switch:{{{p|{{{preset|}}}}}}
|3 = {{{bg|initial}}}; padding:0">
|#default = padding:2px 4px; border-radius:3px; background:rgb(0 0 0 / 26%);
|4 = {{{bg|rgba(255,255,255,.05)}}}; border:1px solid rgba(255,255,255,.1); padding:1px 3px">
|0 =  
}}{{{1|}}}<span style="user-select:none"></span></kbd></onlyinclude></includeonly>
|1 = padding:2px 4px; border-radius:3px; background:rgb(0 0 0 / 16%);
|2 = padding:1px 3px; border-radius:3px; background:rgb(0 0 0 / 16%); border:1px solid rgb(255 255 255 / 10%);
|3 = padding:1px 3px; border-radius:3px; background:rgb(255 255 255 / 5%); border:1px solid rgb(255 255 255 / 10%);
}} {{#if:{{{select|}}}|user-select:{{{select}}};}} {{{style|}}}">{{#if:{{{highlight|}}}|{{#tag:syntaxhighlight|{{{1}}}|lang={{{highlight}}}|inline=1}}|{{{1}}}}}</span></onlyinclude></includeonly>
 
[[Category:Formatting templates]]

Latest revision as of 16:09, 17 August 2025

See Also: Template:CodeBlock

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)
Curly brackets white.pngTemplate Documentation [view] [edit]
Icon-translate.png Available doc translations
View
Page history

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;}