package internal

import "github.com/alecthomas/chroma/lexers/internal"

Index

Variables

var Fallback chroma.Lexer = chroma.MustNewLexer(&chroma.Config{
	Name:      "fallback",
	Filenames: []string{"*"},
}, PlaintextRules)

Fallback lexer if no other is found.

var PlaintextRules = chroma.Rules{
	"root": []chroma.Rule{
		{`.+`, chroma.Text, nil},
		{`\n`, chroma.Text, nil},
	},
}

Used for the fallback lexer as well as the explicit plaintext lexer

var Registry = struct {
	Lexers  chroma.Lexers
	byName  map[string]chroma.Lexer
	byAlias map[string]chroma.Lexer
}{
	// contains filtered or unexported fields
}

Registry of Lexers.

Functions

func Analyse

func Analyse(text string) chroma.Lexer

Analyse text content and return the "best" lexer..

func Get

func Get(name string) chroma.Lexer

Get a Lexer by name, alias or file extension.

func Match

func Match(filename string) chroma.Lexer

Match returns the first lexer matching filename.

func MatchMimeType

func MatchMimeType(mimeType string) chroma.Lexer

MatchMimeType attempts to find a lexer for the given MIME type.

func Names

func Names(withAliases bool) []string

Names of all lexers, optionally including aliases.

func Register

func Register(lexer chroma.Lexer) chroma.Lexer

Register a Lexer with the global registry.

Source Files

api.go

Version
v0.6.4
Published
Jun 17, 2019
Platform
js/wasm
Imports
5 packages
Last checked
3 minutes ago

Tools for package owners.