"magic_pdf/git@developer.sourcefind.cn:wangsen/mineru.git" did not exist on "e31066bae52cfa60891ac04ef1050cf1acc18418"
Commit e36be757 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

Update CodeBlock.svelte

parent ec93fd15
...@@ -30,70 +30,17 @@ ...@@ -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 @@ ...@@ -104,29 +51,7 @@
' not ', ' not ',
' in ', ' in ',
' is ', ' is ',
' as ', ' with '
' with ',
':',
'=',
'==',
'!=',
'>',
'<',
'>=',
'<=',
'+',
'-',
'*',
'/',
'%',
'**',
'//',
'(',
')',
'[',
']',
'{',
'}'
]; ];
for (let syntax of pythonSyntax) { for (let syntax of pythonSyntax) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment