en-croissant icon indicating copy to clipboard operation
en-croissant copied to clipboard

fix: recognizing start/end of game when reading from a PGN

Open pmyszka opened this issue 1 year ago • 2 comments

Issue

The current version does not properly recognize a situation where a line begins with [ character, while also not being a header. See below example:

[Event "test"]

1. e4 f5 2. d4 g5 { This comment will break pgn parsing
[%cal Ge7b7]} 3. Qh5# 1-0

Importing this will fail.

Solution

This PR improves the way games are recognized within a PGN file. Following https://ia802908.us.archive.org/26/items/pgn-standard-1994-03-12/PGN_standard_1994-03-12.txt, section 8.2.6 Game Termination Markers GTMs are used to determine whether we've reached an end of a game. Additionally, the current way of counting games has been slightly amended (look for [Event as a sign of a new game, as according to the above spec it's the first one in the Seven Tag Roster, section 8.1.1)

pmyszka avatar Nov 24 '23 12:11 pmyszka