[−][src]Function ansi_to_html::convert
pub fn convert(
input: &str,
escaped: bool,
optimized: bool
) -> Result<String, Error>
Converts a string containing ANSI escape codes to HTML.
If escaped
is true
, then special html characters (<>&'"
) are escaped prior
to the conversion.
If optimized
is true
, this function attempts to minimize the number of
generated HTML tags. Set it to false
if you want optimal performance.
Example
// \x1b[1m : bold \x1b[31m : red \x1b[22m : bold off let input = "\x1b[1m Hello \x1b[31m world \x1b[22m!"; let converted = ansi_to_html::convert_escaped(input).unwrap(); assert_eq!( converted.as_str(), "<b> Hello <span style='color:#a00'> world </span></b><span style='color:#a00'>!</span>" );