diff --git a/README.md b/README.md index c8f32f8..19756ef 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,59 @@ # Sheaf -A fast, lightweight, **read-only** desktop Markdown viewer. Launch it against a -file (e.g. a project README) and get a clean rendered view instantly. No -editing, no chrome, no clutter. +**Sheaf renders a Markdown file into a clean, instant, read-only window.** Point it at a README before you clone, put it beside your editor while you write, or browse through notes without touching them. Either way you get a calm, typographically comfortable document with no editing chrome, no toolbars, and no buttons competing with your prose. -Built with [Wails](https://wails.io) (Go + Svelte) with Markdown rendering by -[blackfriday/v2](https://github.com/russross/blackfriday). +## Why I built this + +I kept bouncing between a browser tab, a code editor's cramped preview, and a full-featured Markdown editor just to *read* documents. Each one spent screen space and attention on tools for writing, even when I only wanted to read. + +I needed a dedicated, trustworthy surface I could open as easily as I bind a key. You bind Sheaf to `.md` files system-wide, you get a viewer that starts fast, stays out of the way, and never opens a document for editing. Every feature decision flows from that. ## Usage ```sh sheaf README.md # open a file directly -sheaf # launch, then use Open (or Ctrl+O) +sheaf # launch, then Open (or Ctrl+O) ``` -Supported extensions: `.md` `.markdown` `.mdown` `.mkdn` `.mkd` `.mdwn` -`.mdtxt` `.mdtext` `.markdn` - -Features: - -- Instant render of GFM-style Markdown: tables, fenced code, strikethrough, - autolinks, footnotes, heading anchors, smart punctuation -- Syntax highlighting for fenced code blocks, tokenised server-side (Chroma) - in the Digital Rust theme; languages without a lexer render as plain fences -- Relative images and links resolved against the document's directory, so - README screenshots and sibling files render in place (served read-only from - that directory only, with symlink and `..` escape checks) -- External links open in the system browser; in-document anchor links scroll -- Live reload: the view refreshes automatically when the file changes on disk, - keeping your scroll position so you never lose your place mid-edit -- Find in page (Ctrl+F or `/`, Enter/Shift+Enter or F3/Shift+F3 to step, Esc to close) -- Table of contents panel (T or F6) built from the document's own headings -- Recent files menu: the last 8 documents, cycled with Ctrl+Tab / Ctrl+Shift+Tab -- Type zoom: Ctrl+= / Ctrl+- steps the reading size, Ctrl+0 resets to your system size -- Single instance: opening a second file raises the existing window +Supported extensions: + +- `.md` +- `.markdown` +- `.mdown` +- `.mkdn` +- `.mkd` +- `.mdwn` +- `.mdtxt` +- `.mdtext` +- `.markdn` + +## Features + +- GFM-style Markdown: tables, fenced code blocks, strikethrough, autolinks, footnotes, heading anchors, smart punctuation +- Syntax highlighting for fenced code blocks, tokenized on the Go backend in the Digital Rust theme; languages without a recognized lexer render as plain fenced blocks +- Relative images and inbound Markdown links (README → CHANGELOG, for example) resolve against the document's directory, so screenshots and sibling pages render and navigate in place; they are served read-only from that directory only, with symlink and `..` escape checks (test-enforced) +- External links open in your system browser +- In-document anchor links scroll to the section you request +- Live reload: the view refreshes when the file changes on disk (800 ms polling) and keeps your scroll position, so you never lose your place mid-edit +- Find in page (Ctrl+F or `/`), step through hits with Enter or Shift+Enter, close with Esc +- Table of contents panel (T or F6) built from the document's headings +- Recent files menu holds the last eight documents, cycle with Ctrl+Tab or Ctrl+Shift+Tab +- Type zoom (reading size): Ctrl+= / Ctrl+-, Ctrl+0 returns to your system font size +- Single instance: opening a second file raises the existing window and switches to the new file - Drag-and-drop a file onto the window to open it -- Dark/light theme following the system preference -- Read-only by design; raw HTML in documents is stripped, unsafe link schemes - (e.g. `javascript:`) are neutralized, and external links open with - `rel="nofollow noreferrer noopener"` +- Dark and light themes follow your system preference -## Development +## Read-only by design -Requires Go, Node, pnpm, and the Wails CLI. +Being read-only is the point, not a gap. There's no way to accidentally modify an untrusted document, and nothing to compete with your attention. -```sh -wails dev # live-reload dev mode -wails dev -tags webkit2_41 # on systems with webkit2gtk-4.1 -``` +Sheaf is deliberate about being safe to open anything. Raw HTML in a document is stripped at render time. Unsafe link schemes such as `javascript:` are neutralized. Every external link opens with `rel="nofollow noreferrer noopener"`. These rules are enforced by automated tests on every build. + +If the file you're watching is deleted, the last rendered content stays on screen and the app silently stops watching. + +## Getting Sheaf -## Building +Prerequisites: Go, Node, pnpm, and the Wails CLI. ```sh wails build # produces build/bin/sheaf @@ -58,22 +62,49 @@ wails build -tags webkit2_41 # if your distro ships webkit2gtk-4.1 ### Linux desktop install -To install the binary plus the freedesktop integration (`.desktop` entry, app -and Markdown icons, AppStream metadata, and the Markdown MIME association so -Sheaf appears in "Open With"): +To install the binary plus the freedesktop integration (a `.desktop` entry, app and Markdown icons, AppStream metadata, and the Markdown MIME association so Sheaf appears in "Open With"): ```sh -just desktop-install # installs into ~/.local +just desktop-install # install to ~/.local just dest=/usr/local desktop-install # system-wide, with sudo -just desktop-uninstall # remove it again +just desktop-uninstall # remove ``` -This registers Sheaf as a viewer for `text/markdown` and puts it in your app -launcher. +### Arch Linux + +AUR package files for `sheaf-git` live under `aur/` in this repository. To build and publish them, run: + +```sh +just aur-init # clone AUR repo, seed PKGBUILD, build +just aur-build # rebuild after changes +``` + +## Development + +```sh +wails dev # live-reload dev +wails dev -tags webkit2_41 # required on distros with webkit2gtk-4.1 +``` + +If Go tooling fails because `frontend/dist` is missing, run the frontend build once: + +```sh +cd frontend && pnpm install && pnpm run build +``` ## Testing ```sh -go test ./... # backend rendering tests -cd frontend && pnpm run check # frontend typecheck +go test ./... # backend rendering and asset tests +cd frontend && pnpm run check # Svelte typecheck ``` + +## Stack + +Wails v2 (Go backend, Svelte 5 frontend in your OS webview). Markdown rendering by blackfriday/v2. Syntax highlighting by Chroma. + +## License + +MutuaL-1.2. See `LICENSE.md`. + +Project home: diff --git a/justfile b/justfile index f418a69..d74ee95 100644 --- a/justfile +++ b/justfile @@ -8,7 +8,7 @@ dev: build: wails build -tags webkit2_41 - upx --ultra-brute build/bin/sheaf + upx --lzma -9 build/bin/sheaf test: go test ./...