server

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package server implements the md-preview HTTP+WebSocket preview server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(opts Options) error

Run starts the server, reads JSON commands from stdin, and blocks until stdin closes or the process is interrupted. On {"type":"quit"} the process exits with status 0.

The startup line "[md-preview] Serving on http://localhost:<port>/" is written to stdout so external tooling parsing it keeps working.

Types

type Options added in v0.1.2

type Options struct {
	File     string
	Port     int
	Theme    string
	Colemak  bool
	Watch    bool
	OnListen func(port int)
}

Options configures Run. Watch enables the editor-agnostic file watcher (mtime polling). OnListen, if non-nil, is invoked with the actual bound port once net.Listen succeeds — useful when Port is 0 (ephemeral) and the caller needs the address to open a browser.

Jump to

Keyboard shortcuts

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