Versions in this module Expand all Collapse all v1 v1.0.0 Aug 19, 2022 v0 v0.1.8 Aug 5, 2022 v0.1.7 Aug 4, 2022 v0.1.6 Aug 4, 2022 v0.1.5 Aug 4, 2022 v0.1.4 Aug 4, 2022 v0.1.3 Aug 4, 2022 Changes in this version + func GetSpreadTokenArr(tokens []string, lines int) []string + func GetTokenArr(lexer Lexer, contents []string) ([]string, error) v0.1.2 Aug 3, 2022 v0.1.1 Aug 2, 2022 v0.1.0 Aug 2, 2022 Changes in this version + const Date + const Number + const NumberBin + const NumberFloat + const NumberHex + const NumberInteger + const NumberIntegerLong + const NumberOct + const String + const StringAffix + const StringBacktick + const StringChar + const StringDelimiter + const StringDoc + const StringDouble + const StringEscape + const StringHeredoc + const StringInterpol + const StringOther + const StringRegex + const StringSingle + const StringSymbol + const Whitespace + var ANSI2RGB = map[string]string + var StandardTypes = map[TokenType]string + func GetToken(lexer Lexer, content string) (string, error) + func SplitTokensIntoLines(tokens []Token) (out [][]Token) + func Stringify(tokens ...Token) string + func Words(prefix, suffix string, words ...string) string + type Analyser interface + AnalyseText func(text string) float32 + type Colour int32 + func MustParseColour(colour string) Colour + func NewColour(r, g, b uint8) Colour + func ParseColour(colour string) Colour + func (c Colour) Blue() uint8 + func (c Colour) Brighten(factor float64) Colour + func (c Colour) BrightenOrDarken(factor float64) Colour + func (c Colour) Brightness() float64 + func (c Colour) Distance(e2 Colour) float64 + func (c Colour) GoString() string + func (c Colour) Green() uint8 + func (c Colour) IsSet() bool + func (c Colour) Red() uint8 + func (c Colour) String() string + type Colours []Colour + func (c Colours) Len() int + func (c Colours) Less(i, j int) bool + func (c Colours) Swap(i, j int) + type CompiledRule struct + Regexp *regexp2.Regexp + type CompiledRules map[string][]*CompiledRule + type Config struct + AliasFilenames []string + Aliases []string + CaseInsensitive bool + DotAll bool + EnsureNL bool + Filenames []string + MimeTypes []string + Name string + NotMultiline bool + Priority float32 + type Emitter interface + Emit func(groups []string, state *LexerState) Iterator + func ByGroupNames(emitters map[string]Emitter) Emitter + func ByGroups(emitters ...Emitter) Emitter + func Using(lexer Lexer) Emitter + func UsingByGroup(sublexerGetFunc func(string) Lexer, sublexerNameGroup, codeGroup int, ...) Emitter + func UsingSelf(stateName string) Emitter + type EmitterFunc func(groups []string, state *LexerState) Iterator + func (e EmitterFunc) Emit(groups []string, state *LexerState) Iterator + type Formatter interface + Format func(w io.Writer, style *Style, iterator Iterator) error + func RecoveringFormatter(formatter Formatter) Formatter + type FormatterFunc func(w io.Writer, style *Style, iterator Iterator) error + func (f FormatterFunc) Format(w io.Writer, s *Style, it Iterator) (err error) + type Iterator func() Token + func Concaterator(iterators ...Iterator) Iterator + func Literator(tokens ...Token) Iterator + func (i Iterator) Tokens() []Token + type Lexer interface + Config func() *Config + Tokenise func(options *TokeniseOptions, text string) (Iterator, error) + func Coalesce(lexer Lexer) Lexer + func DelegatingLexer(root Lexer, language Lexer) Lexer + func RemappingLexer(lexer Lexer, mapper func(Token) []Token) Lexer + func TypeRemappingLexer(lexer Lexer, mapping TypeMapping) Lexer + type LexerMutator interface + MutateLexer func(rules CompiledRules, state string, rule int) error + type LexerState struct + Groups []string + Lexer *RegexLexer + MutatorContext map[interface{}]interface{} + NamedGroups map[string]string + Pos int + Rule int + Rules CompiledRules + Stack []string + State string + Text []rune + func (l *LexerState) Get(key interface{}) interface{} + func (l *LexerState) Iterator() Token + func (l *LexerState) Set(key interface{}, value interface{}) + type Lexers []Lexer + func (l Lexers) Len() int + func (l Lexers) Less(i, j int) bool + func (l Lexers) Swap(i, j int) + type Mutator interface + Mutate func(state *LexerState) error + func Combined(states ...string) Mutator + type MutatorFunc func(state *LexerState) error + func Mutators(modifiers ...Mutator) MutatorFunc + func Pop(n int) MutatorFunc + func Push(states ...string) MutatorFunc + func (m MutatorFunc) Mutate(state *LexerState) error + type PrioritisedLexers []Lexer + func (l PrioritisedLexers) Len() int + func (l PrioritisedLexers) Less(i, j int) bool + func (l PrioritisedLexers) Swap(i, j int) + type RegexLexer struct + func MustNewLazyLexer(config *Config, rulesFunc func() Rules) *RegexLexer + func MustNewLexer(config *Config, rules Rules) *RegexLexer + func NewLazyLexer(config *Config, rulesFunc func() Rules) (*RegexLexer, error) + func NewLexer(config *Config, rules Rules) (*RegexLexer, error) + func (r *RegexLexer) AnalyseText(text string) float32 + func (r *RegexLexer) Config() *Config + func (r *RegexLexer) SetAnalyser(analyser func(text string) float32) *RegexLexer + func (r *RegexLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) + func (r *RegexLexer) Trace(trace bool) *RegexLexer + type Rule struct + Mutator Mutator + Pattern string + Type Emitter + func Default(mutators ...Mutator) Rule + func Include(state string) Rule + type Rules map[string][]Rule + func (r Rules) Clone() Rules + func (r Rules) Merge(rules Rules) Rules + func (r Rules) Rename(oldRule, newRule string) Rules + type Style struct + Name string + func MustNewStyle(name string, entries StyleEntries) *Style + func NewStyle(name string, entries StyleEntries) (*Style, error) + func (s *Style) Builder() *StyleBuilder + func (s *Style) Get(ttype TokenType) StyleEntry + func (s *Style) Has(ttype TokenType) bool + func (s *Style) Types() []TokenType + type StyleBuilder struct + func NewStyleBuilder(name string) *StyleBuilder + func (s *StyleBuilder) Add(ttype TokenType, entry string) *StyleBuilder + func (s *StyleBuilder) AddAll(entries StyleEntries) *StyleBuilder + func (s *StyleBuilder) AddEntry(ttype TokenType, entry StyleEntry) *StyleBuilder + func (s *StyleBuilder) Build() (*Style, error) + func (s *StyleBuilder) Get(ttype TokenType) StyleEntry + type StyleEntries map[TokenType]string + type StyleEntry struct + Background Colour + Bold Trilean + Border Colour + Colour Colour + Italic Trilean + NoInherit bool + Underline Trilean + func ParseStyleEntry(entry string) (StyleEntry, error) + func (s StyleEntry) Inherit(ancestors ...StyleEntry) StyleEntry + func (s StyleEntry) IsZero() bool + func (s StyleEntry) String() string + func (s StyleEntry) Sub(e StyleEntry) StyleEntry + type Token struct + Type TokenType + Value string + var EOF Token + func Tokenise(lexer Lexer, options *TokeniseOptions, text string) ([]Token, error) + func (t *Token) Clone() Token + func (t *Token) GoString() string + func (t *Token) String() string + type TokenType int + const Background + const CodeLine + const Comment + const CommentHashbang + const CommentMultiline + const CommentPreproc + const CommentPreprocFile + const CommentSingle + const CommentSpecial + const EOFType + const Error + const Generic + const GenericDeleted + const GenericEmph + const GenericError + const GenericHeading + const GenericInserted + const GenericOutput + const GenericPrompt + const GenericStrong + const GenericSubheading + const GenericTraceback + const GenericUnderline + const Keyword + const KeywordConstant + const KeywordDeclaration + const KeywordNamespace + const KeywordPseudo + const KeywordReserved + const KeywordType + const Line + const LineHighlight + const LineNumbers + const LineNumbersTable + const LineTable + const LineTableTD + const Literal + const LiteralDate + const LiteralNumber + const LiteralNumberBin + const LiteralNumberFloat + const LiteralNumberHex + const LiteralNumberInteger + const LiteralNumberIntegerLong + const LiteralNumberOct + const LiteralOther + const LiteralString + const LiteralStringAffix + const LiteralStringAtom + const LiteralStringBacktick + const LiteralStringBoolean + const LiteralStringChar + const LiteralStringDelimiter + const LiteralStringDoc + const LiteralStringDouble + const LiteralStringEscape + const LiteralStringHeredoc + const LiteralStringInterpol + const LiteralStringName + const LiteralStringOther + const LiteralStringRegex + const LiteralStringSingle + const LiteralStringSymbol + const Name + const NameAttribute + const NameBuiltin + const NameBuiltinPseudo + const NameClass + const NameConstant + const NameDecorator + const NameEntity + const NameException + const NameFunction + const NameFunctionMagic + const NameKeyword + const NameLabel + const NameNamespace + const NameOperator + const NameOther + const NameProperty + const NamePseudo + const NameTag + const NameVariable + const NameVariableAnonymous + const NameVariableClass + const NameVariableGlobal + const NameVariableInstance + const NameVariableMagic + const None + const Operator + const OperatorWord + const Other + const PreWrapper + const Punctuation + const Text + const TextPunctuation + const TextSymbol + const TextWhitespace + func (i TokenType) String() string + func (t *TokenType) UnmarshalJSON(data []byte) error + func (t TokenType) Category() TokenType + func (t TokenType) Emit(groups []string, _ *LexerState) Iterator + func (t TokenType) InCategory(other TokenType) bool + func (t TokenType) InSubCategory(other TokenType) bool + func (t TokenType) MarshalJSON() ([]byte, error) + func (t TokenType) Parent() TokenType + func (t TokenType) SubCategory() TokenType + type TokeniseOptions struct + EnsureLF bool + Nested bool + State string + type Trilean uint8 + const No + const Pass + const Yes + func (t Trilean) Prefix(s string) string + func (t Trilean) String() string + type TypeMapping []struct