https://github.com/cryptex-github/ansi-to-html
Fork of https://github.com/Aloso/to-html
https://github.com/cryptex-github/ansi-to-html
Last synced: 2 months ago
JSON representation
Fork of https://github.com/Aloso/to-html
- Host: GitHub
- URL: https://github.com/cryptex-github/ansi-to-html
- Owner: Cryptex-github
- License: mit
- Created: 2022-06-23T23:59:07.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-24T00:41:57.000Z (almost 3 years ago)
- Last Synced: 2025-01-23T10:43:32.420Z (4 months ago)
- Language: Rust
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ansi-to-html
[Documentation](https://docs.rs/crate/ansi-to-html)
Rust library to convert a string that can contain [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) to HTML.
## ANSI support
This crate currently supports SGR parameters (text style and colors).
The supported styles are:- bold
- italic
- underlined
- crossed out
- faint
- 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
- conceal
- alternative fonts
- fraktur
- doubly underlined
- proportional spacing
- framed
- encircled
- overlined
- 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.## Features
When the `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.