jekyll-chess
A small Jekyll plugin, written in Ruby, that draws a chess board on a web page from a single line of FEN notation.
- Ruby
- Jekyll
Overview
jekyll-chess lets you put a chess position in a Jekyll post as text instead of an image. It adds a tag to Jekyll, the static site generator, so that writing {% fenboard r3r1kR/2p5/p1p1P3/1p4q1/1P2P3/P2P1P2/2P1KB2/Q7 b - - 2 27 %} in a post draws the board for that position. FEN is the standard text format for a chess position.
How it works
The plugin is one Ruby file, and it does its work in three steps. A parser splits the FEN text into its six fields. An interpreter reads the piece placement field and builds a board, with a class for each kind of piece. A renderer turns that board into an HTML table, and gives each square CSS classes for its color and any piece on it. Sass styles and the piece images take care of the look.
Only the first field, which says where the pieces are, is needed. If you leave off the rest, the plugin still draws the board. If you leave out the position altogether, it shows a short error message in place of the board. It also accepts a non-standard “marker” piece, written M in the position string.
The README
The README explains FEN from scratch. It goes through the six fields one at a time, with a worked example, and the install steps are numbered. Installing means copying a few files into your Jekyll site, which is simple but manual. The README also says what is missing: only FEN is supported, and PGN, which records whole games, is a possible future addition.