Template:Syntax highlight: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(this was right)
(figured out thanks to https://stackoverflow.com/a/65355529)
Line 1: Line 1:
{{TODO|calculate the results of the current colors after <code>filter: invert(1) hue-rotate(180deg)</code> and change these colors to them. It's what an official wikipedia extension does for dark mode, and will contrast against a dark background better. VDC doesn't allow the <code>filter</code> property.}}
{{doc}}[[Category:Formatting templates]]
{{doc}}[[Category:Formatting templates]]
<onlyinclude><includeonly><!--
<onlyinclude><includeonly><!--
--><span style="{{#switch:{{{1}}}
--><span style="{{#switch:{{{1}}}
|character|string=color: #BA2121;
|character|string=color: rgb(255, 156.822, 156.822);
|comment=color: #408080;font-style: italic;
|comment=color:rgb(90.646, 154.264, 154.264); font-style: italic;
|control=color: #008000;font-weight: bold;
|control=color: rgb(72.47, 199.96, 71.96);font-weight: bold;
|function=color: #0000FF;
|function=color:rgb(218.79, 218.28, 256);
|label=color: #A0A000;
|label=color: rgb(118.23, 118.04, 0);
|macro=color: #BC7A00;
|macro=color: rgb(188.586, 122.452, 0.452);
|number|operator=color: #666666;
|number|operator=color: rgb(153.306, 153, 153);
|register=color: #19177C;
|register=color: rgb(207.544, 205.084, 255);
|regular expression=color: #BB6688;
|regular expression=color: rgb(197.03, 111.894, 145.894);
|type=color: #B00040;
|type=color: rgb(346.966,170.808,234.808);
}}">{{{2|}}}</span><!--
}}">{{{2|}}}</span><!--
--></includeonly></onlyinclude>
--></includeonly></onlyinclude>

Revision as of 16:04, 31 July 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)
Curly brackets white.pngTemplate Documentation [view] [edit]
Icon-translate.png Available doc translations
View
Page history

This template applies CSS to text to signify it is a certain category, such as a comment, type, string, etc. the CSS here is taken from how <syntaxhighlight> renders code.


Usage

{{Syntax highlight|category|text}}


Supported Categories
Uses Example Shortcuts Preview
Character/String {{syntax highlight|character|'x'}}
{{syntax highlight|string|"Hello, World!"}}
{{stx|char|'x'}}
{{stx|str|"Hello, World!"}}
'x'
Comment {{syntax highlight|comment|//comment}} {{stx|comm|//comment}} //comment
Control {{syntax highlight|control|if}} {{stx|ctrl|if}} if
Function {{syntax highlight|function|main}} {{stx|func|main}} main
Label {{syntax highlight|label|final}} {{stx|lbl|final}} final
Macro {{syntax highlight|macro|#define}} {{stx|mac|#define}} #define
Number/Operator {{syntax highlight|number|3.0f}}
{{syntax highlight|operator|+}}
{{stx|no|3.0f}}
{{stx|op|+}}
3.0f
Register {{syntax highlight|register|%rax}} {{stx|reg|%rax}} %rax
Regular Expression {{syntax highlight|regular expression|/a*b+/}} {{stx|regex|/a*b+/}} /a*b+/
Type {{syntax highlight|type|unsigned int}} {{stx|type|unsigned int}} unsigned int