package lexers

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

Package lexers contains the registry of all lexers.

Sub-packages contain lexer implementations.

Index

Variables

var Fallback = internal.Fallback

Fallback lexer if no other is found.

var HLB = internal.Register(MustNewLexer(
	&Config{
		Name:      "HLB",
		Aliases:   []string{"hlb"},
		Filenames: []string{"*.hlb"},
		MimeTypes: []string{},
	},
	Rules{
		"root": {
			{`(#.*)`, ByGroups(CommentSingle), nil},
			{`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
			{`((\b(true|false)\b))`, ByGroups(NameBuiltin), nil},
			{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
			{`(\b[a-zA-Z_][a-zA-Z0-9]*\b)(\()`, ByGroups(NameFunction, Punctuation), Push("params")},
			{`(\{)`, ByGroups(Punctuation), Push("block")},
			{`(\n|\r|\r\n)`, Text, nil},
			{`.`, Text, nil},
		},
		"string": {
			{`"`, LiteralString, Pop(1)},
			{`\\"`, LiteralString, nil},
			{`[^\\"]+`, LiteralString, nil},
		},
		"block": {
			{`(\})`, ByGroups(Punctuation), Pop(1)},
			{`(#.*)`, ByGroups(CommentSingle), nil},
			{`((\b(0(b|B|o|O|x|X)[a-fA-F0-9]+)\b)|(\b(0|[1-9][0-9]*)\b))`, ByGroups(LiteralNumber), nil},
			{`((\b(true|false)\b))`, ByGroups(KeywordConstant), nil},
			{`"`, LiteralString, Push("string")},
			{`(with)`, ByGroups(KeywordReserved), nil},
			{`(as)([\t ]+)(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(KeywordReserved, Text, NameFunction), nil},
			{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)([\t ]+)(\{)`, ByGroups(KeywordType, Text, Punctuation), Push("block")},
			{"" /* 450 byte string literal not displayed */, ByGroups(NameOther), nil},
			{`(\n|\r|\r\n)`, Text, nil},
			{`.`, Text, nil},
		},
		"params": {
			{`(\))`, ByGroups(Punctuation), Pop(1)},
			{`(variadic)`, ByGroups(Keyword), nil},
			{`(\bstring\b|\bint\b|\bbool\b|\bfs\b|\boption\b)`, ByGroups(KeywordType), nil},
			{`(\b[a-zA-Z_][a-zA-Z0-9]*\b)`, ByGroups(NameOther), nil},
			{`(\n|\r|\r\n)`, Text, nil},
			{`.`, Text, nil},
		},
	},
))

HLB lexer.

var Registry = internal.Registry

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

hlb.go lexers.go

Directories

PathSynopsis
lexers/a
lexers/b
lexers/c
lexers/circularPackage circular exists to break circular dependencies between lexers.
lexers/d
lexers/e
lexers/f
lexers/g
lexers/h
lexers/i
lexers/internalPackage internal contains common API functions and structures shared between lexer packages.
lexers/j
lexers/k
lexers/l
lexers/m
lexers/n
lexers/o
lexers/p
lexers/q
lexers/r
lexers/s
lexers/t
lexers/v
lexers/w
lexers/x
lexers/y
Version
v0.7.2
Published
Apr 12, 2020
Platform
js/wasm
Imports
27 packages
Last checked
1 hour ago

Tools for package owners.