Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GoLexer = &chromaLexer{l: chroma.Coalesce(lexers.Go)}
GoLexer is a Lexer that recognizes Go.
var PlainStyle = chroma.MustNewStyle("plain", map[chroma.TokenType]string{
chroma.Comment: "#666666",
chroma.PreWrapper: "bg:#eeeeee",
chroma.Background: "bg:#eeeeee",
})
PlainStyle is a minimal syntax highlighting style for Chroma. It leaves most text as-is, and fades comments ever so slightly.
Functions ¶
This section is empty.
Types ¶
type AnchorSpan ¶
AnchorSpan renders as an addressable anchor point.
type Code ¶
type Code struct {
Spans []Span
}
Code is a code block comprised of multiple text nodes.
type ErrorSpan ¶
ErrorSpan is a special span that represents a failure operation.
This renders in HTML in a visible way to avoid failing silently.
type Highlighter ¶
type Highlighter struct { // Style used for syntax highlighting of code. Style *chroma.Style // UseClasses specifies whether the highlighter // uses inline 'style' attributes for highlighting, // or classes, assumign use of an appropriate style sheet. UseClasses bool // contains filtered or unexported fields }
Highlighter turns Code into HTML.
func (*Highlighter) Highlight ¶
func (h *Highlighter) Highlight(code *Code) string
Highlight renders the given code block into HTML.
type Span ¶
type Span interface {
// contains filtered or unexported methods
}
Span is a part of a code block.
type TokenIndex ¶
type TokenIndex struct {
// contains filtered or unexported fields
}
TokenIndex is a searchable collection of tokens.
func NewTokenIndex ¶
func NewTokenIndex(src []byte, tokens []chroma.Token) *TokenIndex
NewTokenIndex builds a token index given source code and its tokens.
func (*TokenIndex) Interval ¶
func (ts *TokenIndex) Interval(start, end int) (tokens []chroma.Token, lead, trail []byte)
Interval returns a list of tokens that are in the range [start, end). If the token boundaries aren't exactly matching, intervals also returns the leading and trailing text, if any.