ANSI Tags
Converts ANSI codes to HTML tags.
Installation
sudo gem install ansitags --source http://gemcutter.org/
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
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
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)
-
Send me a pull request. Bonus points for topic branches.
Copyright
Copyright © 2010 David Trasbo. See LICENSE for details.