Template:Syntax highlight/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(revert for now)
(Undo revision 333782 by Pee (talk))
Tag: Undo
Line 1: Line 1:
{{Doc/subpage}}
{{Doc/subpage}}


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 <nowiki><source></nowiki> renders code, with the exception of functions, to contrast against a dark background more.
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 <nowiki><source></nowiki> renders code, with the exception of functions, to contrast against a dark background more. If the {{param|code}} parameter is set to 1, it will be embedded into a {{tl|link=code}} template.




== Usage ==
== Usage ==
{{Code|<nowiki>{{Syntax highlight|category|text}}</nowiki>}}
{{Code|<nowiki>{{Syntax highlight|category|text}}</nowiki>}}
{{Code|<nowiki>{{Syntax highlight|category|text|code=1}}</nowiki>}}




Line 25: Line 27:
| Label            ||<nowiki>{{syntax highlight|label|final}}</nowiki>              || <nowiki>{{stx|lbl|final}}</nowiki>                                                || {{syntax highlight|label|final}}
| Label            ||<nowiki>{{syntax highlight|label|final}}</nowiki>              || <nowiki>{{stx|lbl|final}}</nowiki>                                                || {{syntax highlight|label|final}}
|-
|-
| Macro            ||<nowiki>{{syntax highlight|macro|#define}}</nowiki>            || <nowiki>{{stx|mac|#define}}</nowiki>                                              || {{syntax highlight|macro|#define}}
| Macro            ||<nowiki>{{syntax highlight|macro|&&#35;35;define}}</nowiki>            || <nowiki>{{stx|mac|&&#35;35;define}}</nowiki>                                              || {{syntax highlight|macro|&#35;define}}
|-
|-
| Number/Operator  ||<nowiki>{{syntax highlight|number|3.0f}}</nowiki><br><nowiki>{{syntax highlight|operator|+}}</nowiki>              || <nowiki>{{stx|no|3.0f}}</nowiki><br><nowiki>{{stx|op|+}}</nowiki>                || {{syntax highlight|number|3.0f}}
| Number/Operator  ||<nowiki>{{syntax highlight|number|3.0f}}</nowiki><br><nowiki>{{syntax highlight|operator|+}}</nowiki>              || <nowiki>{{stx|no|3.0f}}</nowiki><br><nowiki>{{stx|op|+}}</nowiki>                || {{syntax highlight|number|3.0f}}
Line 36: Line 38:
|-  
|-  
|}
|}
{{note|{{tl|stx}} accepts the {{param|code}} parameter as well.}}

Revision as of 13:00, 2 August 2023

Edit-copy.png
This is a documentation subpage for Template:Syntax highlight.
Don't forget to purge the contents of the base page upon creating or editing this subpage.

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 <source> renders code, with the exception of functions, to contrast against a dark background more. If the {{{code}}} parameter is set to 1, it will be embedded into a {{code}} template.


Usage

{{Syntax highlight|category|text}}

{{Syntax highlight|category|text|code=1}}


Currently 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|&#35;define}} {{stx|mac|&#35;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
Note.pngNote:{{stx}} accepts the {{{code}}} parameter as well.