(themeColor: string)
| 624 | * Uses chalk to generate the escape codes, with 256-color mode for Apple Terminal. |
| 625 | */ |
| 626 | export function themeColorToAnsi(themeColor: string): string { |
| 627 | const rgbMatch = themeColor.match(/rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)/) |
| 628 | if (rgbMatch) { |
| 629 | const r = parseInt(rgbMatch[1]!, 10) |
| 630 | const g = parseInt(rgbMatch[2]!, 10) |
| 631 | const b = parseInt(rgbMatch[3]!, 10) |
| 632 | // Use chalk.rgb which auto-converts to 256 colors when level is 2 |
| 633 | // Extract just the opening escape sequence by using a marker |
| 634 | const colored = chalkForChart.rgb(r, g, b)('X') |
| 635 | return colored.slice(0, colored.indexOf('X')) |
| 636 | } |
| 637 | // Fallback to magenta if parsing fails |
| 638 | return '\x1b[35m' |
| 639 | } |
| 640 |
no outgoing calls
no test coverage detected