Skip to content

Parse uncommon nag symbols (e.g. ±, ∓, ∞...)#28

Draft
tneisinger wants to merge 1 commit intokevinludwig:masterfrom
tneisinger:parse-nag-symbols
Draft

Parse uncommon nag symbols (e.g. ±, ∓, ∞...)#28
tneisinger wants to merge 1 commit intokevinludwig:masterfrom
tneisinger:parse-nag-symbols

Conversation

@tneisinger
Copy link
Copy Markdown
Contributor

Add the ability to parse special NAG symbols from this table.

Example:

const pgn = '1. f3 e6 2. g4?? ∓ $5 ∞ Qh4# 0-1';
const [result] = pgnParser.parse(pgn);

result = {
    comments_above_header: null,
    headers: null,
    comments: null,
    moves: [
        { move_number: 1, move: 'f3', comments: [] },
        { move: 'e6', comments: [] },
        { move_number: 2, move: 'g4', nags: [ '??', '∓', '$5', '∞' ], comments: [] },
        { move: 'Qh4#', comments: [] }
    ],
    result: '0-1'
}

NOTE: This pull request does slightly change the behavior of the parser:

Parsing the move 2. g4?? $2 currently produces:

{ move_number: 2, move: 'g4??', nags: ['$2'], comments: []}

After this commit the new result would be:

{ move_number: 2, move: 'g4', nags: ['??', '$2']}

I've made this a draft pull request in case there are objections to this behavior change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant