mliebelt / pgn-viewer

Simple PGN viewer with the necessary features to display chess games
GNU General Public License v3.0
165 stars 44 forks source link

Comment Markup Annotations #91

Closed cgencer closed 5 years ago

cgencer commented 6 years ago

Hi, great work! I surely enjoyed the parser, as I was trying to build one using radix-trie trees to save the data as an internal structure but caught up on writing a detailed regexp filtering, so I switched over to your flat-structure with two-sided references, which just simply works easily. Thanks! I definitely will share my version of PGN-editor, when finished.

As seen on various PGN-edit tools, Comment Annotations with markup code for coloring tiles and drawing arrows would be a nice feature for another release. The internal parser on pgn.js could be expanded for this. More info at https://chesstempo.com/user-guide/en/pgnViewerCommentAnnotations.html

Another idea is to able to make the renderer easily replacable, like plugin. e.g. to use chessboard.js if the user wants to or even only render as text-only, etc.

thanks again, your work saved quite some time for me. At least I can focus more on usability matters right now. best, CG.

mliebelt commented 6 years ago

Thank's for the feedback, and your comments about annotations. I have refactored the code to use Chessground (the board from lichess.org), and I am nearly ready to create a new release. And then we have support by the board for annotations, and can learn how to hold them in the comments. This would mean, that you can e.g. create a game with lichess.org, and redisplay then that at your website.

Thank's for your advice, I will need some time to implement it ...

mliebelt commented 6 years ago

I just tried the coloring for tiles and arrows, and lichess.org uses exactly the same format. I have to check, if that format is as well used by Chessbase. I have to check that on a different computer. It should be easy to interpret those comments, and the current board allows to draw arrows and mark fields (but without adding that as comment).

cgencer commented 6 years ago

Hi again, it seems the pgn-parser needs to be updated accordingly, as the used one spits out comments with [%c.. ..]

there are [%cal ...] [%csl ...] commands within the comment, but it would be GREAT, if you would also add possibility for other. maybe only check for [%cXX ...] so poeople like me could also use other non-standart posibilities. I've got several options for video, audio and other comment-commands, thus I would HIGHLY appreciate such. thanks!

mliebelt commented 6 years ago

Thanks a lot for your comments, I have the same idea about that. I had to (partially the parsing of headers, when I tried the graphics stuff the first time.

But first I have to do a release with Chessground as a replacement, then I will start on this stuff.

Bye miebelt

cgencer commented 6 years ago

I've found some interesting tags here: http://www.enpassant.dk/chess/palview/manual/pgn.htm especially cpmment markups and annotations are interesting.

mliebelt commented 6 years ago

A great resource, thank you a lot for the link. I have to look at some of the ideas how to use comments in an ... well, interesting way. At the moment I am glad that viewing games with circle and arrow annotations works. Have to find out how to get an event handler for annotation events registered somehow ... (and have no idea yet).

cgencer commented 6 years ago

cool! nice to hear that its working now... is there a way to add also my own comment-codes? even some how-to's without adding them to your codebase would be great. i'd like to add something such as [%cvd 2462362;05:26:15] so i can reference a video (e.g. its id & a timestamp) within the comment. this way, i could easily sync videos to the board.

mliebelt commented 6 years ago

At the moment, the comment annotations are read directly from the grammar, and the generated parser. See the grammar file https://github.com/mliebelt/PgnViewerJS/blob/master/js/pgn-rules.peg from line 61 about the implementation.

I have not yet described how to generate from that the parser. Here are the rough steps:

  1. Go to https://pegjs.org/online
  2. Enter on the left the grammar file
  3. Tune it then
  4. Test on the right if that works
  5. At the end, download parser.
  6. Take the resulting file, and paste the content in the right manner into https://github.com/mliebelt/PgnViewerJS/blob/master/js/pgn-parser.js (replace from line 7 up to end).

I don't see any chance to abstract the comment annotations away, the only way would be to not interpret at all the content. Then everything that looks like [%.*} (inside a comment of course) will be kept with the word after the % as key. Will think about that.

mliebelt commented 5 years ago

Did some analysis, it seems to be doable. Those are the steps: