diff --git a/src/pgn.ts b/src/pgn.ts index 698fe20..16a32d5 100644 --- a/src/pgn.ts +++ b/src/pgn.ts @@ -36,7 +36,9 @@ export function isMainline(node: TreeNode): boolean { } export function pgnHeader(header: HeaderMap): string[] { - return Object.entries(header).map(([key, val]) => `[${key} "${val}"]`) + return Object.entries(header) + .filter(([_, val]) => val !== undefined && val !== null) + .map(([key, val]) => `[${key} "${val}"]`) } export function pgnMoves(node: TreeNode): string[] {