Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for annotations #235

Merged
merged 1 commit into from
Jun 11, 2020
Merged

add support for annotations #235

merged 1 commit into from
Jun 11, 2020

Conversation

jtwires
Copy link
Contributor

@jtwires jtwires commented May 3, 2020

  • add methods for creating/retrieving/removing annotations
  • parse bracket- and semicolon-style annotations when loading PGNs
  • output bracket-style annotations when producing PGNs

@jtwires jtwires marked this pull request as ready for review May 3, 2020 01:09
@jhlywa
Copy link
Owner

jhlywa commented May 5, 2020

Thanks Jake. I'll review this over the next few days.

@jhlywa
Copy link
Owner

jhlywa commented May 14, 2020

Thanks @jtwires. It's clear you put a lot of work into this PR. I've got a few questions and suggestions before I merge.

  1. I can see the use-case arising where a user would want to remove all annotations from a PGN. How would you feel about adding an explicit clear_annotation() function that could be called with an optional argument to clear all annotations (e.g. clear_annotation({target: 'game'}) or clear_annotation({all: true}) or something similar, picking good names is hard). Returning the annotation that was cleared (or null) would be a nice touch too.

  2. The PGN spec refers to these annotations as comments; basically anything in { ... } or ;..., while using the term annotation for Recursive Annotation Variations. Could you change the API to use the term comments instead?

  3. I've added a few inlines comments in the PR itself.

Many people have been requesting this capability. Thanks again for your contribution.

README.md Outdated
Retrieve the annotation for the current position, if it exists.

```js
const chess new Chess()
Copy link
Owner

@jhlywa jhlywa May 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor typo const chess = new Chess()

@@ -1541,14 +1615,46 @@ var Chess = function(fen) {
}
}

var to_hex = function(string) {
Copy link
Owner

@jhlywa jhlywa May 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here to explain what you're doing with hex and URI encoding? It's not immediately clear to me. Thanks

@jtwires
Copy link
Contributor Author

jtwires commented May 16, 2020

cool, comment it is..

* add methods for creating/retrieving/removing comments
* parse bracket- and semicolon-style comments when loading PGNs
* output bracket-style comments when producing PGNs
@jhlywa jhlywa merged commit 45a8286 into jhlywa:master Jun 11, 2020
@jhlywa
Copy link
Owner

jhlywa commented Jun 20, 2020

0.11.0 has been pushed to npm. I'll gen up a changelog sometime over the weekend.

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.

3 participants