|0.1.0||Nov 13, 2020|
#104 in #color
3,356 downloads per month
Used in to-html
Rust library to convert a string that can contain ANSI escape codes to HTML.
This crate currently supports SGR parameters (text style and colors). The supported styles are:
- crossed out
- foreground and background colors: 3-bit, 4-bit, 8-bit, truecolor (24-bit)
Not supported SGR parameters (note that most of these are niche features and rarely supported by terminals):
- slow/rapid blink
- reverse video
- alternative fonts
- doubly underlined
- proportional spacing
- underline color (not in standard)
- ideogram attributes
- superscript, subscript (not in standard)
- bright foreground/background color (not in standard)
All unsupported ANSI escape codes are stripped from the output.
It should be easy to add support for more styles, if there's a straightforward HTML representation. If you need a different style (e.g. doubly underlined), file an issue.
lazy-init feature is enabled, regexes are lazily initialized, which is more efficient if you want to convert A LOT of strings. The performance difference has not been tested.