From 84973c002c0cef47a979e040334430d229a18954 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 24 May 2026 14:35:44 +0200 Subject: [PATCH] Fix PGN parser: move extraction and Event header value --- pgn-parser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pgn-parser.js b/pgn-parser.js index 4842629..7352c49 100644 --- a/pgn-parser.js +++ b/pgn-parser.js @@ -21,8 +21,8 @@ function parseGameBlock(block) { // Der Event-Header fehlt, weil wir danach splitten – extrahiere ihn aus dem Blockanfang const eventEnd = block.indexOf('"]'); - if (eventEnd > 0) { - headers.Event = block.substring(0, eventEnd); + if (eventEnd > 1) { + headers.Event = block.substring(1, eventEnd); } const headerRegex = /^\s*\[(\w+)\s+"([^"]*)"\]/gm; @@ -35,7 +35,7 @@ function parseGameBlock(block) { } // Extract moves - everything after the last header - const lastHeaderEnd = block.lastIndexOf(']"'); + const lastHeaderEnd = block.lastIndexOf('"]'); let movesText = lastHeaderEnd > -1 ? block.substring(lastHeaderEnd + 2).trim() : ''; // Remove comments from moves for cleaner parsing