synlight

package
v0.7.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: ISC Imports: 7 Imported by: 0

Documentation

Overview

something like pygments in go written before I discovered https://github.com/alecthomas/chroma

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lighter

type Lighter struct {
	// contains filtered or unexported fields
}

A syntax highlighter

func New

func New(options Options) *Lighter

Create a new highlighter. It should be reused if possible.

func (*Lighter) AddLexer

func (hl *Lighter) AddLexer(lang string, r io.Reader)

Add a new lexer to this highlighter.

func (*Lighter) Highlight

func (hl *Lighter) Highlight(data []byte, filename string, w io.Writer)

Highlight code, writing it to w.

func (*Lighter) HighlightString

func (hl *Lighter) HighlightString(data string, filename string) string

Highlight code, returning a string

type Options

type Options struct {
	Format OutputFormat
}

Options for creating a new highlighter. HTML or TTY output are supported.

type OutputFormat

type OutputFormat int
const (
	None OutputFormat = iota
	HTML
	TTY
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL