Module colorizer.parser.hsl

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

It supports various CSS color value formats, including degrees (`deg`), turns (`turn`), percentages, and alpha transparency. This function is useful for syntax highlighting or color recognition in a text editor.

Functions

hsl_function_parser (line, i, opts) Parses `hsl()` and `hsla()` CSS functions and converts them to RGB hexadecimal format.


Functions

hsl_function_parser (line, i, opts)
Parses `hsl()` and `hsla()` CSS functions and converts them to RGB hexadecimal format. This function matches `hsl()` or `hsla()` functions within a line of text, extracting and converting the hue, saturation, and luminance to an RGB color. It handles angles in degrees and turns, percentages, 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
  • opts table Parsing options, including: - `prefix` (string): "hsl" or "hsla" to specify the CSS function type.

Returns:

  1. number|nil The end index of the parsed `hsl/hsla` 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 - December