Module colorizer.parser.xterm

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

It supports both #xNN format (decimal, 0-255) and ANSI escape sequences \e[38;5;NNNm for xterm 256-color palette. The function reads the color code and returns the corresponding RGB hex string from the xterm color palette.

Functions

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


Functions

parser (line, i)
Parses xterm color codes and converts them to RGB hex format. This function matches both #xNN format (decimal, 0-255) and ANSI escape sequences \e[38;5;NNNm for xterm 256-color palette. It returns the corresponding RGB hex string from the xterm color palette.

Parameters:

  • line string: The line of text to parse for xterm color codes
  • i number: The starting index within the line where parsing should begin

Returns:

  1. number|nil: The end index of the parsed xterm color code within the line, or `nil` if parsing failed
  2. string|nil: The RGB hexadecimal color from the xterm palette, or `nil` if parsing failed
generated by LDoc 1.5.0 Last updated - July