Template:CodeBlock/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 2: Line 2:
This template formats the text as a block of code.
This template formats the text as a block of code.


== Parameters and Examples ==
==Parameters and Examples==
=== Main ===
===Main===
The main parameters are described below.
The main parameters are described below.
{| class=standard-table width=100%
{| class=standard-table width=100%
Line 26: Line 26:
:* {{Code|style=3|Default}} - Default style that is based on Markdown.
:* {{Code|style=3|Default}} - Default style that is based on Markdown.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|style=1|Hello, World!}}</nowiki>}}
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|style=1|Hello, World!}}</nowiki>}}
| {{Capsule|margin=5px|{{CodeBlock|style=1|margin=0|Hello, World!}}}}
| {{Capsule|margin=5px|{{CodeBlock|margin=0|style=1|Hello, World!}}}}
|-
| align=center | {{Code|{{Param|limited}}}}
| Limits the block height to 400 pixels and enables scrolling.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|1. Hello World
2. Hello World
3. Hello World
4. Hello World}}</nowiki>}}
| align=center | See below
|-
|-
| align=center | {{Code|{{Param|height}}}}
| align=center | {{Code|{{Param|height}}}}
| Controls the height of the block.<br>Does not work without {{param|limited}}.<br>The maximum height is 400 pixels.
| Controls the height of the block.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|limited=1|height=32px|1. Hello World
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|height=52px|<nowiki>1. Hello World
2. Hello World
2. Hello World
3. Hello World
3. Hello World
4. Hello World}}</nowiki>}}
4. Hello World<&#47;nowiki>}}</nowiki>}}
| {{Capsule|margin=5px|{{CodeBlock|limited=1|height=32px|margin=0|<nowiki>1. Hello World
| {{Capsule|margin=5px|{{CodeBlock|height=52px|margin=0|<nowiki>1. Hello World
2. Hello World
2. Hello World
3. Hello World
3. Hello World
Line 49: Line 41:
| align=center | {{Code|{{Param|lines}}}}
| align=center | {{Code|{{Param|lines}}}}
| ''Manual:'' Numbered lines.
| ''Manual:'' Numbered lines.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lines=4|1. Hello World
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lines=4|<nowiki>Hello World
2. Hello World
Hello World
3. Hello World
Hello World
4. Hello World}}</nowiki>}}
Hello World<&#47;nowiki>}}</nowiki>}}
| {{Capsule|margin=5px|{{CodeBlock|lines=4|margin=0|<nowiki>1. Hello World
| {{Capsule|margin=5px|{{CodeBlock|lines=4|margin=0|<nowiki>Hello World
2. Hello World
Hello World
3. Hello World
Hello World
4. Hello World</nowiki>}}}}
Hello World</nowiki>}}}}
|-
| align=center | {{Code|{{Param|start}}}}
| What number to start numbering from (default value is 1). The value can be negative.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|start=12|lines=5|<nowiki>Hello World
Hello World
Hello World
Hello World
Hello World<&#47;nowiki>}}</nowiki>}}
| {{Capsule|margin=5px|{{CodeBlock|start=12|lines=5|<nowiki>Hello World
Hello World
Hello World
Hello World
Hello World</nowiki>}}}}
|}
|}


=== Header ===
===Header===
The parameters for adding a header with the code source and the name of the programming language are described below.
The parameters for adding a header with the code source and the name of the programming language are described below.
{{ModernNote|The header is enabled automatically when you enter one of the following parameters.}}
{{ModernNote|The header is enabled automatically when you enter one of the following parameters.}}
Line 75: Line 80:
| align=center | {{Code|{{Param|lang}}}}
| align=center | {{Code|{{Param|lang}}}}
|The name of the language displayed on the right side of the header.
|The name of the language displayed on the right side of the header.
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock
| {{CodeBlock|margin=5px|<nowiki>{{CodeBlock|lang=cs
|lang = cs
|<nowiki>using System;
|<nowiki>using System;



Revision as of 17:20, 17 February 2023

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)
Edit-copy.png
This is a documentation subpage for Template:CodeBlock.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

This template formats the text as a block of code.

Parameters and Examples

Main

The main parameters are described below.

Name Description Example Preview
{{{1}}} Your code.
It is recommended to wrap the template content with the <nowiki> tag.
{{CodeBlock|Hello, World!}}
Hello, World!
{{{margin}}} Controls margins.
{{CodeBlock|margin=0 20px 0 20px|Hello, World!}}
Hello, World!
{{{style}}} The style of the template. The following styles are available:
  • 1 - Outlined version;
  • Default - Default style that is based on Markdown.
{{CodeBlock|style=1|Hello, World!}}
Hello, World!
{{{height}}} Controls the height of the block.
{{CodeBlock|height=52px|<nowiki>1. Hello World 2. Hello World 3. Hello World 4. Hello World</nowiki>}}
1. Hello World 2. Hello World 3. Hello World 4. Hello World
{{{lines}}} Manual: Numbered lines.
{{CodeBlock|lines=4|<nowiki>Hello World Hello World Hello World Hello World</nowiki>}}
  1.  
  2.  
  3.  
  4.  
Hello World Hello World Hello World Hello World
{{{start}}} What number to start numbering from (default value is 1). The value can be negative.
{{CodeBlock|start=12|lines=5|<nowiki>Hello World Hello World Hello World Hello World Hello World</nowiki>}}
  1.  
  2.  
  3.  
  4.  
  5.  
Hello World Hello World Hello World Hello World Hello World

Header

The parameters for adding a header with the code source and the name of the programming language are described below. Template:ModernNote

Name Description Example Preview
{{{src}}} The source of your code.
{{CodeBlock|src=light.rad|forcetextureshadow props_foliage/urban_tree01.mdl}}
light.rad
forcetextureshadow props_foliage/urban_tree01.mdl
{{{lang}}} The name of the language displayed on the right side of the header.
{{CodeBlock|lang=cs |<nowiki>using System; namespace HelloWorld { internal class Program { static void Main(string[] args) { Console.WriteLine("Hello World"); } } }</nowiki>}}
The source was not specified
cs
using System; namespace HelloWorld { internal class Program { static void Main(string[] args) { Console.WriteLine("Hello World"); } } }