Documentation
¶
Index ¶
- func StripDataURIText(s string) string
- func StripDataURIs(doc ast.Node, source []byte)
- type DocumentTransformer
- type GoBackMsg
- type KeyMap
- type Model
- func (m *Model) AtBottom() bool
- func (m *Model) AtTop() bool
- func (m *Model) Clear()
- func (m *Model) ClearStatusMessage()
- func (m *Model) ColumnOffset() int
- func (m *Model) ContentWidth() int
- func (m *Model) CursorMode() bool
- func (m *Model) DecreaseContentWidth()
- func (m *Model) EffectiveWidth() int
- func (m *Model) FocusedLinkDestination() string
- func (m *Model) FollowLink() bool
- func (m *Model) GetMarkdown() []byte
- func (m *Model) GetName() string
- func (m *Model) GoBack() bool
- func (m *Model) GotoBottom()
- func (m *Model) GotoTop()
- func (m *Model) Height() int
- func (m *Model) IncreaseContentWidth()
- func (m Model) Init() tea.Cmd
- func (m *Model) LineOffset() int
- func (m *Model) PageDown()
- func (m *Model) PageUp()
- func (m *Model) ScrollDown(n int)
- func (m *Model) ScrollLeft(n int)
- func (m *Model) ScrollPercent() float64
- func (m *Model) ScrollRight(n int)
- func (m *Model) ScrollUp(n int)
- func (m *Model) Searching() bool
- func (m *Model) SelectAnchor(anchor string) bool
- func (m *Model) SelectFirstVisible(selector Selector) bool
- func (m *Model) SelectLastVisible(selector Selector) bool
- func (m *Model) SelectNext(selector Selector) bool
- func (m *Model) SelectPrevious(selector Selector) bool
- func (m *Model) SelectSpan(span *renderer.NodeSpan, highlight bool)
- func (m *Model) Selection() *renderer.NodeSpan
- func (m *Model) SetColumnOffset(n int)
- func (m *Model) SetContentWidth(width int)
- func (m *Model) SetGutter(showGutter bool)
- func (m *Model) SetHeight(height int)
- func (m *Model) SetLineOffset(n int)
- func (m *Model) SetSize(width, height int)
- func (m *Model) SetStatusMessage(msg string)
- func (m *Model) SetText(name, markdown string)
- func (m *Model) SetWidth(width int)
- func (m *Model) SetWrap(wrap bool)
- func (m *Model) TotalLineCount() int
- func (m Model) Update(msg tea.Msg) (Model, tea.Cmd)
- func (m Model) View() string
- func (m *Model) VisibleLineCount() int
- func (m *Model) VisualMode() bool
- func (m *Model) Width() int
- type OpenLinkMsg
- type Option
- func WithContentWidth(width int) Option
- func WithDiagramRenderer(dr renderer.DiagramRenderer) Option
- func WithDocumentTransformer(t DocumentTransformer) Option
- func WithGutter(showGutter bool) Option
- func WithHeight(height int) Option
- func WithKeyMap(keyMap KeyMap) Option
- func WithTheme(theme *chroma.Style) Option
- func WithWidth(width int) Option
- func WithWrap(wrap bool) Option
- type Selector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StripDataURIText ¶
StripDataURIText replaces data URIs in raw markdown text with a placeholder. This is used to reduce the size of bug reports that contain large base64-encoded images.
func StripDataURIs ¶
StripDataURIs is a DocumentTransformer that removes nodes containing data: URIs. It handles RawHTML nodes (e.g. <img src="data:...">), Image and Link nodes with data: destinations, and LinkReferenceDefinition nodes with data: destinations.
Types ¶
type DocumentTransformer ¶
DocumentTransformer is a function that transforms a parsed Markdown AST before rendering. It can be used to remove or modify nodes in the document.
type GoBackMsg ¶
type GoBackMsg struct{}
GoBackMsg is sent when the user presses the back key and the internal backstack is empty. Embedders should handle this message to navigate to the previous page.
type KeyMap ¶
type KeyMap struct {
Up key.Binding
Down key.Binding
PageUp key.Binding
PageDown key.Binding
GotoTop key.Binding
GotoEnd key.Binding
Home key.Binding
End key.Binding
Left key.Binding
Right key.Binding
NextLink key.Binding
PrevLink key.Binding
NextCodeBlock key.Binding
PrevCodeBlock key.Binding
NextHeading key.Binding
PrevHeading key.Binding
DecreaseWidth key.Binding
IncreaseWidth key.Binding
FollowLink key.Binding
GoBack key.Binding
CopySelection key.Binding
CursorMode key.Binding
VisualMode key.Binding
WordForward key.Binding
WordBack key.Binding
WordEnd key.Binding
LineStart key.Binding
LineEnd key.Binding
Search key.Binding
NextMatch key.Binding
PrevMatch key.Binding
ClearSearch key.Binding
}
KeyMap defines key bindings for the Model. Each field is a key.Binding that can be customized or disabled. Use SetEnabled to bulk-enable/disable all bindings for focus management.
func DefaultKeyMap ¶
func DefaultKeyMap() KeyMap
DefaultKeyMap returns a KeyMap with the default key bindings matching the original hardcoded keys. DecreaseWidth and IncreaseWidth are disabled by default since they are unusual for an embedded component.
func (KeyMap) FullHelp ¶
FullHelp returns the full set of key bindings for the help view. Implements the help.KeyMap interface from charmbracelet/bubbles/help.
func (*KeyMap) SetEnabled ¶
SetEnabled bulk-enables or disables all bindings in the KeyMap. This is the primary mechanism for focus management: disable the KeyMap when the Model does not have focus, re-enable when it regains focus.
type Model ¶
type Model struct {
// KeyMap defines the key bindings for this model. Customize individual
// bindings or call KeyMap.SetEnabled(false) to disable all input.
KeyMap KeyMap
// contains filtered or unexported fields
}
Model is a bubbletea model that displays rendered Markdown content.
func (*Model) Clear ¶
func (m *Model) Clear()
Clear removes all text from the buffer and resets all document-dependent state including selections, the navigation backstack, and the span tree.
func (*Model) ClearStatusMessage ¶
func (m *Model) ClearStatusMessage()
ClearStatusMessage clears the transient gutter status message.
func (*Model) ColumnOffset ¶
ColumnOffset returns the current horizontal scroll offset.
func (*Model) ContentWidth ¶
ContentWidth returns the current content width setting. 0 means full viewport width.
func (*Model) CursorMode ¶
CursorMode reports whether cursor positioning mode is active.
func (*Model) DecreaseContentWidth ¶
func (m *Model) DecreaseContentWidth()
DecreaseContentWidth reduces the content width by 10 columns (minimum 40).
func (*Model) EffectiveWidth ¶
EffectiveWidth returns the computed effective width used for rendering.
func (*Model) FocusedLinkDestination ¶
FocusedLinkDestination returns the URL of the currently selected link, or "" if the selection is not a link.
func (*Model) FollowLink ¶
FollowLink follows the currently selected internal anchor link. Returns true if navigation occurred (the link was an internal anchor).
func (*Model) GetMarkdown ¶
GetMarkdown returns the raw markdown bytes.
func (*Model) GoBack ¶
GoBack returns to the previous selection from the backstack. Returns true if there was a previous selection to return to.
func (*Model) GotoBottom ¶
func (m *Model) GotoBottom()
GotoBottom scrolls to the bottom of the document and resets horizontal scroll.
func (*Model) GotoTop ¶
func (m *Model) GotoTop()
GotoTop scrolls to the top of the document and resets horizontal scroll.
func (*Model) IncreaseContentWidth ¶
func (m *Model) IncreaseContentWidth()
IncreaseContentWidth increases the content width by 10 columns. If the result would be within 10 of the viewport width, resets to 0 (full width).
func (*Model) LineOffset ¶
LineOffset returns the current vertical scroll offset (first visible line index).
func (*Model) ScrollPercent ¶
ScrollPercent returns the scroll position as a value between 0.0 and 1.0.
func (*Model) ScrollRight ¶
ScrollRight scrolls right by n columns.
func (*Model) SelectAnchor ¶
SelectAnchor selects the next node with the given anchor. For anchors defined by HTML anchor tags (<a id="...">), this navigates to the anchor node itself. For heading-derived anchors, it navigates to the heading.
func (*Model) SelectFirstVisible ¶
SelectFirstVisible selects the first node within the viewport that matches the given selector.
func (*Model) SelectLastVisible ¶
SelectLastVisible selects the last node within the viewport that matches the given selector.
func (*Model) SelectNext ¶
SelectNext selects the first node after the current selection that matches the given selector.
func (*Model) SelectPrevious ¶
SelectPrevious selects the first node before the current selection that matches the given selector.
func (*Model) SelectSpan ¶
SelectSpan selects the given node span.
func (*Model) SetColumnOffset ¶
SetColumnOffset sets the horizontal scroll offset.
func (*Model) SetContentWidth ¶
SetContentWidth sets the desired content width. 0 means use full viewport width.
func (*Model) SetGutter ¶
SetGutter sets whether to show the gutter with document name and position.
func (*Model) SetLineOffset ¶
SetLineOffset sets the vertical scroll offset.
func (*Model) SetStatusMessage ¶
SetStatusMessage sets a transient status message to display in the gutter.
func (*Model) SetText ¶
SetText sets the text of this view. Previously contained text will be removed. If name is empty, the name is inferred from the first heading in the document.
func (*Model) TotalLineCount ¶
TotalLineCount returns the total number of rendered lines.
func (*Model) VisibleLineCount ¶
VisibleLineCount returns the number of lines visible in the viewport.
func (*Model) VisualMode ¶
VisualMode reports whether visual selection mode is active.
type OpenLinkMsg ¶
type OpenLinkMsg struct {
URL string
}
OpenLinkMsg is sent when the user activates a link that is not an internal document anchor. Embedders should handle this message to open the link in a browser or otherwise.
type Option ¶
type Option func(*Model)
Option configures a Model during construction.
func WithContentWidth ¶
WithContentWidth sets the desired content width. 0 means use full viewport width.
func WithDiagramRenderer ¶
func WithDiagramRenderer(dr renderer.DiagramRenderer) Option
WithDiagramRenderer sets the diagram renderer used to convert diagram code blocks (e.g. mermaid) into rendered text.
func WithDocumentTransformer ¶
func WithDocumentTransformer(t DocumentTransformer) Option
WithDocumentTransformer adds a document transformer that will be applied to the parsed AST before rendering.
func WithGutter ¶
WithGutter sets whether to show the gutter with document name and position.
func WithKeyMap ¶
WithKeyMap sets the key bindings for the model.