mirror of
https://github.com/open-webui/open-webui
synced 2025-02-20 12:00:22 +00:00
Update CodeBlock.svelte
This commit is contained in:
parent
ec93fd15c3
commit
e36be75754
@ -30,70 +30,17 @@
|
||||
};
|
||||
|
||||
const checkPythonCode = (str) => {
|
||||
// Check if the string contains typical Python keywords, syntax, or functions
|
||||
const pythonKeywords = [
|
||||
'def',
|
||||
'class',
|
||||
'import',
|
||||
'from',
|
||||
'if',
|
||||
'else',
|
||||
'elif',
|
||||
'for',
|
||||
'while',
|
||||
'try',
|
||||
'except',
|
||||
'finally',
|
||||
'return',
|
||||
'yield',
|
||||
'lambda',
|
||||
'assert',
|
||||
'pass',
|
||||
'break',
|
||||
'continue',
|
||||
'global',
|
||||
'nonlocal',
|
||||
'del',
|
||||
'True',
|
||||
'False',
|
||||
'None',
|
||||
'and',
|
||||
'or',
|
||||
'not',
|
||||
'in',
|
||||
'is',
|
||||
'as',
|
||||
'with'
|
||||
];
|
||||
|
||||
for (let keyword of pythonKeywords) {
|
||||
if (str.includes(keyword)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the string contains typical Python syntax characters
|
||||
const pythonSyntax = [
|
||||
'def ',
|
||||
'class ',
|
||||
'import ',
|
||||
'from ',
|
||||
'if ',
|
||||
'else:',
|
||||
'elif ',
|
||||
'for ',
|
||||
'while ',
|
||||
'try:',
|
||||
'except:',
|
||||
'finally:',
|
||||
'return ',
|
||||
'yield ',
|
||||
'lambda ',
|
||||
'assert ',
|
||||
'pass',
|
||||
'break',
|
||||
'continue',
|
||||
'global ',
|
||||
'nonlocal ',
|
||||
'del ',
|
||||
'True',
|
||||
@ -104,29 +51,7 @@
|
||||
' not ',
|
||||
' in ',
|
||||
' is ',
|
||||
' as ',
|
||||
' with ',
|
||||
':',
|
||||
'=',
|
||||
'==',
|
||||
'!=',
|
||||
'>',
|
||||
'<',
|
||||
'>=',
|
||||
'<=',
|
||||
'+',
|
||||
'-',
|
||||
'*',
|
||||
'/',
|
||||
'%',
|
||||
'**',
|
||||
'//',
|
||||
'(',
|
||||
')',
|
||||
'[',
|
||||
']',
|
||||
'{',
|
||||
'}'
|
||||
' with '
|
||||
];
|
||||
|
||||
for (let syntax of pythonSyntax) {
|
||||
|
Loading…
Reference in New Issue
Block a user