Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ANSIConverter ¶
type ANSIConverter struct {
// contains filtered or unexported fields
}
ANSIConverter converts ANSI escape sequences to HTML.
func NewANSIConverter ¶
func NewANSIConverter() *ANSIConverter
NewANSIConverter creates a new ANSI to HTML converter
func (*ANSIConverter) ConvertToHTML ¶
func (c *ANSIConverter) ConvertToHTML(input string) (string, error)
ConvertToHTML converts ANSI-formatted text to HTML
func (*ANSIConverter) ConvertToPlainText ¶
func (c *ANSIConverter) ConvertToPlainText(input string) string
ConvertToPlainText removes ANSI escape sequences and returns plain text
type ANSIParser ¶
type ANSIParser struct {
// contains filtered or unexported fields
}
ANSIParser parses ANSI escape sequences from text.
func (*ANSIParser) Parse ¶
func (p *ANSIParser) Parse(input string) ([]ANSIToken, error)
Parse parses the input string and returns a slice of ANSI tokens
func (*ANSIParser) ParseSimple ¶
func (p *ANSIParser) ParseSimple(input string) string
ParseSimple is a helper method that parses input and returns just the text content with escape sequences removed. Useful for extracting plain text.
type ANSIState ¶
type ANSIState struct {
Bold bool
Italic bool
Underline bool
StrikeThrough bool
FgColor string
BgColor string
}
ANSIState tracks the current ANSI formatting state.
func NewANSIState ¶
func NewANSIState() *ANSIState
NewANSIState creates a new ANSI state with default values
func (*ANSIState) ApplyCodes ¶
func (s *ANSIState) ApplyCodes(codes []int, colorMapper *ColorMapper)
ApplyCodes applies ANSI codes to update the current state
func (*ANSIState) GetClasses ¶
GetClasses returns CSS classes based on the current state
func (*ANSIState) HasFormatting ¶
HasFormatting returns true if the state has any formatting applied
type ColorMapper ¶
type ColorMapper struct {
// contains filtered or unexported fields
}
ColorMapper maps ANSI color codes to CSS colors.
func NewColorMapper ¶
func NewColorMapper() *ColorMapper
NewColorMapper creates a new color mapper with standard ANSI colors
func (*ColorMapper) Get256Color ¶
func (m *ColorMapper) Get256Color(index int) string
Get256Color returns the CSS color for a 256-color palette index
func (*ColorMapper) GetBackgroundColor ¶
func (m *ColorMapper) GetBackgroundColor(code int) (string, bool)
GetBackgroundColor returns the CSS color for a background ANSI code
func (*ColorMapper) GetForegroundColor ¶
func (m *ColorMapper) GetForegroundColor(code int) (string, bool)
GetForegroundColor returns the CSS color for a foreground ANSI code
func (*ColorMapper) GetRGBColor ¶
func (m *ColorMapper) GetRGBColor(r, g, b int) string
GetRGBColor returns the CSS color for RGB values