irc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package irc handles IRC text, such as its formatting codes: bold, italic, underline, strikethrough, monospace, reverse, reset, and colours in both the numbered (\x03) and hex (\x04) forms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flatten

func Flatten(text string) string

Flatten reduces text to a single clean line: formatting codes and other control characters (such as CTCP delimiters) are removed, and runs of whitespace, including newlines, become a single space with none at either end.

func StripFormatting

func StripFormatting[T string | []byte](text T) T

StripFormatting removes formatting codes from text, leaving what a client would display. Other control characters, including newlines, are kept. Text without any codes is returned as is, so a byte slice result may share its backing array with the input.

Types

type Span

type Span struct {
	Style
	Text string
}

Span is a run of text with one style.

func ParseFormatting

func ParseFormatting(text string) []Span

ParseFormatting splits text into spans at its formatting codes, leaving the codes out. Adjacent runs with the same style are merged, so text without codes is a single unstyled span. Empty text gives no spans.

type Style

type Style struct {
	Bold, Italic, Underline, Strikethrough, Monospace, Reverse bool

	Foreground, Background string
}

Style is the formatting in effect for a run of text. Colours are lowercase CSS hex colours such as "#ff0000", or empty for the client's default.

Jump to

Keyboard shortcuts

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