Bläddra i källkod

Update CodeBlock.svelte

Timothy J. Baek 11 månader sedan
förälder
incheckning
e36be75754
1 ändrade filer med 1 tillägg och 76 borttagningar
  1. 1 76
      src/lib/components/chat/Messages/CodeBlock.svelte

+ 1 - 76
src/lib/components/chat/Messages/CodeBlock.svelte

@@ -30,70 +30,17 @@
 	};
 	};
 
 
 	const checkPythonCode = (str) => {
 	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
 		// Check if the string contains typical Python syntax characters
 		const pythonSyntax = [
 		const pythonSyntax = [
 			'def ',
 			'def ',
-			'class ',
-			'import ',
-			'from ',
-			'if ',
 			'else:',
 			'else:',
 			'elif ',
 			'elif ',
-			'for ',
-			'while ',
 			'try:',
 			'try:',
 			'except:',
 			'except:',
 			'finally:',
 			'finally:',
-			'return ',
 			'yield ',
 			'yield ',
 			'lambda ',
 			'lambda ',
 			'assert ',
 			'assert ',
-			'pass',
-			'break',
-			'continue',
-			'global ',
 			'nonlocal ',
 			'nonlocal ',
 			'del ',
 			'del ',
 			'True',
 			'True',
@@ -104,29 +51,7 @@
 			' not ',
 			' not ',
 			' in ',
 			' in ',
 			' is ',
 			' is ',
-			' as ',
-			' with ',
-			':',
-			'=',
-			'==',
-			'!=',
-			'>',
-			'<',
-			'>=',
-			'<=',
-			'+',
-			'-',
-			'*',
-			'/',
-			'%',
-			'**',
-			'//',
-			'(',
-			')',
-			'[',
-			']',
-			'{',
-			'}'
+			' with '
 		];
 		];
 
 
 		for (let syntax of pythonSyntax) {
 		for (let syntax of pythonSyntax) {