mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 13:27:21 +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,34 @@
|
||||
namespace AIStudio.Tools.CodeHighlighting.Languages;
|
||||
|
||||
/// <summary>
|
||||
/// How Python code looks to the tokenizer.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The soft keywords match, case, and type stay out: they are names everywhere else, as in re.match.
|
||||
/// </remarks>
|
||||
public static class PythonCodeRules
|
||||
{
|
||||
public static readonly CodeLanguageRules RULES = new()
|
||||
{
|
||||
Keywords = CodeLanguageRules.Words(
|
||||
"and", "as", "assert", "async", "await", "break", "class", "continue", "def", "del", "elif", "else", "except",
|
||||
"finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "nonlocal", "not", "or", "pass",
|
||||
"raise", "return", "try", "while", "with", "yield"),
|
||||
|
||||
Types = CodeLanguageRules.Words("bool", "bytearray", "bytes", "complex", "dict", "float", "frozenset", "int", "list", "object", "set", "str", "tuple"),
|
||||
Literals = CodeLanguageRules.Words("True", "False", "None"),
|
||||
FunctionDeclarations = CodeLanguageRules.Words("def"),
|
||||
TypeDeclarations = CodeLanguageRules.Words("class"),
|
||||
LineComments = ["#"],
|
||||
Strings =
|
||||
[
|
||||
new("\"\"\"", "\"\"\"", IsMultiline: true),
|
||||
new("'''", "'''", IsMultiline: true),
|
||||
new("\"", "\""),
|
||||
new("'", "'"),
|
||||
],
|
||||
|
||||
StringPrefixes = CodeLanguageRules.WordsInAnyCase("r", "u", "b", "f", "t", "rb", "br", "fr", "rf", "tr", "rt"),
|
||||
AnnotationPrefix = '@',
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user