WIP
This commit is contained in:
@@ -24,6 +24,14 @@ const cleanPGN = (pgn: string) => {
|
|||||||
game.load_pgn(pgn);
|
game.load_pgn(pgn);
|
||||||
game.delete_comments();
|
game.delete_comments();
|
||||||
|
|
||||||
|
if (!game.header().Result) {
|
||||||
|
const result = (pgn.trim().match(/(1-0)|(0-1)|(1\/2-1\/2)$/) || [])[0];
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
game.header("Result", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const headerEntries = Object.entries(game.header());
|
const headerEntries = Object.entries(game.header());
|
||||||
|
|
||||||
const [_, moves] =
|
const [_, moves] =
|
||||||
@@ -37,11 +45,7 @@ const cleanPGN = (pgn: string) => {
|
|||||||
.sort()
|
.sort()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
console.log(header);
|
return [header, moves].join("\n\n");
|
||||||
|
|
||||||
const cleanedPGN = [header, moves].join("\n\n");
|
|
||||||
console.log(cleanedPGN);
|
|
||||||
return cleanedPGN;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const compressPGN = (pgn: string) => {
|
const compressPGN = (pgn: string) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user