python-chess icon indicating copy to clipboard operation
python-chess copied to clipboard

Feature Request: Distinguish between "pre-move" and "post-move" comments in GameNode

Open aslyamov opened this issue 1 month ago • 0 comments

Hi!

I am working with a data source that explicitly distinguishes between two types of comments for a specific move:

  1. Before the move (e.g., context or instructions given before the move is made).
  2. After the move (e.g., analysis or annotation of the move itself).

Currently, chess.pgn.GameNode seems to only support a single comment attribute.

If I have a sequence like: {Comment Before} 1. e4 {Comment After}

I am forced to append {Comment Before} to the parent.comment (the previous node) and {Comment After} to the current node.comment. While this produces valid PGN text, it causes semantic issues in the object model:

  • If I iterate through the game nodes later, the "Comment Before" is logically attached to the previous move, not the current one.
  • It becomes difficult to parse the PGN back and separate which part of the text was intended as a "pre-move" note vs a "post-move" annotation.

Feature Request: Would it be possible to introduce a mechanism to store pre-move comments separately? For example, adding a pre_comment attribute to GameNode or ensuring that the Visitor can distinguish between comments appearing before the move token/SAN and comments appearing after it.

This would greatly help in preserving the structure of the original data.

Thanks for the great library!

aslyamov avatar Nov 19 '25 17:11 aslyamov