Skip to content

About

Write a book in Markdown, get a Windows app: portable .exe, setup .exe, .msi or .msix. Tauri 2 + Rust + Vue.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Book Craft

Write a book in Markdown, press Build, get a Windows app: a portable .exe, a setup .exe (NSIS), an .msi (WiX) or an .msix — with your title, icon, publisher, version and package ID inside.

CI License: MIT

Download

Get the latest installer from Releases: Book.Craft_*_x64-setup.exe (recommended) or the .msi. bookcraft.exe is the command-line builder. Windows 10 or 11, x64.

What the books can do

  • Read in one long scroll or turn pages, one or two at a time, with Fade, Slide, Flip (a page curl you can drag) or Instant turns.
  • Paper look, focus mode, full screen, light, sepia and dark themes, text size, typeface, line spacing and width (narrow to full).
  • Search, bookmarks, highlights in four colours (select text, then pick a colour), remembered reading position, page numbers, page arrows and a contents sidebar.
  • The author decides whether readers can select and copy text; code blocks keep their copy button either way.
  • Callouts, quotes, boxes, columns, tabs, math (KaTeX), chemistry, diagrams (Mermaid), charts, drawings, code with highlighting, quizzes, flashcards, exercises, timelines and more.

How it works

book-craft/
├── src/                  Studio UI (Vue 3 + CodeMirror)
├── src-tauri/            Studio backend (Tauri 2)
│   └── resources/        reader template + KaTeX/Mermaid (generated by `prepare:resources`)
├── crates/
│   ├── book-core/        project files, Markdown block engine, book.pak, exe editing, installers
│   │   └── runtime/      blocks.css / blocks.js shared by the preview and every reader
│   ├── reader/           the reader app every book is made from (Tauri 2, ~3.7 MB)
│   ├── pak-format/       how book.pak is found inside or next to the reader exe
│   └── cli/              `bookcraft` command line (CI, scripts)
└── scripts/prepare.mjs   builds the reader template and copies resources

The reader is compiled once. Building a book never compiles Rust:

  1. Chapters are rendered to HTML (syntax highlighting, charts and drawings happen here) and packed with the assets into book.pak (a zip).
  2. The reader template is copied and its icon and version resource are replaced (editpe).
  3. Portable: book.pak is appended to the exe. Installers: the exe and book.pak are installed side by side.
  4. NSIS, WiX 3 and MakeAppx package it; SignTool signs it if you provide a .pfx.

At start-up the reader takes its identity (window title, app ID, data folder) from the book's manifest, so every book is its own app with its own settings.

Development

Prerequisites: Rust (MSVC) and Bun. Packaging uses NSIS 3, WiX Toolset 3.14 and MakeAppx/SignTool. If they are missing, Build offers to download them (no administrator rights needed) into %LOCALAPPDATA%\uz.nurafshon.bookcraft\tools, or shows the winget command to install them system-wide. Tauri's own caches in %LOCALAPPDATA%\tauri and installed copies are found automatically.

bun install
bun run prepare:resources
bun run tauri dev

prepare:resources builds the reader template (release) and copies it plus KaTeX and Mermaid into src-tauri/resources. Run it again after changing anything in crates/reader.

bun run test

Scripts

