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 ¶
- func IsMarkdownPath(path string) bool
- type CancelMsg
- type Pane
- func (p Pane) Blur() Pane
- func (p Pane) Focus() Pane
- func (p Pane) Focused() bool
- func (p Pane) HasSource() bool
- func (p Pane) Path() string
- func (p Pane) Update(msg tea.Msg) (Pane, tea.Cmd)
- func (p Pane) View() string
- func (p Pane) WithSize(w, h int) Pane
- func (p Pane) WithSource(path, contents string) Pane
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMarkdownPath ¶
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 (Pane) HasSource ¶
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) Update ¶
Update routes scroll keys to the embedded viewer when focused, and emits CancelMsg on Esc. All other keys pass through.
func (Pane) View ¶
View renders the pane. Layout is:
title row "preview <basename>" (muted if no source) body rows viewer output (height-1 lines)
func (Pane) WithSize ¶
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 ¶
WithSource replaces the markdown content and resets the scroll offset to the top. Path is used purely for the title row.