You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use python-chess to merge two pgn games, which is working fine. But it appears some PGN viewers really want the normal text comments and the %cal and %csl annotations separated into their own comment, like so:
e4 { Here is a text comment } { [%cal Ge2e4] }
I seem to have no way to create this type of comment since the "comment" field in the GameNode class in pgn.py is a string, when I think I want it to be a list of strings. So I end up with this:
e4 { Here is a text comment [%cal Ge2e4] } <--- without a closing and opening bracket between the text and annotation
I have also tried setting node.comment = f"{text} }} {{ {annotations}" , ie injecting a } and a { inside the comment but it doesn't work, and is hacky anyway. It appears to insert the { but the } never appears.
What's your take on this? Just something the library doesn't support?
The text was updated successfully, but these errors were encountered:
And Chesstempo.org:
(though it's not obvious how to create these so not a lot of people are probably creating annotations here, but maybe some people import into Chesstempo and then export, in which case you also get this)
1.e4 e5 { This is a comment } {[%cal Gf2f5,Gg2g3][%csl Gb3,Yc4]}
And this NodeJS library for parsing PGN files seem to want it formatted this way too.
Check out test/test_grammer.js around line 170 for a test that tells alot.
I have sort of gotten around this by now by creating python script using your parser and a hack that inserts } { between the text part and the [% part after it is printed, but at least based on these three frameworks/sites I would guess this would be something good to support.
I'm trying to use python-chess to merge two pgn games, which is working fine. But it appears some PGN viewers really want the normal text comments and the %cal and %csl annotations separated into their own comment, like so:
I seem to have no way to create this type of comment since the "comment" field in the GameNode class in pgn.py is a string, when I think I want it to be a list of strings. So I end up with this:
I have also tried setting node.comment = f"{text} }} {{ {annotations}" , ie injecting a } and a { inside the comment but it doesn't work, and is hacky anyway. It appears to insert the { but the } never appears.
What's your take on this? Just something the library doesn't support?
The text was updated successfully, but these errors were encountered: