page

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(p Params) ([]byte, error)

Build renders p into a complete, self-contained HTML document.

func DocKey added in v0.8.0

func DocKey(abs string) string

DocKey is the identity of a document across runs: the first 16 hex characters of the sha256 of abs. The path must be absolute with its symlinks already resolved by the caller — the same file reached two ways has to hash the same, or a document would lose its reading position depending on how it was named. Only the hash reaches the page: under --tunnel that page is read by someone else's browser, and the path would name the OS user and their client.

Types

type Block added in v0.5.0

type Block struct {
	HTML     []byte
	Editable bool
}

Block is one top-level chunk of a document. It mirrors render.Block; the page package keeps its own type so it depends only on primitive inputs, like Body.

type Conflict added in v0.8.0

type Conflict struct {
	// Doc is the document prefix, which the client answers the banner with.
	Doc string
	// Name is the document as the page names it elsewhere: the prefix of a
	// single-document page is empty and names nothing to the author.
	Name string
}

Conflict is one document whose file diverged from the session under unsaved edits. It mirrors edit.Conflict; the page package keeps its own type so it depends only on primitive inputs, as it does for the table of contents.

type Doc added in v0.5.0

type Doc struct {
	Prefix string
	Path   string
	Title  string
	// Key identifies the document across runs, so the page can remember where
	// its reader stopped. It is DocKey of the file path; an empty Key means a
	// document without memory.
	Key    string
	Body   []byte
	Blocks []Block
	TOC    []TOCEntry
}

Doc is one rendered markdown document placed into the page. Every document stays in the DOM at once — only the active one is visible — so navigating between files never needs the server and the page survives its exit.

type Params

type Params struct {
	Docs       []Doc
	Theme      string
	Size       string
	HasMermaid bool
	HasKatex   bool
	Edit       bool
	EditToken  string
	// Warnings are the render issues the documents came with, already named by
	// document. They seed the ⚠ badge of an edit page, which every later render
	// refreshes from its own answer: without them the warnings of the very first
	Warnings []string
	// Dirty holds the prefixes of the documents that hold edits not yet written
	// to disk. An editing page is rebuilt on every load, so a reload can land on
	// a session that is ahead of the files: without this the fresh page would
	Dirty []string
	// Conflicts names the documents whose file moved on disk under unsaved
	// edits. A conflict is a state, not a notice: it is raised once and stays
	// until it is answered, so the only event carrying it is long past by the
	// time the author reloads — and a page built without it would offer them
	// nothing but the overwrite.
	Conflicts []Conflict
	// Live marks a page that follows the session it was built from: the client
	// opens the event stream and applies what the server pushes. A reading page
	// under --tunnel is live too, so this is not implied by Edit.
	Live bool
	// Seq is the state the markup was built from. The client sends it back as
	// the stream cursor, so events the page already shows are skipped instead of
	// replayed over it.
	Seq uint64
	// Epoch names the run of the CLI the markup was built by. It travels back
	// with the cursor: the cursor counts from zero in every run, and only the
	// pair says whether a reconnecting tab is caught up or is still showing a
	// page an earlier run left it.
	Epoch string
}

Params is the input to Build.

type TOCEntry added in v0.2.0

type TOCEntry struct {
	Level int
	ID    string
	Text  string
}

TOCEntry is one table-of-contents link rendered into the right sidebar. It mirrors render.TOCEntry; the page package keeps its own type so it depends only on primitive inputs, like Body.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL