chess-moments 1.6.3 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -155,8 +155,17 @@ const momentsToPgn = (moments) => {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
// Add move number for white moves
|
|
159
|
-
|
|
158
|
+
// Add move number for white moves, when starting a variation, or for a
|
|
159
|
+
// black move that follows a variation close ')' or a comment '}' — PGN
|
|
160
|
+
// requires the "N..." indicator whenever a black move isn't immediately
|
|
161
|
+
// preceded by its white pair, else the move text is unparseable.
|
|
162
|
+
const prev = pgn.trimEnd();
|
|
163
|
+
const afterBreak = prev.endsWith(')') || prev.endsWith('}');
|
|
164
|
+
if (
|
|
165
|
+
moveWasByWhite ||
|
|
166
|
+
(depth > 1 && pgn.endsWith('(')) ||
|
|
167
|
+
(!moveWasByWhite && afterBreak)
|
|
168
|
+
) {
|
|
160
169
|
pgn += `${moveNumber}.`;
|
|
161
170
|
if (!moveWasByWhite) {
|
|
162
171
|
pgn += '..';
|