simple

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: 4 Imported by: 0

Documentation

Overview

Package simple implements a Transformer that supports basic replacement based transformations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	ReplaceMap struct {
		Bold          string
		Italic        string
		Underline     string
		Strikethrough string
		Reset         string
	} `xml:"replace_map" comment:"Replace the listed formatting codes with the given string"`

	ColourMap []struct {
		R      uint8 `toml:"red"`
		G      uint8 `toml:"green"`
		B      uint8 `toml:"blue"`
		Mapped string
	} `toml:"map_colour" comment:"maps the given RGB colour to a string"`
}

Conf Holds a replacemap and a colourmap in a format that's simple to store in XML

func (*Conf) MakeMaps

func (s *Conf) MakeMaps() (replaceMap map[rune]string, colourMap map[color.Color]string)

MakeMaps creates a replace and colour map based on the given config

type Transformer

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

Transformer is a Transformer implementation that does basic replacement based transformation. Colours are handled by way of a palette and a map to transform colours in that palette to the transformer specific format

func New

func New(replaceMap map[rune]string, colourMap map[color.Color]string) *Transformer

New constructs a Transformer from the given args. A colour palette will be automatically created from the colour map passed.

func (*Transformer) MakeIntermediate

func (s *Transformer) MakeIntermediate(in string) string

MakeIntermediate uses a simple replace operation to convert from a transformer specific implementation to the intermediate format

func (*Transformer) Transform

func (s *Transformer) Transform(in string) string

Transform implements the Transformer interface. Applies the simple conversions setup in the constructor

Jump to

Keyboard shortcuts

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