mliebelt / pgn-parser

Javascript library to allow reading of a PGN (Portable Game Notation) chess game notation, and providing the result as JSON.
Apache License 2.0
65 stars 20 forks source link

Issue when parsing PGN with annotations(circle and arrow) from Lichess #333

Closed coffeeDev98 closed 1 year ago

coffeeDev98 commented 1 year ago

Hey @mliebelt , I've noticed some issue when parsing PGN which contains Circle and Arrow annotations even though the format is the same as the one generated when using annotations within the package.

This is the PGN used:

  1. e4 c5 2. d4 cxd4 3. c3 dxc3 4. Nxc3 a6 5. Bc4 e6 6. Nge2 ( 6. Nf3 {[%csl Ge5][%cal ]} ) Nc6 7. O-O Qc7 8. Bb3 {[%csl ][%cal Gc7c4]} Nge7 9. f4 Ng6 10. f5 Nge5 {[%csl Ge5][%cal ]} 11. fxe6 dxe6 12. Nf4 Bd6 13. Nfd5 Qb8 ( 13... exd5 ) 14. Nb6 Bc5+ 15. Kh1 Bxb6 16. Bf4 Bc7 17. Rc1 O-O 18. Qh5 Nd4 19. Nd5 exd5 20. Bxd5 Be6 0-1

This seems to be happening because of the empty space after %cal or %csl(The occurrences in the above PGN to highlighted)

image
mliebelt commented 1 year ago

The reason is not the whitespace, but the missing arrows or circles. I may make the grammar more robust to allow that as well (should not be too complicated), but it is of course not necessary to have empty color fields or arrows.

mliebelt commented 1 year ago

Moved the issue to the parser, and will fix it there in the next version.

mliebelt commented 1 year ago

Provided the fix and a new version 1.4.6 including tests.