Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeBlockRef ¶
type CodeBlockRef struct {
Lang string
Content string
Start int // first line of the frame, inclusive
End int // last line of the frame, inclusive
}
CodeBlockRef locates a rendered code block in the output.
Line extents are recorded during assembly rather than recovered afterwards. The previous approach matched a block's first source line against the stripped ANSI output, which silently failed whenever highlighting altered the text and gave no way to tell a miss from a block at line zero.
type Document ¶
type Document struct {
ANSI string
SectionOffsets []int
CodeBlocks []CodeBlockRef
Images []ImageRef
}
Document is a rendered markdown file plus the offsets needed to navigate it.
type ImageRef ¶
type ImageRef struct {
Alt string
Target string // absolute path, or URL for remote images
Line int // first line of the image block
Rows int // lines the block occupies
// Anchored marks an image drawn at the cursor rather than into text
// cells. iTerm2 and sixel bitmaps cannot be clipped, so the viewport has
// to suppress them unless the whole block is on screen.
Anchored bool
}
ImageRef locates a rendered image and records what it points at, so the TUI can open the underlying file and manage anchored placements.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer turns markdown sections into ANSI. It holds the palette and colour profile so they are resolved once rather than per render, and caches the glamour renderer across rebuilds at the same width.
func (*Renderer) Build ¶
func (r *Renderer) Build(sections []string, fm *mdutil.FrontMatter, paneWidth int) (*Document, error)
Build renders sections at the given pane width.
Rather than handing whole sections to glamour, each is segmented so that tables, fenced code and alerts can be rendered directly; glamour keeps the prose. Spacing is applied here, one blank line between blocks and between sections, instead of compounding a join with glamour's own block padding.
func (*Renderer) SetBaseDir ¶
SetBaseDir sets the directory relative image paths are resolved against.
func (*Renderer) SetProtocol ¶
SetProtocol overrides the detected graphics protocol. Tests use it to exercise each encoder without depending on the terminal running them.