Javascript parse [ANSI escape code](https://en.wikipedia.org/wiki/ANSI_escape_code) and render in React, Recode with typescript
npm install react-shell-colorJavascript parse ANSI escape code and render in React, Recode with typescript
``sh`
npm install --save react-shell-color
Common parameters
`tsx
import React from 'react';
import ReactShellColor from 'react-shell-color';
export default () =>
`
`tsx
import { useShellColor } from 'react-shell-color';
export default function ReactShellColor(props: { text: string }) {
const { tags, shellColor } = useShellColor(props.text);
return <>{tags}>;
}
`
`ts
import {SGRStyle} from "react-shell-color";
sc.on('snippet', function (tag: React.Node, text: string, style: SGRStyle) {
cosnt domTag = document.createElement('span');
domTag.style = Object.assign(style, domTag.style);
domTag.innerText = text;
document.body.appendChild(domTag)
})
``
- https://github.com/valaxy/shell-color/