Ircxd.Formatting (ircxd v1.1.0)

Copy Markdown View Source

Parser helpers for common IRC formatting control codes.

The parser returns text spans with compact style maps. Rendering is left to the host application.

Summary

Types

A text segment with one style.

IRC text style properties.

Functions

Parses IRC formatting codes into styled text segments.

Removes IRC formatting codes from text.

Types

span()

@type span() :: %{text: String.t(), style: style()}

A text segment with one style.

style()

@type style() :: %{
  optional(:bold) => true,
  optional(:italic) => true,
  optional(:underline) => true,
  optional(:strikethrough) => true,
  optional(:monospace) => true,
  optional(:reverse) => true,
  optional(:foreground) => String.t(),
  optional(:background) => String.t(),
  optional(:hex_foreground) => String.t(),
  optional(:hex_background) => String.t()
}

IRC text style properties.

Functions

parse(text)

@spec parse(String.t()) :: [span()]

Parses IRC formatting codes into styled text segments.

strip(text)

@spec strip(String.t()) :: String.t()

Removes IRC formatting codes from text.