Template:Syntax highlight/doc: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(done moving everything and nominating for deletion)
No edit summary
 
(40 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 category, such as a comment, type, string, etc. the CSS here is taken from how <nowiki><source></nowiki> renders code.
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/Category|text}}</nowiki>}}
{{Code|<nowiki>{{Syntax highlight|category|text}}</nowiki>}}




{| class="standard-table"
{| class="standard-table" style="margin-bottom:0px;"
|+ Currently Supported Categories
|+ <!--Currently -->Supported Categories
! Uses
! Uses
! Example
! Example
Line 16: Line 15:
! Preview
! Preview
|-  
|-  
| Char/String       ||<nowiki>{{Syntax highlight/string|"Hello, World!"}}</nowiki>    || <nowiki>{{stxchar|'x'}}</nowiki><br><nowiki>{{stxstr|"Hello, World!"}}</nowiki> || {{Syntax highlight/string|"Hello, World!"}}
| 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>{{stxcmnt|//comment}}</nowiki>                                         || {{Syntax highlight/comment|//comment}}
| Comment           ||<nowiki>{{syntax highlight|comment|//comment}}</nowiki>        || <nowiki>{{stx|comm|//comment}}</nowiki>                                           || {{syntax highlight|comment|//comment}}
|-  
|-  
| Control           ||<nowiki>{{Syntax highlight/control|if}}</nowiki>                || <nowiki>{{stxctrl|if}}</nowiki>                                                 || {{Syntax highlight/control|if}}
| Control           ||<nowiki>{{syntax highlight|control|if}}</nowiki>                || <nowiki>{{stx|ctrl|if}}</nowiki>                                                 || {{syntax highlight|control|if}}
|-  
|-  
| Function           ||<nowiki>{{Syntax highlight/function|main}}</nowiki>            || <nowiki>{{stxfunc|main}}</nowiki>                                               || {{Syntax highlight/function|main}}
| Function         ||<nowiki>{{syntax highlight|function|main}}</nowiki>            || <nowiki>{{stx|func|main}}</nowiki>                                               || {{syntax highlight|function|main}}
|-  
|-  
| Label             ||<nowiki>{{Syntax highlight/label|final}}</nowiki>              || <nowiki>{{stxlbl|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>{{stxmac|#define}}</nowiki>                                             || {{Syntax highlight/macro|#define}}
| 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>              || <nowiki>{{stxno|3.0f}}</nowiki><br><nowiki>{{stxop|+}}</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}}
|-  
|-  
| Register           ||<nowiki>{{Syntax highlight/register|%rax}}</nowiki>            || <nowiki>{{stxreg|%rax}}</nowiki>                                               || {{Syntax highlight/register|%rax}}
| 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>{{stxregex|/a*b+/}}</nowiki>                                           || {{Syntax highlight/regular expression|/a*b+/}}
| 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>{{stxtype|unsigned int}}</nowiki>                                       || {{Syntax highlight/type|unsigned int}}
| Type             ||<nowiki>{{syntax highlight|type|unsigned int}}</nowiki>        || <nowiki>{{stx|type|unsigned int}}</nowiki>                                       || {{syntax highlight|type|unsigned int}}
|-  
|-  
|}
|}
{{Doc/Sandbox other|
<!-- Categories below this line, please -->
[[Category:Templates]]
}}

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