Super simple C# syntax highlighter. Adapted from https://codingvision.net/interface/c-simple-syntax-highlighting
More...
◆ HighlightWithBBCode()
string SyntaxHighlighter.HighlightWithBBCode |
( |
string |
code | ) |
|
|
inline |
Highlight C# code with BBCode tags.
- Parameters
-
- Returns
- Input string with BBCode tags.
Definition at line 16 of file SyntaxHighlighter.cs.
18 string outputCode = code;
21 const string keywords =
@"\b(public|private|protected|partial|static|namespace|class|using|void|float|Vector2|int|bool|string|foreach|in|var|override|if|for|else|new|true|false)\b";
22 MatchCollection keywordMatches = Regex.Matches(outputCode, keywords);
23 outputCode = ColorizeMatches(outputCode, keywordMatches, Colors.Cyan);
26 const string types =
@"\b(GD|OS|Engine)\b";
27 MatchCollection typeMatches = Regex.Matches(outputCode, types);
28 outputCode = ColorizeMatches(outputCode, typeMatches, Colors.DarkCyan);
31 const string strings =
"\".+?\"";
32 MatchCollection stringMatches = Regex.Matches(outputCode, strings);
33 outputCode = ColorizeMatches(outputCode, stringMatches, Colors.Brown);
36 var comments =
@"(\/\/.*)";
37 MatchCollection commentMatches = Regex.Matches(outputCode, comments);
38 outputCode = ColorizeMatches(outputCode, commentMatches, Colors.Green);
41 comments =
@"(\/\*.+?\*\/)";
42 commentMatches = Regex.Matches(outputCode, comments, RegexOptions.Multiline | RegexOptions.Singleline);
43 return ColorizeMatches(outputCode, commentMatches, Colors.Green);
The documentation for this class was generated from the following file: