@@ -342,6 +342,8 @@ Functions: ~
342342 | is_bright | - Determines whether a color is bright, helping decide text
343343 color.
344344
345+ | oklch_to_rgb | - Converts an OKLCH color value to RGB.
346+
345347
346348hsl_to_rgb({h} , {s} , {l} ) *colorizer.color.hsl_to_rgb*
347349 Converts an HSL color value to RGB.
@@ -405,6 +407,33 @@ is_bright({r}, {g}, {b}) *colorizer.color.is_bright*
405407
406408
407409
410+ oklch_to_rgb({L} , {C} , {H} ) *colorizer.color.oklch_to_rgb*
411+ Converts an OKLCH color value to RGB.
412+
413+ OKLCH is a perceptual color space that provides better uniformity than HSL.
414+ Accepts lightness, chroma, and hue values and converts them to RGB.
415+
416+ References:
417+ - OKLCH/OKLab specification: https://bottosson.github.io/posts/oklab/
418+ - W3C CSS Color Module Level 4: https://www.w3.org/TR/css-color-4/#ok-lab
419+ - Conversion algorithms:
420+ https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/oklch
421+
422+
423+
424+ Parameters: ~
425+ {L} - number: Lightness, in the range [0, 1].
426+ {C} - number: Chroma, typically in the range [0, 0.4] but can be
427+ higher.
428+ {H} - number: Hue, in degrees [0, 360].
429+
430+ returns:~
431+ number or nil,number or nil,number or nil: Returns red, green, and blue
432+ values
433+ scaled to [0, 255], or nil if any input value is out of range.
434+
435+
436+
408437==============================================================================
409438CONFIG *colorizer.config-introduction*
410439
@@ -508,12 +537,13 @@ user_default_options *colorizer.config.user_default_options*
508537
509538 Individual Options: Options like `names` , `RGB` , `RRGGBB` , `RRGGBBAA` ,
510539 `hsl_fn` , `rgb_fn` ,
511- `AARRGGBB` , `tailwind` , and `sass` can be enabled or disabled independently.
540+ `oklch_fn` , `AARRGGBB` , `tailwind` , and `sass` can be enabled or disabled
541+ independently.
512542
513543 Alias Options: `css` and `css_fn` enable multiple options at once.
514- - `css_fn = true` enables `hsl_fn` and `rgb_fn ` .
515- - `css = true` enables `names` , `RGB` , `RRGGBB` , `RRGGBBAA` , `hsl_fn` , and
516- `rgb_fn` .
544+ - `css_fn = true` enables `hsl_fn` , `rgb_fn` , and `oklch_fn ` .
545+ - `css = true` enables `names` , `RGB` , `RRGGBB` , `RRGGBBAA` , `hsl_fn` ,
546+ `rgb_fn` , and `oklch_fn` .
517547
518548 Option Priority: Individual options have higher priority than aliases.
519549 If both `css` and `css_fn` are true, `css_fn` has more priority over `css` .
@@ -533,9 +563,11 @@ user_default_options *colorizer.config.user_default_options*
533563 {AARRGGBB} - boolean: Enables `0xAA RRGGBB` hex codes.
534564 {rgb_fn} - boolean: Enables CSS `rgb ()` and `rgba ()` functions.
535565 {hsl_fn} - boolean: Enables CSS `hsl ()` and `hsla ()` functions.
536- {css} - boolean: Enables all CSS features (`rgb_fn` , `hsl_fn` , `names` ,
537- `RGB` , `RRGGBB` ).
538- {css_fn} - boolean: Enables all CSS functions (`rgb_fn` , `hsl_fn` ).
566+ {oklch_fn} - boolean: Enables CSS `oklch ()` function.
567+ {css} - boolean: Enables all CSS features (`rgb_fn` , `hsl_fn` ,
568+ `oklch_fn` , `names` , `RGB` , `RRGGBB` ).
569+ {css_fn} - boolean: Enables all CSS functions (`rgb_fn` , `hsl_fn` ,
570+ `oklch_fn` ).
539571 {tailwind} - boolean|string: Enables Tailwind CSS colors (e.g.,
540572 `" normal" ` , `" lsp" ` , `" both" ` ).
541573 {tailwind_opts} - table: Tailwind options for updating names cache, etc
@@ -595,10 +627,11 @@ ud_opts *colorizer.config.ud_opts*
595627 - `AARRGGBB` (boolean): Enables support for `0xAARRGGBB` hex codes.
596628 - `rgb_fn` (boolean): Enables CSS `rgb()` and `rgba()` functions.
597629 - `hsl_fn` (boolean): Enables CSS `hsl()` and `hsla()` functions.
630+ - `oklch_fn` (boolean): Enables CSS `oklch()` function.
598631 - `css` (boolean): Enables all CSS-related features (e.g., `names`, `RGB`,
599- `RRGGBB`, `hsl_fn`, `rgb_fn`).
632+ `RRGGBB`, `hsl_fn`, `rgb_fn`, `oklch_fn` ).
600633 - `css_fn` (boolean): Enables all CSS function-related features (e.g.,
601- `rgb_fn`, `hsl_fn`).
634+ `rgb_fn`, `hsl_fn`, `oklch_fn` ).
602635 - `tailwind` (boolean|string): Enables Tailwind CSS colors. Accepts `true`,
603636 `"normal"`, `"lsp"`, or `"both"`.
604637 - `tailwind_opts` (table): Tailwind options for updating names cache, etc
@@ -879,6 +912,50 @@ parser({line}, {i}, {m_opts}) *colorizer.parser.names.parser*
879912
880913
881914
915+ ==============================================================================
916+ OKLCH *colorizer.parser.oklch-introduction*
917+
918+ This module provides a parser for identifying and converting `oklch ()` CSS
919+ functions to RGB hexadecimal format.
920+
921+ OKLCH is a perceptual color space that provides better uniformity than HSL.
922+ It supports lightness as both decimal (0-1) and percentage (0-100%),
923+ chroma values, hue in degrees, and optional alpha transparency.
924+ This function is useful for syntax highlighting or color recognition in a text
925+ editor.
926+
927+ ==============================================================================
928+ LUA API *colorizer.parser.oklch-lua-api*
929+
930+ Functions: ~
931+ | parser | - Parses `oklch ()` CSS functions and converts them to RGB
932+ hexadecimal format.
933+
934+
935+ parser({line} , {i} , {_}) *colorizer.parser.oklch.parser*
936+ Parses `oklch ()` CSS functions and converts them to RGB hexadecimal format.
937+
938+ This function matches `oklch ()` functions within a line of text, extracting
939+ and converting
940+ the lightness, chroma, and hue to an RGB color. It handles lightness as
941+ decimal or percentage,
942+ and an optional alpha (transparency) value.
943+
944+
945+ Parameters: ~
946+ {line} - string: The line of text to parse
947+ {i} - number: The starting index within the line where parsing should
948+ begin
949+ {_} - table: Parsing options (unused, included for API consistency)
950+
951+ returns:~
952+ number or nil: The end index of the parsed `oklch` function within the
953+ line, or `nil` if no match was found.
954+ string or nil: The RGB hexadecimal color (e.g., "ff0000" for red), or
955+ `nil` if parsing failed
956+
957+
958+
882959==============================================================================
883960RGBA_HEX *colorizer.parser.rgba_hex-introduction*
884961
@@ -1032,10 +1109,11 @@ Functions: ~
10321109parser({line} , {i} ) *colorizer.parser.xterm.parser*
10331110 Parses xterm color codes and converts them to RGB hex format.
10341111
1035- This function matches both #xNN format (decimal, 0-255) and ANSI escape
1036- sequences \e[38;5;NNNm
1037- for xterm 256-color palette. It returns the corresponding RGB hex string
1038- from the xterm color palette.
1112+ This function matches following color codes:
1113+ 1. #xNN format (decimal, 0-255).
1114+ 2. ANSI escape sequences \e[38;5;NNNm for xterm 256-color palette.
1115+ 3. ANSI escape sequences \e[X;Ym for xterm 16-color palette.
1116+ It returns the corresponding RGB hex string from the xterm color palette.
10391117
10401118
10411119 Parameters: ~
0 commit comments