Documentation
¶
Index ¶
- func HeadingSlugs(source string) map[string]bool
- func RenderImageInline(path string, protocol ImageProtocol, fsys ...afero.Fs) (string, error)
- func Slugify(s string) string
- type CodeRenderer
- func (r *CodeRenderer) CSS() (string, error)
- func (r *CodeRenderer) GetLanguage(filename string) string
- func (r *CodeRenderer) Highlight(filename, source string) (string, error)
- func (r *CodeRenderer) HighlightFile(filePath string) (string, error)
- func (r *CodeRenderer) HighlightLines(filename, source string, startLine, endLine int) (string, error)
- func (r *CodeRenderer) HighlightToWriter(w io.Writer, filename, source string) error
- func (r *CodeRenderer) ListLanguages() []string
- func (r *CodeRenderer) SetFs(fs afero.Fs)
- func (r *CodeRenderer) SetTheme(theme string)
- type Heading
- type ImageProtocol
- type Link
- type MarkdownRenderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HeadingSlugs ¶
HeadingSlugs returns a map of slug -> true for all headings in the source. Duplicate headings get GitHub-style suffixes: "heading", "heading-1", "heading-2".
func RenderImageInline ¶
RenderImageInline outputs an image using the given terminal protocol. Only safe outside alt-screen (e.g., `fur cat`), NOT inside Bubble Tea. An optional afero.Fs can be provided; if nil, the OS filesystem is used.
Types ¶
type CodeRenderer ¶
type CodeRenderer struct {
// contains filtered or unexported fields
}
CodeRenderer provides syntax highlighting via Chroma.
func NewCodeRenderer ¶
func NewCodeRenderer(theme string, terminal bool) *CodeRenderer
NewCodeRenderer creates a code renderer. Set terminal=true for TUI (terminal256) output, false for HTML output.
func (*CodeRenderer) CSS ¶
func (r *CodeRenderer) CSS() (string, error)
CSS returns the Chroma CSS classes for the current theme (HTML mode only).
func (*CodeRenderer) GetLanguage ¶
func (r *CodeRenderer) GetLanguage(filename string) string
GetLanguage detects the language for a filename. Returns an empty string if no language is detected.
func (*CodeRenderer) Highlight ¶
func (r *CodeRenderer) Highlight(filename, source string) (string, error)
Highlight returns syntax-highlighted content for the given file.
func (*CodeRenderer) HighlightFile ¶
func (r *CodeRenderer) HighlightFile(filePath string) (string, error)
HighlightFile reads a file and returns syntax-highlighted content.
func (*CodeRenderer) HighlightLines ¶
func (r *CodeRenderer) HighlightLines(filename, source string, startLine, endLine int) (string, error)
HighlightLines highlights source with a specific line range emphasized. Lines outside startLine..endLine are rendered normally; lines within the range receive Chroma's highlight style.
func (*CodeRenderer) HighlightToWriter ¶
func (r *CodeRenderer) HighlightToWriter(w io.Writer, filename, source string) error
HighlightToWriter writes syntax-highlighted content to a writer.
func (*CodeRenderer) ListLanguages ¶
func (r *CodeRenderer) ListLanguages() []string
ListLanguages returns all supported language names.
func (*CodeRenderer) SetFs ¶
func (r *CodeRenderer) SetFs(fs afero.Fs)
SetFs sets the filesystem for file operations.
func (*CodeRenderer) SetTheme ¶
func (r *CodeRenderer) SetTheme(theme string)
SetTheme changes the highlighting theme at runtime.
type Heading ¶
Heading represents a markdown heading extracted from source.
func ExtractHeadings ¶
ExtractHeadings returns all headings from markdown source.
type ImageProtocol ¶
type ImageProtocol int
ImageProtocol identifies the terminal image protocol to use.
const ( ImageProtocolNone ImageProtocol = iota ImageProtocolKitty ImageProtocolITerm2 )
func DetectImageProtocol ¶
func DetectImageProtocol() ImageProtocol
DetectImageProtocol returns the best available terminal image protocol.
type Link ¶
Link represents a markdown link extracted from source.
func ExtractLinks ¶
ExtractLinks returns all links from markdown source.
type MarkdownRenderer ¶
type MarkdownRenderer struct {
// contains filtered or unexported fields
}
MarkdownRenderer wraps Glamour for TUI markdown rendering.
func NewMarkdownRenderer ¶
func NewMarkdownRenderer(theme string, width int) (*MarkdownRenderer, error)
NewMarkdownRenderer creates a markdown renderer with the given theme and width.
func (*MarkdownRenderer) Render ¶
func (r *MarkdownRenderer) Render(source string) (string, error)
Render converts markdown to styled terminal output. On error, returns the raw source as fallback.
func (*MarkdownRenderer) RenderFile ¶
func (r *MarkdownRenderer) RenderFile(filePath string) (string, error)
RenderFile reads a file and renders its markdown content. On render error, returns the raw file content as fallback.
func (*MarkdownRenderer) SetFs ¶
func (r *MarkdownRenderer) SetFs(fs afero.Fs)
SetFs sets the filesystem for file operations.
func (*MarkdownRenderer) SetWidth ¶
func (r *MarkdownRenderer) SetWidth(width int) error
SetWidth updates the word wrap width and recreates the renderer.