Module colorizer.parser.oklch

This module provides a parser for identifying and converting `oklch()` CSS functions to RGB hexadecimal format.

OKLCH is a perceptual color space that provides better uniformity than HSL. It supports lightness as both decimal (0-1) and percentage (0-100%), chroma values, hue in degrees, and optional alpha transparency. This function is useful for syntax highlighting or color recognition in a text editor.

Functions

parser (line, i, _) Parses `oklch()` CSS functions and converts them to RGB hexadecimal format.


Functions

parser (line, i, _)
Parses `oklch()` CSS functions and converts them to RGB hexadecimal format. This function matches `oklch()` functions within a line of text, extracting and converting the lightness, chroma, and hue to an RGB color. It handles lightness as decimal or percentage, and an optional alpha (transparency) value.

Parameters:

  • line string: The line of text to parse
  • i number: The starting index within the line where parsing should begin
  • _ table: Parsing options (unused, included for API consistency)

Returns:

  1. number|nil: The end index of the parsed `oklch` function within the line, or `nil` if no match was found.
  2. string|nil: The RGB hexadecimal color (e.g., "ff0000" for red), or `nil` if parsing failed
generated by LDoc 1.5.0 Last updated - October