I decided to start contributing to Redox OS. While searching for resources to study, I came across the Rustonomicon. Having dismissed it in the past — "I certainly won't be writing unsafe Rust any time soon" — I now felt the time has come.

There was only one problem: I don't enjoy reading on my computer screen. Like, at all. But I do enjoy1 reading on my dated e-reader. As it turns out, you can make mdBook builds spit out .epub files!

Here is how you do it.

Install requirements

  1. Install mdbook and mdbook-pandoc
$ cargo install mdbook
$ cargo install mdbook-pandoc --locked
  1. Install pandoc through your package manager:
$ pacman -S pandoc-cli  # I use arch btw

Build the EPUB file

  1. Clone the Rustonomicon source
$ git clone https://github.com/rust-lang/nomicon.git
  1. Add an EPUB profile to book.toml
diff --git a/book.toml b/book.toml
index f51dfa31b3..1487933ef1 100644
--- a/book.toml
+++ b/book.toml
@@ -31,5 +31,9 @@ git-repository-url = "https://github.com/rust-lang/nomicon"
 "./arc-layout.html" = "./arc-mutex/arc-layout.html"
 "./arc.html" = "./arc-mutex/arc.html"
 
+[output.pandoc.profile.epub]
+to = "epub"
+output-file = "rustonomicon.epub"
+
 [rust]
 edition = "2024"
  1. Build the book
$ mdbook build

Huzzah! Now you have a book/pandoc/epub/rustonomicon.epub file that you can copy to your dated e-reader.

:wq

  1. "Enjoy" may be too strong of a word. Physical books all the way, but since not everything gets printed, I learned to love my e-reader. ↩