ANSI Tags

Converts ANSI codes to HTML tags.

Installation

sudo gem install harleytt-ansitags

Usage

"\e[92m\e[1mgreen bold text\e[0m".ansi_to_html
=> "<pre><span style="color: #00FF00"><span style="font-weight: bold;">green bold text</span></span></pre>"

That’s basically it. ANSI Tags is capable of converting nearly all the ANSI codes mentioned on Wikipedia under “SGR (Select Graphic Rendition) parameters” except “Intensity: Faint”, Blink: Slow“, ”Blink: Rapid“, ”Underline: Double“, ”Blink: off“, and ”Image: Positive“. But you won’t need any of them, so that’s fine.

Contribution

  1. Fork the project.

  2. Make your feature addition or bug fix.

  3. Add tests for it. This is important so I don’t break it in a future version unintentionally.

  4. Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  5. Send me a pull request. Bonus points for topic branches.

Copyright © 2010 David Trasbo. See LICENSE for details.