https://github.com/xd009642/mdbook-chess
An mdbook preprocessing plugin to generate chess boards
https://github.com/xd009642/mdbook-chess
chess mdbook mdbook-plugins
Last synced: about 2 months ago
JSON representation
An mdbook preprocessing plugin to generate chess boards
- Host: GitHub
- URL: https://github.com/xd009642/mdbook-chess
- Owner: xd009642
- License: apache-2.0
- Created: 2022-08-06T14:24:25.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T18:35:02.000Z (about 2 years ago)
- Last Synced: 2025-02-03T22:38:25.533Z (8 months ago)
- Topics: chess, mdbook, mdbook-plugins
- Language: Rust
- Homepage:
- Size: 167 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# mdbook-chess
Create chess boards in your mdbooks!

# Installation
Simply:
```
cargo install mdbook-chess
```And then add to your mdbook project as so:
```
# book.toml
[book]
authors = ["xd009642"]
language = "en"
multilingual = false
src = "src"
title = "mdbook-chess"[preprocessor.chess]
```For an example book just look to the provided [demo-book](./demo-book).
# Usage
Currently the chess boards are specified via a very simple YAML structure. With
5 possible fields:* load - either "start" for the starting board or a FEN string. If not provided it's default starting board
* save - name to save board under (can be a list)
* moves - list of moves
* overwrite - boolean of whether to overwrite saved version of the board with these moves
* highlights - highlight a square on the board a list of squares
* lines - lines and arrows from square to square (currently only straight)So we can create a starting board like using a code block with the language set to chess. Like:
```chess
load: start
```Or like:
```chess
# mdbook seems to hate empty code blocks so have at least a blank line
```_For brevity/formating the backticks and "chess" language specifier will be omitted
for future examples._Of course if we want to refer to this board later we need to save it. So we can
create a board with a name to refer to it later as so:```chess
save: our_board
```We can then load it and apply some moves - this will overwrite it so to do
alternatives can set overwrite to false and start from previous position. We
can also save multiple boards from a point for exploring many different routes:```chess
load: our_board
save: ["ck-main", "ck-2", "ck-3"]
moves: ["e4", "c6", "d4", "d5"]
```Arrows are done by writing the two squares and the line between them, there are
currently 3 styles:* `-` a line
* `->` a single direction arrow
* `<->` a bidirectional arrowAnd we can use them as so:
```chess
load: our_board
moves: ["e4", "c6", "d4", "d5"]
lines: ["e2->e4", "d1<->h5", "a4-h4"]
```Generally, if there's a syntax error in the markdown there's a reasonable
chance you'll see a bunch of SVG text dumped into the book. If this happens
read the log messages and hopefully an answer will be gleaned.For an example of all the features in use please look to the demo book!
# Roadmap
## Potential future features
These are features I'd be willing to do if there was demand and they were
sufficiently easy or willing to accept PRs for.* GIF generation
* L shaped move arrow for horsey
* Chess.com style icons (blunder, excellent etc)
* Styling and theming
* More layout options in page
* Rank and file labels
* Flip the board## Unlikely features
These are features where they will only be added via PR but the PR may
not be accepted* Chess variants
* Eval bar# License and Copyright
All chess SVGs were created by Wikimedia user Cburnett and are CC BY-SA 3.0
licensed. You can find them [here](https://commons.wikimedia.org/wiki/Category:SVG_chess_pieces)
I've edited them to template in a transform and remove the outer tags for
ease of board generation.All other aspects of this project are currently licensed under the terms of both
the MIT license and the Apache License (Version 2.0). See LICENSE-MIT and
LICENSE-APACHE for more details.