formatting

package
v4.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Text       string                 `json:"text"`
	Color      *colors.Color          `json:"color,omitempty"`
	Decorators []decorators.Decorator `json:"decorators"`
}

Item is a single formatting item that contains a color and any optional formatting controls.

func (Item) Clean

func (i Item) Clean() string

Clean returns the text only of the formatting item.

func (Item) HTML

func (i Item) HTML() string

HTML returns the HTML representation of the format item. A <span> tag is used as well as the style and class attributes. Obfuscation is encoded as a class with the name 'minecraft-format-obfuscated'.

func (Item) IsSameAs

func (i Item) IsSameAs(j Item) bool

IsSameAs returns whether the formatting is identical to another item.

func (Item) Raw

func (i Item) Raw() (result string)

Raw returns the Minecraft encoding of the formatting (§ + formatting codes/color + text).

type Result

type Result struct {
	Tree  []Item `json:"-"`
	Raw   string `json:"raw"`
	Clean string `json:"clean"`
	HTML  string `json:"html"`
}

Result is a parsed structure of any Minecraft string encoded with color codes or format codes.

func Parse

func Parse(input interface{}) (*Result, error)

Parse parses the formatting of any string or Chat object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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