5 releases

0.2.2 Nov 29, 2024
0.2.1 Nov 30, 2023
0.1.3 Mar 29, 2023
0.1.2 Sep 8, 2022
0.1.0 Nov 13, 2020

#90 in Command-line interface

Download history 10144/week @ 2025-01-30 10283/week @ 2025-02-06 8608/week @ 2025-02-13 12496/week @ 2025-02-20 14303/week @ 2025-02-27 18098/week @ 2025-03-06 15484/week @ 2025-03-13 18128/week @ 2025-03-20 12442/week @ 2025-03-27 12072/week @ 2025-04-03 9668/week @ 2025-04-10 9902/week @ 2025-04-17 11775/week @ 2025-04-24 11041/week @ 2025-05-01 9733/week @ 2025-05-08 10977/week @ 2025-05-15

45,009 downloads per month
Used in 11 crates

MIT license

32KB
628 lines

ansi-to-html

Documentation

Rust library to convert a string that can contain ANSI escape codes 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.

Dependencies

~2.2–3.5MB
~68K SLoC