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