Template:Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
See Also: [[Template:CodeBlock]]
{{Documentation}}
{{doc}}
<includeonly>


<includeonly><onlyinclude><span style="font-family:monospace; {{#switch:{{{p|{{{preset|}}}}}}
<onlyinclude><span style="font-family:monospace; {{#switch:{{{p|{{{preset|}}}}}}
|#default = padding:2px 4px; border-radius:3px; background:rgb(0 0 0 / 26%);
|#default = padding:2px 4px; border-radius:3px; background:rgb(0 0 0 / 26%);
|0 =  
|0 =  
Line 8: Line 8:
|2 = padding:1px 3px; border-radius:3px; background:rgb(0 0 0 / 16%); border:1px solid rgb(255 255 255 / 10%);
|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%);
|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>
}} {{#if:{{{select|}}}|user-select:{{{select}}};}} {{{style|}}}">{{#if:{{{highlight|}}}|{{#tag:syntaxhighlight|{{{1}}}|lang={{{highlight}}}|inline=1}}|{{{1}}}}}</span></onlyinclude>


[[Category:Formatting templates]]
</includeonly>

Revision as of 09:27, 7 October 2025

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.

Usage

This template is usually written in a single line. To use it, insert {{Code}} into the desired page and specify the parameters to the right of the template name in the following format: {{Code|parameter 1 = value|parameter 2 = value}}.

Parameters and Examples

Parameters Description Examples Preview
{{{1}}} Text.
| Hello, World!
(?) Hello, World!
| 1 = Hello, World!
(?)
{{{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.
| preset = 0
(?) Hello, World!
| preset = 1
(?) Hello, World!
| preset = 2
(?) Hello, World!
| preset = 3
(?) Hello, World!
{{{select}}} Text selection mode.

Uses the user-select CSS property.

Default value is unset.

| select = none
(?) Hello, World!
| select = all
(?) Hello, World!
{{{style}}} CSS styles.
| style = color:#EF9B9B
(?) Hello, World!
{{{highlight}}} Adds syntax highlighting for the language specified.
Icon-Bug.pngBug:Condenses code into one line.  [todo tested in ?]
| highlight = c
(?) int main() {return 0;}

See Also