Documentation
¶
Index ¶
- Variables
- type Highlighter
- func (h *Highlighter) CSS() (string, error)
- func (h *Highlighter) HighlightLine(line int) (string, error)
- func (h *Highlighter) HighlightLines(start, end int) ([]string, error)
- func (h *Highlighter) HighlightReplacedSubstr(replacement string, line, start, end int, context bool) (string, error)
- func (h *Highlighter) HighlightSubstr(line, start, end int, context bool) (string, error)
- func (h *Highlighter) Lang() string
- func (h *Highlighter) Style() *chroma.Style
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoLexer = errors.New("no lexer for supplied language")
)
Functions ¶
This section is empty.
Types ¶
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
Highlighter is a wrapper for the chroma library that allows for line by line and substring highlighting.
func NewHighlighter ¶
NewHighlighter returns a newly configured instance of Highlighter.
func (*Highlighter) CSS ¶
func (h *Highlighter) CSS() (string, error)
CSS returns the formatted CSS classes for the chroma highlighting without being wrapped in <style> tags.
func (*Highlighter) HighlightLine ¶
func (h *Highlighter) HighlightLine(line int) (string, error)
HighlightLine highlights the specified line number from the sources lines that were provided to the Highlighter instance.
func (*Highlighter) HighlightLines ¶
func (h *Highlighter) HighlightLines(start, end int) ([]string, error)
HighlightLines calls HighlightLine over a range of lines and returns a list of the results.
func (*Highlighter) HighlightReplacedSubstr ¶
func (h *Highlighter) HighlightReplacedSubstr(replacement string, line, start, end int, context bool) (string, error)
HighlightReplacedSubstr replaces the specified substring in the line with the newly provided string. It then highlights and returns the specified substring of a given line. If the context value is set to true, the Highlighter will highlight the whole line and then identify and return the specified substring HTML elements.
func (*Highlighter) HighlightSubstr ¶
func (h *Highlighter) HighlightSubstr(line, start, end int, context bool) (string, error)
HighlightSubstr highlights and returns the specified substring of a given line. If the context value is set to true, the Highlighter will highlight the whole line and then identify and return the specified substring HTML elements.
func (*Highlighter) Lang ¶
func (h *Highlighter) Lang() string
Lang returns the highlighters language
func (*Highlighter) Style ¶
func (h *Highlighter) Style() *chroma.Style
Style returns the highlighters chroma style