chess.js icon indicating copy to clipboard operation
chess.js copied to clipboard

Extracting comments from PGN

Open MakG10 opened this issue 8 years ago • 6 comments

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.

MakG10 avatar Jan 20 '16 01:01 MakG10

+1

billymoon avatar Jan 31 '16 16:01 billymoon

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:

  1. Would it be better to convert comments into an object and key off the current FEN?
  2. Should comments be preserved and re-inserted when calling dumping PGN via .pgn()?

jhlywa avatar Feb 03 '16 02:02 jhlywa

@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.

charliesneath avatar Oct 06 '19 14:10 charliesneath

@imor Any chance you're able to submit a pull request for the code you wrote to extract comments from the PGN?

charliesneath avatar Oct 09 '19 13:10 charliesneath

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.

danegraphics avatar Dec 10 '19 00:12 danegraphics

fyi, i submitted a new PR that should address the comments from @jhlywa

jtwires avatar May 05 '20 02:05 jtwires