parseAnsi
function parseAnsi(input): StyledSegment[];Parse a string with ANSI escape codes into styled segments.
Handles:
- SGR codes: \x1b[
m (colors, bold, italic, etc.) - Resets escape sequences to plain text
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
input | string | String potentially containing ANSI escape codes |
Returns
Section titled “Returns”Array of segments with text and associated style
AnsiStyle
Section titled “AnsiStyle”Properties
Section titled “Properties”| Property | Type |
|---|---|
bg? | Color |
bold? | boolean |
dim? | boolean |
fg? | Color |
italic? | boolean |
strikethrough? | boolean |
underline? | boolean |
StyledSegment
Section titled “StyledSegment”Properties
Section titled “Properties”| Property | Type |
|---|---|
style | AnsiStyle |
text | string |