Skip to content

Conversation

@aslyamov
Copy link

This PR adds a pre_comment attribute to GameNode and updates the StringExporter to support writing comments immediately before a move token.

Use Case:
In many educational chess materials (and complex PGNs), there is a semantic difference between a comment explaining the previous position and a comment giving instructions specifically for the upcoming move (e.g., "Find the best move").

Currently, users are forced to append such comments to node.parent.comment, which works for PGN validity but loses the logical association in the object model.

Changes:

  1. Added pre_comment attribute to GameNode.
  2. Added visit_pre_comment to BaseVisitor and StringExporterMixin.
  3. Updated ChildNode._accept_node to visit the pre-comment before the move.

This implementation ensures that force_movenumber is triggered after a pre-comment, producing valid PGN output like:
1. e4 {Post-comment} {Pre-comment for next move} 2. Nf3

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.

1 participant