mdpreview

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package mdpreview is the nook side of the markdown preview pane. It wraps the reusable markdownviewer.Viewer from glyph's components directory with nook's path/focus/size conventions so the host can place it on the right column alongside git and term.

The pane is read-only: it shows what's in the active buffer (or the freshly-saved file). Editing happens in the editor pane. Scrolling is handled by the embedded Viewer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMarkdownPath

func IsMarkdownPath(path string) bool

IsMarkdownPath reports whether the given path is something the preview can render. The check is case-insensitive on the extension; .md and .markdown are the only accepted suffixes. Files without an extension are rejected so the host can show a status-line hint.

Types

type CancelMsg

type CancelMsg struct{}

CancelMsg is emitted when the user presses Esc while the pane has focus. The host treats it as a request to close the preview.

type Pane

type Pane struct {
	// contains filtered or unexported fields
}

Pane is the markdown preview pane.

func NewPane

func NewPane(t theme.Theme) Pane

NewPane constructs an empty preview pane bound to the given theme.

func (Pane) Blur

func (p Pane) Blur() Pane

Blur sets focused=false.

func (Pane) Focus

func (p Pane) Focus() Pane

Focus sets focused=true.

func (Pane) Focused

func (p Pane) Focused() bool

Focused reports whether the pane has keyboard focus.

func (Pane) HasSource

func (p Pane) HasSource() bool

HasSource reports whether the pane currently holds content. The host uses this to decide whether to open the pane vs. show "no buffer."

func (Pane) Path

func (p Pane) Path() string

Path returns the source path the pane is currently rendering.

func (Pane) Update

func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)

Update routes scroll keys to the embedded viewer when focused, and emits CancelMsg on Esc. All other keys pass through.

func (Pane) View

func (p Pane) View() string

View renders the pane. Layout is:

title row    "preview  <basename>"  (muted if no source)
body rows    viewer output (height-1 lines)

func (Pane) WithSize

func (p Pane) WithSize(w, h int) Pane

WithSize sets pane dimensions. The viewer's body height is one row shorter than the pane height to leave room for the title row.

func (Pane) WithSource

func (p Pane) WithSource(path, contents string) Pane

WithSource replaces the markdown content and resets the scroll offset to the top. Path is used purely for the title row.

Jump to

Keyboard shortcuts

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