Template:Syntax highlight/doc: Difference between revisions
Jump to navigation
Jump to search
Note:
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
{| class="standard-table" style="margin-bottom:0px;" | {| class="standard-table" style="margin-bottom:0px;" | ||
|+ Currently Supported Categories | |+ Currently Supported Categories | ||
Line 43: | Line 42: | ||
|} | |} | ||
{{note|{{tl|stx}} accepts the {{param|embed}} parameter, which automatically embeds the highlighted text in another template.}} | {{note|{{tl|stx}} accepts the {{param|embed}} parameter, which automatically embeds the highlighted text in another template.}} | ||
Revision as of 17:49, 3 August 2023

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.
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. Direct use of this template should generally be avoided in favor of {{stx}}
, which is more readable and supports multiple sections of text at once.
Usage
{{Syntax highlight|category|text}}
{{Syntax highlight|embed=template|category|text}}
Use none for the category for no syntax highlighting.
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 |

{{stx}}
accepts the {{{embed}}} parameter, which automatically embeds the highlighted text in another template.