formatters

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoOp formatter.
	NoOp = Register("noop", zdpgo_pygments.FormatterFunc(func(w io.Writer, s *zdpgo_pygments.Style, iterator zdpgo_pygments.Iterator) error {
		for t := iterator(); t != zdpgo_pygments.EOF; t = iterator() {
			if _, err := io.WriteString(w, t.Value); err != nil {
				return err
			}
		}
		return nil
	}))

	SVG = Register("svg", svg.New(svg.EmbedFont("Liberation Mono", svg.FontLiberationMono, svg.WOFF)))
)
View Source
var Fallback = NoOp

Fallback formatter.

View Source
var JSON = Register("json", zdpgo_pygments.FormatterFunc(func(w io.Writer, s *zdpgo_pygments.Style, it zdpgo_pygments.Iterator) error {
	fmt.Fprintln(w, "[")
	i := 0
	for t := it(); t != zdpgo_pygments.EOF; t = it() {
		if i > 0 {
			fmt.Fprintln(w, ",")
		}
		i++
		bytes, err := json.Marshal(t)
		if err != nil {
			return err
		}
		if _, err := fmt.Fprint(w, "  "+string(bytes)); err != nil {
			return err
		}
	}
	fmt.Fprintln(w)
	fmt.Fprintln(w, "]")
	return nil
}))

JSON formatter outputs the raw token structures as JSON.

Registry 格式化的存储对象

View Source
var TTY = Register("terminal", &indexedTTYFormatter{ttyTables[8]})

TTY is an 8-colour terminal formatter.

The Lab colour space is used to map RGB values to the most appropriate index colour.

View Source
var TTY16 = Register("terminal16", &indexedTTYFormatter{ttyTables[16]})

TTY16 is a 16-colour terminal formatter.

It uses \033[3xm for normal colours and \033[90Xm for bright colours.

The Lab colour space is used to map RGB values to the most appropriate index colour.

View Source
var TTY16m = Register("terminal16m", zdpgo_pygments.FormatterFunc(trueColourFormatter))

TTY16m is a true-colour terminal formatter.

View Source
var TTY256 = Register("terminal256", &indexedTTYFormatter{ttyTables[256]})

TTY256 is a 256-colour terminal formatter.

The Lab colour space is used to map RGB values to the most appropriate index colour.

View Source
var TTY8 = Register("terminal8", &indexedTTYFormatter{ttyTables[8]})

TTY8 is an 8-colour terminal formatter.

The Lab colour space is used to map RGB values to the most appropriate index colour.

View Source
var Tokens = Register("tokens", zdpgo_pygments.FormatterFunc(func(w io.Writer, s *zdpgo_pygments.Style, it zdpgo_pygments.Iterator) error {
	for t := it(); t != zdpgo_pygments.EOF; t = it() {
		if _, err := fmt.Fprintln(w, t.GoString()); err != nil {
			return err
		}
	}
	return nil
}))

Tokens formatter outputs the raw token structures.

Functions

func Get

Get 根据名字获取格式化对象

func Names

func Names() []string

Names 获取所有的格式化名称

func Register

func Register(name string, formatter zdpgo_pygments.Formatter) zdpgo_pygments.Formatter

Register 注册一个格式化对象

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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