Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
adler3d authored and mliebelt committed May 28, 2024
1 parent 236f0c6 commit 2046546
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,28 @@ It does not have an API, just a JSON structure that has to be read then. You hav
* `pgn`: Reads only the moves of the game (as array).

A code example to read a complete game then looks like:

import { parse } from '@mliebelt/pgn-parser'
let game = parse('[White "Me"] [Black "Magnus"] 1. f4 e5 2. g4 Qh4#', {startRule: "game"})
console.log(JSON.stringify(res, null, 2))
==>
JSON.stringify(res, null, 2)
```javascript
import { parse } from '@mliebelt/pgn-parser'
let game = parse('[White "Me"] [Black "Magnus"] 1. f4 e5 2. g4 Qh4#', {startRule: "game"})
console.log(JSON.stringify(res, null, 2))
==>
JSON.stringify(res, null, 2)
{
"tags": {
"White": "Me",
"Black": "Magnus"
},
"moves": [
{
"tags": {
"White": "Me",
"Black": "Magnus"
},
"moves": [
{
"turn": "w",
"moveNumber": 1,
...
},
{...},
...
]
}

"turn": "w",
"moveNumber": 1,
...
},
{...},
...
]
}
```
See the example `doc/read-sample.js` that can be directly used in the shell: `node doc/read-sample.js`. The directory contains some more examples how to use it.

## How to use it as an CLI?
Expand Down

0 comments on commit 2046546

Please sign in to comment.