shaack / cm-pgn

Parse and create PGNs (Portable Game Notation for chess games)
MIT License
27 stars 21 forks source link

Allow rendering of PGNs with variations #4

Closed shaack closed 1 year ago

shaack commented 6 years ago

The method pgn.toString() should render a valid PGN.

For this it is necessary to implement the toString()method for Header and History.

Therefore Header and History should remain as Objects and store the related data (not only export the parseHeader/parseHistory function).

The History-Object should keep the history-data, the Header-Object should keep the header tags.

Then it is possible to create "toString()" functions for the Header and the History Object and also to use these Objects independent of the Pgn Object. (Header renders the header and History renders the history on toString().

Result: Pgn.js renders the pgn on toString() as header.toString() + "\n" + history.toString()