previewserver

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Browser              string
	Theme                string
	FixedPort            int
	OpenBrowserOnStartup bool
	EnableTabs           bool

	LSPRequestChan = make(chan OpenDocumentRequest)
)

Functions

func GetChromaStyleForTheme added in v0.17.0

func GetChromaStyleForTheme(themeName string) string

GetChromaStyleForTheme returns a recommended chroma syntax highlighting style for a given theme. Since theme names match chroma conventions, most themes return their name directly.

func HasClients added in v0.20.0

func HasClients() bool

HasClients returns true if any WebSocket clients are connected.

func ListThemes added in v0.17.0

func ListThemes()

func Openbrowser added in v0.3.0

func Openbrowser(url, browser string) error

func WaitForClients added in v0.4.1

func WaitForClients(timeout time.Duration) error

Types

type OpenDocumentRequest added in v0.17.0

type OpenDocumentRequest struct {
	URI           string
	TakeFocus     bool
	UpdatePreview bool
}

type Server

type Server struct {
	Server         *http.Server
	InitialContent string
	Port           int
	WorkspaceRoot  string
}

func New

func New() *Server

func (*Server) CloseDocument added in v0.17.0

func (s *Server) CloseDocument(documentURI string, isLastDocument bool)

CloseDocument sends a close message to clients viewing the specified document.

func (*Server) GetWorkspaceRoot added in v0.17.0

func (s *Server) GetWorkspaceRoot() string

func (*Server) SetWorkspaceRoot added in v0.17.0

func (s *Server) SetWorkspaceRoot(root string)

func (*Server) Start

func (s *Server) Start()

func (*Server) Stop

func (s *Server) Stop()

Stop gracefully shuts down the server.

func (*Server) Update

func (s *Server) Update(filename, newContent string, meta map[string]any)

Update updates the current HTML content.

func (*Server) UpdateWithURI added in v0.17.0

func (s *Server) UpdateWithURI(filename, documentURI string, newContent string, meta map[string]any)

UpdateWithURI updates the current HTML content with document URI for client filtering.

Jump to

Keyboard shortcuts

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