transformer

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package transformer implements a platform agnostic way of converting between platform specific formatting styles

In order to do this, an intermediate format is used internally and by all implementations of Transformer The format is defined as follows

Formatters are first indicated with a sentinel, '$', after which a single character for type follows The only defined types are:

b	Bold
i	Italics
u	Underline
s	Strikethrough
r	Reset
$	Escaped Sentinel
c Colour

Colour has a special definition, instead of simply $c, the sentinel and type is followed by six hex characters that together indicate a colour. It is expected that converters with a smaller colour space automatically condense any unsupported colours into something within their colour space.

Unintended uses of the sentinel must be escaped by using two sentinels in a row.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transformer

type Transformer interface {
	// Transform takes a string in the intermediate format and converts it to its specific format.
	// When the implementation of Transformer does not support a given format type, it can either eat it entirely, or
	// use a pure ascii notation to indicate that it was there. For example: strike though could be replaced with ~~
	Transform(in string) string
	// MakeIntermediate takes a string in a Transformer specific format and converts it to the Intermediate format.
	// Any existing sentinels in the string SHOULD be escaped
	MakeIntermediate(in string) string
}

Transformer refers to a string transformer. String Transformers convert messages from an intermediate format to a protocol specific format

func GetTransformer

func GetTransformer(conf *tomlconf.ConfigHolder) (Transformer, error)

GetTransformer Instantiates a Transformer implementation given a config

Directories

Path Synopsis
Package minecraft contains a Transformer implementation for the JSON specification of minecraft format strings see https://minecraft.gamepedia.com/Raw_JSON_text_format for a full look at the format itself
Package minecraft contains a Transformer implementation for the JSON specification of minecraft format strings see https://minecraft.gamepedia.com/Raw_JSON_text_format for a full look at the format itself
Package simple implements a Transformer that supports basic replacement based transformations
Package simple implements a Transformer that supports basic replacement based transformations
Package tokeniser implements a tokeniser for the format/transformer intermediate language
Package tokeniser implements a tokeniser for the format/transformer intermediate language

Jump to

Keyboard shortcuts

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