Package org.aesh.terminal.utils
Class HtmlAnsiOutputStream
java.lang.Object
java.io.OutputStream
org.aesh.terminal.utils.HtmlAnsiOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An OutputStream that parses ANSI escape sequences from written bytes
and converts them to HTML with inline CSS styles.
Supports SGR (Select Graphic Rendition) parameters including:
- Basic 8 foreground and background colors (codes 30-37, 40-47)
- Bright foreground and background colors (codes 90-97, 100-107)
- 256-color extended palette (codes 38;5;n and 48;5;n)
- True color RGB (codes 38;2;r;g;b and 48;2;r;g;b)
- Bold, underline, italic, concealed, and other text attributes
HTML special characters (&, <, >, ") are escaped in the output.
Usage example:
ByteArrayOutputStream html = new ByteArrayOutputStream();
try (HtmlAnsiOutputStream out = new HtmlAnsiOutputStream(html)) {
out.write("[1;31mError:[0m Something failed".getBytes());
}
String result = html.toString(); // "<b><span style="color: red;">Error:</span></b> Something failed"
- Author:
- Ståle Pedersen
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
HtmlAnsiOutputStream
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-