Skip to content

Commit

Permalink
Omit empty headers from pgn generation
Browse files Browse the repository at this point in the history
  • Loading branch information
lubert committed Aug 19, 2024
1 parent e13afdc commit ca0992e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pgn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export function isMainline(node: TreeNode<HexState>): 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<HexState>): string[] {
Expand Down

0 comments on commit ca0992e

Please sign in to comment.