Crates.io | mdbook-chess |
lib.rs | mdbook-chess |
version | 0.2.2 |
source | src |
created_at | 2022-08-06 20:54:55.887721 |
updated_at | 2023-08-11 18:37:35.541188 |
description | An mdbook preprocessing plugin to generate chess boards |
homepage | https://github.com/xd009642/mdbook-chess |
repository | https://github.com/xd009642/mdbook-chess |
max_upload_size | |
id | 639988 |
size | 164,914 |
Create chess boards in your mdbooks!
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.
Currently the chess boards are specified via a very simple YAML structure. With 5 possible fields:
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:
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:
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:
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!
These are features I'd be willing to do if there was demand and they were sufficiently easy or willing to accept PRs for.
These are features where they will only be added via PR but the PR may not be accepted
All chess SVGs were created by Wikimedia user Cburnett and are CC BY-SA 3.0 licensed. You can find them here 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.