Script What it does
bun run app Run the studio with hot reload (tauri dev)
bun run dev Studio UI only, in a browser (add ?mock for fake data)
bun run check Type-check the studio UI
bun run test Rust tests for every crate
bun run verify check + test
bun run prepare:resources Build the reader template, fonts, KaTeX and Mermaid into src-tauri/resources
bun run build:app Build and package the studio: target/release/bundle/nsis/*-setup.exe and bundle/msi/*.msi
bun run build:cli Build the command-line builder: target/release/bookcraft.exe
bun run package build:app + build:cli
bun run build:all Everything in one go: resources, type check, tests, installers and CLI, then a list of what was built (-- --skip-tests to go faster)
bun run lucide-icons Regenerate the reader's and blocks' icons
bun run icons Regenerate the app icons

Releases

GitHub Actions runs type checks, tests and a build on every push (.github/workflows/ci.yml). Pushing a tag like v0.2.0 builds the installers and the CLI and attaches them to a draft release (.github/workflows/release.yml); review the draft, then publish it. Bump the version in package.json, Cargo.toml ([workspace.package]) and src-tauri/tauri.conf.json first.

Try the studio UI in an ordinary browser with fake data: run bun run dev and open http://localhost:1420/?mock.

Command line

cargo run -p bookcraft -- new "D:\Books\My Book" --title "My Book" --author "Me"
cargo run -p bookcraft -- build "D:\Books\My Book" --targets portable,nsis,msi,msix

Set BOOKCRAFT_CERT_PASSWORD (or pass --password) to sign.

cargo run -p bookcraft -- tools install missing

Downloads any missing packaging tools (nsis, wix, sdk for MakeAppx and SignTool, webview2, or all) into the same folder the studio uses.

cargo run -p bookcraft -- cert new "CN=My Press" D:\certs --password secret

Studio UI

The studio uses its own component kit in src/ui (UiButton, UiSelect, UiRange, UiSwitch, UiCheckbox, UiSegmented, UiInput, UiField, UiCard, UiDialog, UiMenu, UiColor, UiBadge, UiScrollArea) and Lucide icons from @lucide/vue. The reader and the book blocks have no build step, so their icons are generated from the same package: run bun run lucide-icons after changing the lists in scripts/lucide-icons.mjs (it writes crates/reader/ui/icons.js and crates/book-core/runtime/icons.css).

Fonts

Appearance → Fonts picks four roles: body text, headings, labels/captions/controls, and code. Choose Windows fonts (no size cost) or the bundled library of 19 open-licence (SIL OFL) families: Literata, Source Serif 4, Merriweather, Lora, EB Garamond, PT Serif, Noto Serif, Playfair Display, Inter, Source Sans 3, IBM Plex Sans, Nunito, Noto Sans, Atkinson Hyperlegible, OpenDyslexic, Caveat, JetBrains Mono, Fira Code and Source Code Pro. Most include Cyrillic. A book carries only the fonts it uses (typically 100–500 KB each), with their licence files.

Under Reader → Fonts readers can switch to you choose what the reader's typeface menu offers besides the book's own font.

The library is built from the @fontsource packages by scripts/fonts.mjs (run as part of bun run prepare:resources) into src-tauri/resources/runtime/fonts.

Book settings file

Each book folder holds its settings in book.json or book.toml (same data; TOML is nicer to edit by hand). Switch in Book details → Settings file; if both exist, book.toml wins.

Signing

  1. Build → Code signing → Create test certificate… makes a self-signed .pfx (kept in Book Craft's data folder, never in the book) to try signing.
  2. For real releases use a certificate from a certificate authority, or Azure Trusted Signing; readers' PCs don't trust test certificates.
  3. The studio checks the certificate before building: password, expiry, code-signing use and — for MSIX — that its subject equals the Publisher ID.
  4. To install an MSIX signed with a test certificate on your own PC, use Trust on this PC… (asks for administrator permission and adds it to Local Machine › Trusted People). Developer Mode can also register the unpacked package.

The portable exe is signed after the book is appended, so the signature covers the book too.

Writing

Chapters are Markdown with GitHub extensions (tables, task lists, footnotes, strikethrough, ==highlight==, H~2~O, x^2^, ||spoiler||, > [!NOTE] alerts). Blocks use ::: containers and fenced code; options go in { }. Nest containers by using more colons on the outside (::::).

Family Syntax
Callouts ::: note, tip, info, warning, danger, important, success, question, example, summary, keypoints, objectives, history — {title="…" collapsible=true color=teal} (collapsible callouts, details, spoilers, hints and solutions start collapsed; add collapsed=false or open to start them open)
Theorem-style ::: theorem, lemma, corollary, proposition, definition, proof, remark (auto-numbered)
Quotes ::: quote {style=classic|pull|card|big|line|shaded|minimal author= source= role=}, ::: epigraph
Boxes & shapes ::: box {style=framed|shaded|tinted|filled|outline|dashed|double|card|note shape=rounded|square|pill|circle|cut|ticket color= width= align= float=}
Layout :::: columns {count=3} + ::: column, ::: columns {flow=true}, :::: tabs + ::: tab {title=}, ::: details {summary=}, ::: spoiler, ::: aside, ::: sidenote, ::: center, ::: opener {label= image=}, ::: pagebreak
Prose ::: verse {title= author=}, ::: dialogue, ::: letter, ::: lead, ::: smallcaps
Math $x^2$, $$…$$, ```math {#eq-id}, ```chem, \ce{H2O}, \pu{9.8 m/s^2}
Code ```rust {title="main.rs" lines=true highlight="2,4-6" start=10 wrap=true}, ```js {run=true}, ```terminal, ```diff
Diagrams & charts ```mermaid, ```chart {type=bar|line|area|pie|donut|hbar|stacked title= x= y=} (CSV or JSON), ```canvas (shapes, arrows, axes, text, images)
Media ![alt](assets/x.png "caption"), ::: figure {src= caption= credit=}, ::: gallery {columns=3}, ::: compare {before= after=}, ::: audio {src=}, ::: video {src= poster=}, ::: attachment {src= label=}
Learning ::: quiz {multiple=true} (task list: [x] = correct, > = explanation), ::: exercise {difficulty=} with ::: hint / ::: solution, ::: flashcards (definition list), ::: steps, ::: timeline, ::: glossary
Advanced ```widget {height=300} (sandboxed HTML/JS, off by default), any ::: my-block styled by your own CSS

Each family can be switched off in Blocks & features; KaTeX and Mermaid are only packed into books that use them.

Notes

  • Installer license: Build → Installation → License shown by installers → Write… opens an editor with templates (all rights reserved, a simple end-user agreement, CC BY, CC BY-NC). It is saved as legal/LICENSE.txt in the book, and the setup .exe and .msi show it before installing.
  • MSIX must be signed to install outside the Store, with a certificate whose subject equals the book's Publisher ID (CN=…). The Store signs Store submissions itself.
  • MSI versions use the first three numbers (1.2.3); keep the package ID the same across editions so upgrades replace older installs.
  • Unsigned apps trigger SmartScreen warnings until signed with a trusted certificate.
  • Readers keep their reading position and bookmarks in %LOCALAPPDATA%\<package ID>. The setup .exe's uninstaller offers to delete them (off by default, so silent uninstalls and upgrades keep them); the MSI leaves them in place.
  • The reader draws its own title bar that follows the book's theme; choose Appearance → Reader → Title bar → Windows for the standard one.
  • Raw HTML in Markdown is shown as text unless turned on; widgets and runnable code run in sandboxed frames without access to the reader's files.

License

MIT © 2026 Otabek Sadiridinov

Bundled fonts are under the SIL Open Font License (each book carries the licence of the fonts it uses); KaTeX and Mermaid are MIT; icons are from Lucide (ISC).

About

Write a book in Markdown, get a Windows app: portable .exe, setup .exe, .msi or .msix. Tauri 2 + Rust + Vue.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages