Open source
By Lukas ·
Two parts of Kernsetzer are open source: the document model, and the importer that reads Word and Markdown manuscripts into it. Both are Rust crates on crates.io, under the MIT or the Apache 2.0 license, whichever you prefer.
This page is for programmers. If you write books, you don’t need any of it: the app has all of it built in.
kernsetzer-model
The book as data. A book holds its details (title, author, language, ISBN) and its sections in reading order: front matter, chapters, back matter. Sections hold blocks such as paragraphs, quotations, verse, scene breaks, tables and images, and blocks hold text with its emphasis. The model says what a manuscript contains, never how it’s laid out.
The crate also reads and writes the .kernsetzer project file, a zip archive with the book as JSON and its images, and holds the typographic rules for English and German text: the right quotation marks, dashes and non-breaking spaces. They are applied when the book is set, so the stored text stays the way the author typed it.
kernsetzer-model on crates.io · source on GitHub · documentation on docs.rs
kernsetzer-import
Reads a .docx or Markdown manuscript into that model. From a Word file it takes the styles, lists, emphasis and images, and works out the chapters, the front matter, the scene breaks and the book’s details. It knows chapter headings in English and German (“Chapter 3”, “Kapitel drei”, “IV.”) and tells the two languages apart from the text when a file doesn’t say, or says wrong. An odd file gives warnings, not an error; only a file that isn’t a manuscript at all is an error.
It also makes a scrambled copy of a manuscript: every letter replaced, the structure kept. An author whose import goes wrong can send the copy instead of the book, and most import problems still show in it.
kernsetzer-import on crates.io · source on GitHub · documentation on docs.rs
Using them
Add both to a project:
cargo add kernsetzer-model
cargo add kernsetzer-import
In code, the libraries are called setzer_model and setzer_import, after Kernsetzer’s working name. One call reads a file:
use setzer_import::read_manuscript;
use std::path::Path;
let path = Path::new("novel.docx");
let imported = read_manuscript(path)?;
What comes back holds the book, its images and what looked odd, as book, assets and warnings. The crates need Rust 1.92 or newer. Their tests use only public-domain text, such as Jane Austen and Franz Kafka.
Why these two
Every book-formatting tool has to read manuscripts first. What Kernsetzer is about comes after that: setting the book on the page. So the reading is open for anyone to use, in any project, commercial or not, while the layout engine, the designs, the EPUB writer and the app stay closed. The app itself builds on the published crates, so what’s on crates.io is the code Kernsetzer runs.
Issues and pull requests
Issues are welcome on GitHub: a bug, a Word file that imports wrong, a question. I’m not taking pull requests yet. The name “Kernsetzer” is a trademark and isn’t licensed with the code, so a project built on the crates needs a name of its own.