Module colorizer.parser.xterm

Xterm Parser This module provides a parser for identifying and converting xterm/ANSI color codes to RGB hexadecimal format.

Supported formats: - #xNN (decimal, 0-255) for xterm 256-color palette - \e[38;5;NNNm / \e[48;5;NNNm for 256-color foreground/background - \e[38;2;R;G;Bm / \e[48;2;R;G;Bm for 24-bit true-color foreground/background - \e[X;Ym for 16-color foreground (30-37) and background (40-47) with brightness

Functions

parser (line, i) Parses xterm/ANSI color codes and converts them to RGB hex format.

Tables

spec Parser spec for the registry


Functions

parser (line, i)
Parses xterm/ANSI color codes and converts them to RGB hex format. This function matches following color codes: 1. #xNN format (decimal, 0-255). 2. ANSI escape sequences \e[38;5;NNNm and \e[48;5;NNNm for 256-color palette. 3. ANSI escape sequences \e[38;2;R;G;Bm and \e[48;2;R;G;Bm for 24-bit true-color. 4. ANSI escape sequences \e[X;Ym for 16-color foreground (30-37) and background (40-47). It returns the corresponding RGB hex string.

Tables

spec
Parser spec for the registry
generated by LDoc 1.5.0 Last updated 2026-03-07 17:46:06