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()
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 theHistory
Object and also to use these Objects independent of thePgn
Object. (Header renders the header and History renders the history ontoString()
.Result: Pgn.js renders the pgn on
toString()
asheader.toString() + "\n" + history.toString()