The Serifu editor
README.md

Serifu (v3) #

Serifu is a text editor and project workbench for comics and manga translators and editors. It's built around a plain-text markup language, and it's designed to make the work of comics translation faster, less laborious, and less error-prone.

Why use Serifu #

  • No more counting: Automatic in-script numbering of pages and panels
  • No more typing the same name hundreds of times: Character and Style autocomplete
  • Write in one format, export to any publisher's style sheet. Currently Viz, Yen Press, Seven Seas, Kodansha, and One Peace. If you need one that's not that list, send me an example and I'll add it.
  • Smart Search: Ever wanted to search for text within a specific character's dialogue? Now you can search for text within a specific character's dialogue.
  • Rename a character everywhere at once: Realized your romanization for a character's name was wrong halfway through the volume? Double-click it in the Origins panel and change it.
  • Built-in structure-aware OCR: Automatically detect panels and text chunks on a page of the source material, then import the text into your script as an annotation.
  • Multiple sources for OCR workflow: PDFs, page-by-page image files, or connect to the Serifu editor with your smartphone over WiFi (really) and snap photos of pages.

Tech stack #

Layer Technology
Desktop shell Tauri 2 (Rust)
Frontend Svelte 5 + TypeScript
Editor CodeMirror 6
Grammar Lezer (@lezer/lr + @lezer/generator)
Word export docx
PDF import pdfium-render (Rust)
Camera import tiny_http (Rust) + uqr (QR)
Inference local HTTP service (serifu-ml), behind a seam
Build tool Vite 6
Tests Vitest + @testing-library/svelte
Package mgr Bun

Architecture #

Organized for maximum testability.

src/
  main.ts                     # mounts App with the real (Tauri) services
  App.svelte                  # owns the session, buffer, project + layout; composes the panes
  lib/
    editor/
      editorController.ts     # framework-free CM bridge: snapshot read path + command write path
      editorSnapshot.ts       # pure projection of EditorState for the UI
      editorBuffer.ts         # CM-backed DocumentBuffer (the source of truth in the app)
      find.ts                 # find/replace: query + matches as a StateField + StateEffect
      lineIndex.ts            # per-line kind, searchable span, and effective Origin (carryover)
      formatCommands.ts       # insert/emphasis/format-document commands + the indent constants
      structureGutter.ts      # Page/Panel labels where the line numbers used to be
      attribCompletion.ts     # Origin/Style autocomplete, ranked from the document
      renameAttrib.ts         # rename an Origin/Style everywhere it's written, in one step
      lang/                   # serifu.grammar → parser.js, highlighting, indent service
    files/
      fileService.ts          # FileService interface (the platform boundary)
      tauriFileService.ts     # real impl — imports Tauri fs/dialog
      fakeFileService.ts      # in-memory impl for tests
      documentSession.ts      # path + saved-baseline + open/save/dirty (framework-free)
      documentBuffer.ts       # DocumentBuffer seam + InMemoryBuffer (test default)
      lineEndings.ts          # detect on load, restore on save
    recovery/
      recoveryController.ts   # all the timing: journal debounce, flush, retire
      recoveryStore.ts        # the seam; tauriRecoveryStore.ts real, fakeRecoveryStore.ts tests
      recoveryScan.ts         # what a surviving journal means, and what to sweep
    vision/
      projectSession.ts       # pages, boxes, order, OCR text — persists as a .serifu-project sidecar
      sourceViewModel.ts      # pane state in image px: DOM-free, fully unit-tested
      serialize.ts            # project → canonical-order .serifu
      pairing.ts              # (syntax tree, project) → script ↔ balloon links, pure
      inferenceService.ts     # the seam; httpInferenceService.ts real, fake for tests
      order/                  # VENDORED reading-order heuristic — change upstream, re-copy
    export/
      scriptDoc.ts            # the only place the tree is read for export: text → ScriptDoc
      formats/*.ts            # pure ScriptDoc → DocxSpec, one per publisher
      buildDocx.ts            # the only module that imports `docx`: DocxSpec → bytes
      exportDocx.ts           # the command: parse → format → pack → FileService
    camera/                   # CameraServer seam + the import state machine
    components/               # thin Svelte shells: Editor, EditorPane, SourcePane, FindPanel, …
    layout/                   # WorkspaceLayout: sidebars, panels, persistence
    icons/                    # inline SVG; lucide.ts is VENDORED
    menu/, windows/, workspace/  # native menu, multi-window close guard, confirm/notify

src-tauri/src/
  lib.rs                      # commands + menu; atomic_write.rs, camera_server.rs, pdf_rasterize.rs

The operational rules and hard-won invariants behind each subsystem live in CLAUDE.md.

Getting started #

Prerequisites #

Develop #

bun install
bun run tauri dev      # launches the app (Vite + Tauri)

Frontend-only (no Rust build) #

bun run dev            # Vite dev server at http://localhost:1420

PDF import, camera import, and the native menu are Tauri-only; in the browser they report themselves as unconfigured rather than failing silently.

The inference service #

Detection and OCR run in a separate local process from the serifu-ml repo, on 127.0.0.1:8807:

cd ~/dev/serifu-ml
PYTORCH_ENABLE_MPS_FALLBACK=1 .venv/bin/python tools/serifu_infer.py

The source pane polls /api/health and disables Detect/OCR while it's down. Everything else in the app works without it.

Test #

bun run test           # run the suite once
bun run test:watch     # watch mode
bun run check          # svelte-check type checking (keep at 0 errors, 0 warnings)
cd src-tauri && cargo test   # the Rust side

Build #

bun run tauri build    # production desktop app
bun run gen:parser     # regenerate parser.js after editing serifu.grammar

Docs #

File What's in it
LANGUAGE.md The living Serifu spec
CLAUDE.md Operational rules + the invariants behind each subsystem
docs/source-panel-ux.md Source-pane user stories and the primitive build order
src-tauri/PACKAGING.md Cross-platform pdfium build checklist