pj 5c0040955e fix(export): correct list nesting, marks, line-start escaping, svg type
Four export-correctness fixes intermingled across the Typst and EPUB
renderers:

- H7: neutralize newlines in escaped text and apply leading-marker
  escaping (= - + / and N.) to the first text node of every block
  (paragraph, heading, list item, blockquote) and figure captions, even
  when that run carries a mark, so author text can never inject Typst
  markup or phantom headings/TOC entries.
- H9: render lists recursively so nested lists survive and multi-
  paragraph list items keep their paragraph breaks (Typst functional
  list()/enum(); EPUB nested <ul>/<ol> and multiple <p> in <li>).
- H10: render strike, underline and inline code marks in both exporters
  (Typst #strike/#underline/#raw; EPUB <s>/<u>/<code> with css).
- H8b: normalize +-bearing image subtypes so an imported svg+xml cover
  becomes cover.svg with the correct media type.

Validated the generated Typst constructs compile with typst 0.15.

Claude-Session: https://claude.ai/code/session_01RzTWrLiy4zGuw2hZSQGamk
2026-06-22 13:24:19 -04:00
2026-06-20 23:46:10 -04:00
2026-06-22 13:03:11 -04:00
fix
2026-06-20 19:07:57 -04:00
2026-06-21 14:37:02 -04:00
2026-06-22 16:50:04 +00:00
2026-06-22 09:56:20 -04:00
2026-06-20 13:09:40 -04:00
2026-06-22 11:56:31 -04:00

margin

An offline desktop app for writing books and exporting them to print-ready PDF and reflowable EPUB — a focused, free alternative to InDesign for text-first books (novels, non-fiction).

Stack

  • Tauri 2 (Rust shell) — offline by construction; the entire export pipeline runs locally, nothing hits the network.
  • React + TipTap — the semantic writing surface.
  • Typst (embedded as a Rust crate) — print-ready PDF with real book typography.
  • Built-in EPUB3 generator + zip packager.

One semantic document feeds three renderers — the editor, the PDF, and the EPUB — from a single design-token theme (Quiet Press: Literata for the page, Hanken Grotesk for the chrome). Both fonts are bundled.

Develop

pnpm install
pnpm tauri dev     # the real desktop app: live PDF dock, file dialogs, PDF/EPUB export
pnpm dev           # browser-only UI preview (Tauri APIs are inert)

The first tauri dev build is slow because it compiles Typst.

Using it

  • A book saves as a single .margin file (JSON). Open / Save with ⌘O / ⌘S.
  • Click the title in the top bar for Book setup (title, author, ISBN, trim size, language).
  • Insert images from the toolbar and choose a placement (inline / full-width / full-page / float).
  • Export to PDF or EPUB from the titlebar menu.

Layout

  • src/editor/ — TipTap editor, extensions, figure block, floating toolbar.
  • src/components/ — app shell, preview dock, book-setup panel, pdf.js renderer.
  • src/export/ — typst.ts (book → Typst source), epub.ts (book → EPUB3 files), exporters.ts.
  • src/store/, src/model/ — document model and state.
  • src-tauri/src/ — pdf.rs (Typst compile), epub.rs (zip packager), project.rs (file IO).
S
Description
No description provided
Readme MIT
8.1 MiB
0 Stars 1 Watchers 0 Forks
Languages
TypeScript 46.6%
CSS 13.7%
Rust 12%
Astro 11.2%
HTML 8.4%
Other 8.1%