chess.js
chess.js copied to clipboard
Extracting comments from PGN
Now, instead of comments being removed completely, they are stored in "comments" array which is accessible via .comments() method. The array is always the size of a history array.
+1
Let's open this up for discussion. The c_index
variable that's used to index the comments is opaque to the user ... and I don't think exposing it would be a good idea. So a few questions:
- Would it be better to convert
comments
into an object and key off the current FEN? - Should comments be preserved and re-inserted when calling dumping PGN via
.pgn()
?
@jhlywa Found issue since I'd like to take advantage of any comments extracted from PNG. Is this something you are still able to work on?
To answer your questions:
Would it be better to convert comments into an object and key off the current FEN?
Providing a comments object would be helpful, and seems to mimic how chess.history()
works after chess.load_pgn()
. Maybe chess.comments()
is available after chess.load_pgn()
?
Should comments be preserved and re-inserted when calling dumping PGN via .pgn()?
This seems defensible since it doesn't change the PGN at all.
@imor Any chance you're able to submit a pull request for the code you wrote to extract comments from the PGN?
Is anyone working on this? I don't want to have to write my own PGN reader just to keep track of comments in games.
fyi, i submitted a new PR that should address the comments from @jhlywa