Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pmyszka
Copy link
Contributor

@pmyszka pmyszka commented Nov 24, 2023

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)

@franciscoBSalgueiro
Copy link
Owner

franciscoBSalgueiro commented Nov 25, 2023

This will still break when using a game termination marker inside a comment. For example:

[Event "test"]

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

I also don't want to require [Event to be present. Even if it's the standard, some files might not have it or not be the first header to appear.

@Coccocoahelper
Copy link
Contributor

Progress?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants