Template:Syntax highlight/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{Doc/subpage}} This template has subpages used to apply CSS to text to signify it is a certain part of code, such as a comment, type, string, etc. == Usage == {{Code|<nowik...")
 
No edit summary
 
(63 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Doc/subpage}}
{{Doc/subpage}}


This template has subpages used to apply CSS to text to signify it is a certain part of code, such as a comment, type, string, etc.
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><syntaxhighlight></nowiki> renders code.
 


== Usage ==
== Usage ==
{{Code|<nowiki>{{Syntax Highlight|type}}</nowiki>}}
{{Code|<nowiki>{{Syntax highlight|category|text}}</nowiki>}}
 


{{Doc/Sandbox other|
{| class="standard-table" style="margin-bottom:0px;"
<!-- Categories below this line, please -->
|+ <!--Currently -->Supported Categories
[[Category:Templates]]
! Uses
}}
! Example
! Shortcuts
! Preview
|-
| Character/String  ||<nowiki>{{syntax highlight|character|'x'}}</nowiki><br><nowiki>{{syntax highlight|string|"Hello, World!"}}</nowiki>    || <nowiki>{{stx|char|'x'}}</nowiki><br><nowiki>{{stx|str|"Hello, World!"}}</nowiki> || {{syntax highlight|character|'x'}}
|-
| Comment          ||<nowiki>{{syntax highlight|comment|//comment}}</nowiki>        || <nowiki>{{stx|comm|//comment}}</nowiki>                                          || {{syntax highlight|comment|//comment}}
|-
| Control          ||<nowiki>{{syntax highlight|control|if}}</nowiki>                || <nowiki>{{stx|ctrl|if}}</nowiki>                                                  || {{syntax highlight|control|if}}
|-
| Function          ||<nowiki>{{syntax highlight|function|main}}</nowiki>            || <nowiki>{{stx|func|main}}</nowiki>                                                || {{syntax highlight|function|main}}
|-
| 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}}
|-
| 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}}
|-
| Register          ||<nowiki>{{syntax highlight|register|%rax}}</nowiki>            || <nowiki>{{stx|reg|%rax}}</nowiki>                                                || {{syntax highlight|register|%rax}}
|-  
| Regular Expression||<nowiki>{{syntax highlight|regular expression|/a*b+/}}</nowiki> || <nowiki>{{stx|regex|/a*b+/}}</nowiki>                                            || {{syntax highlight|regular expression|/a*b+/}}
|-
| Type              ||<nowiki>{{syntax highlight|type|unsigned int}}</nowiki>        || <nowiki>{{stx|type|unsigned int}}</nowiki>                                        || {{syntax highlight|type|unsigned int}}
|-
|}

Latest revision as of 13:41, 23 June 2024

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