mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 19:47:22 +00:00
Highlighted code blocks inside the app (#1153)
This commit is contained in:
1 parent
0b42c0288e
commit
f4a86c2fb8
60 files changed
+2550
-41
No files matched your search
@@ -0,0 +1,46 @@
|
||||
namespace AIStudio.Tools.CodeHighlighting.Languages;
|
||||
|
||||
/// <summary>
|
||||
/// How a PowerShell script looks to the tokenizer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// PowerShell ignores the case of its keywords and operators. A command such as Get-ChildItem has the
|
||||
/// form Verb-Noun, an operator such as -eq is a word after a hyphen, and a type stands in square
|
||||
/// brackets, as in [string]. The backtick escapes within double quotation marks; two apostrophes stand
|
||||
/// for one within single ones.
|
||||
/// </remarks>
|
||||
public static class PowerShellCodeRules
|
||||
{
|
||||
public static readonly CodeLanguageRules RULES = new()
|
||||
{
|
||||
Keywords = CodeLanguageRules.WordsInAnyCase(
|
||||
"begin", "break", "catch", "class", "continue", "do", "dynamicparam", "else", "elseif", "end", "enum", "exit",
|
||||
"filter", "finally", "for", "foreach", "function", "if", "in", "param", "process", "return", "switch", "throw",
|
||||
"trap", "try", "until", "using", "while"),
|
||||
|
||||
FunctionDeclarations = CodeLanguageRules.WordsInAnyCase("function", "filter"),
|
||||
TypeDeclarations = CodeLanguageRules.WordsInAnyCase("class", "enum"),
|
||||
LineComments = ["#"],
|
||||
LineCommentsNeedSeparator = true,
|
||||
BlockComments = [new("<#", "#>")],
|
||||
Strings =
|
||||
[
|
||||
new("@\"", "\"@", Escape: '`', IsMultiline: true),
|
||||
new("@'", "'@", Escape: null, IsMultiline: true),
|
||||
new("\"", "\"", Escape: '`', IsMultiline: true),
|
||||
new("'", "'", Escape: null, IsMultiline: true, DoubledCloseIsLiteral: true),
|
||||
],
|
||||
|
||||
VariablePrefix = '$',
|
||||
VariableNameCharacters = ":",
|
||||
WordCharacters = "-",
|
||||
HighlightCommandNames = true,
|
||||
HyphenOperators = CodeLanguageRules.WordsInAnyCase(
|
||||
"and", "as", "band", "bnot", "bor", "bxor", "ceq", "clike", "cmatch", "cne", "contains", "creplace", "eq", "f",
|
||||
"ge", "gt", "ieq", "ilike", "imatch", "in", "ine", "ireplace", "is", "isnot", "join", "le", "like", "lt",
|
||||
"match", "ne", "not", "notcontains", "notin", "notlike", "notmatch", "or", "replace", "shl", "shr", "split",
|
||||
"xor"),
|
||||
|
||||
HasBracketTypes = true,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user