diff --git a/.gitignore b/.gitignore index b4dd471d..b8fe2c1f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ dist-web/ dist-ssr *.local xplugin/ +src-others/ # Editor directories and files .vscode/* diff --git a/src/ts/parser.ts b/src/ts/parser.ts index eac26f7e..b025a5db 100644 --- a/src/ts/parser.ts +++ b/src/ts/parser.ts @@ -199,4 +199,42 @@ function isAPNG(pngData: Uint8Array): boolean { } } return false; -} \ No newline at end of file +} + +function wppParser(data:string){ + const lines = data.split('\n'); + let characterDetails:{[key:string]:string[]} = {}; + + lines.forEach(line => { + + // Check for "{" and "}" indicator of object start and end + if(line.includes('{')) return; + if(line.includes('}')) return; + + // Extract key and value within brackets + let keyBracketStartIndex = line.indexOf('('); + let keyBracketEndIndex = line.indexOf(')'); + + if(keyBracketStartIndex === -1 || keyBracketEndIndex === -1) + throw new Error(`Invalid syntax ${line}`); + + let key = line.substring(0, keyBracketStartIndex).trim(); + + // Validate Key + if(!key) throw new Error(`Missing Key in ${line}`); + + const valueArray=line.substring(keyBracketStartIndex + 1, keyBracketEndIndex) + .split(',') + .map(str => str.trim()); + + // Validate Values + for(let i=0;i