PGN special codes

Support for special tags in the PGN has now been added to WordPressChess.

These tags are added as comments in the pgn. This feature is supported for the [pgn] and [chess ignore="1"] short codes. It is also available in both the free and PRO version of WordPressChess.

Here's an example pgn:

[pgn tpl="5" ignore="1"][eventdate "1998.??.??"]
[eventdate "1998.??.??"]
[setup "1"]
[castle "1"]
[index "1"]
[ts "1487793853499"]
[event " White to move."]
[site "?"]
[date "1998.??.??"]
[round "?"]
[white "White mates in 4"]
[black "White mates in 4 1001 Brilliant Ways to Checkmate"]
[result "1-0"]
[fen "r1b2rk1/pp1p1pp1/1b1p2B1/n1qQ2p1/8/5N2/P3RPPP/4R1K1 w - - 0 1"]
[plycount "7"]


{[%ar d5g8][%sq f7,h7]}1. Qxf7+{[%ar g6f7] [%sq g8]}  Rxf7 2. Re8+  Rf8 3. Rxf8+  Kxf8 4. Re8#[/pgn]

The special tags are added inside comments. Comments in PGN files are located inside curly braces {}.

The special tag for rendering arrows is:

  [%ar e2e4;e5e6;#f00]

The tag starts with [%ar and ends with ].

You define from and to squares (e2e4 means arrow from e2 to e4). To add more than one arrow, separate them by a comma.

In the example above you also see that the second arrow from e5 to e6 is assigned a reddish color. Colors are defined after the squares separated by a semicolon. If not defined, default styling will be used. The default styling can be set in the admin tool of WordPressChess (arrow action styling).

To add arrows at the start of the game, insert the comment before first move.

For Squares, the code is:

  [%sq e2,e4]
  [%sq e2;red]

i.e. a tag starting with [%sq and with a list of highlighted squares separated by comma.

Highlighted squares get there default styling from the css class

.dhtml-chess-highlight-square

You can override this styling in your css. This is the default styling:


.dhtml-chess-highlight-square{
opacity:0.5;
background-color:#D32F2F;
}

Here's an example of such codes in action.

Share This:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *