Fix PGN parser: move extraction and Event header value

This commit is contained in:
2026-05-24 14:35:44 +02:00
parent 414732cb7e
commit 84973c002c

View File

@@ -21,8 +21,8 @@ function parseGameBlock(block) {
// Der Event-Header fehlt, weil wir danach splitten extrahiere ihn aus dem Blockanfang // Der Event-Header fehlt, weil wir danach splitten extrahiere ihn aus dem Blockanfang
const eventEnd = block.indexOf('"]'); const eventEnd = block.indexOf('"]');
if (eventEnd > 0) { if (eventEnd > 1) {
headers.Event = block.substring(0, eventEnd); headers.Event = block.substring(1, eventEnd);
} }
const headerRegex = /^\s*\[(\w+)\s+"([^"]*)"\]/gm; const headerRegex = /^\s*\[(\w+)\s+"([^"]*)"\]/gm;
@@ -35,7 +35,7 @@ function parseGameBlock(block) {
} }
// Extract moves - everything after the last header // Extract moves - everything after the last header
const lastHeaderEnd = block.lastIndexOf(']"'); const lastHeaderEnd = block.lastIndexOf('"]');
let movesText = lastHeaderEnd > -1 ? block.substring(lastHeaderEnd + 2).trim() : ''; let movesText = lastHeaderEnd > -1 ? block.substring(lastHeaderEnd + 2).trim() : '';
// Remove comments from moves for cleaner parsing // Remove comments from moves for cleaner parsing