Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddLanguage ¶
AddLanguage adds support for a new language. The 'loader' should return the highlighting grammar when called.
Types ¶
type Highlighter ¶
type Highlighter struct {
// contains filtered or unexported fields
}
A Highlighter corresponds to a compiled GPeg program and a mapping from captures to highlight groups. It can be used to generate highlight results from a io.ReaderAt.
func LoadHighlighter ¶
func LoadHighlighter(lang string, data []byte, memo bool) (*Highlighter, error)
LoadHighlighter loads a highlighter from some data.
func LoadHighlighterBuiltin ¶
func LoadHighlighterBuiltin(name string, memo bool) (*Highlighter, error)
LoadHighlighterBuiltin compiles and loads the given highlighter. Use 'memo' if the highlighter will be used in an incremental setting (editor).
func (*Highlighter) HighlightFunc ¶
func (h *Highlighter) HighlightFunc(r io.ReaderAt, tbl memo.Table, draw func(text []byte, group string), i *vm.Interval)
HighlightFunc is similar to HighlightMatches but calls a function for each match instead of storing it in a table.
func (*Highlighter) HighlightMatches ¶
HighlightMatches performs syntax highlighting on the given ReaderAt with a possibly pre-filled memoization table, over a specified interval. It generates a Matches structure that can be queried for the highlight results. If the specified interval is nil, the full file is used.
NOTE: if using an interval, make sure it is as small as possible. Using nil and the full file range are not equivalent. Parse time is proportional to the size of the window, unless nil is used. However, if nil is used memory usage may be high if the input is large because the full parse tree is returned.
type Matches ¶
type Matches struct {
// contains filtered or unexported fields
}
Matches is a structure that stores highlighting results corresponding to a certain range of the document. It supports querying the highlight group of any index within the range.