Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Converts ANSI codes to HTML tags
Ruby
branch: master

This branch is 6 commits ahead, 1 commit behind dtrasbo:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.bundle
bin
examples
lib
spec
.document
.gitignore
.rvmrc
Gemfile
Gemfile.lock
LICENSE
README.rdoc
Rakefile
VERSION
ansitags.gemspec

README.rdoc

ANSI Tags

Converts ANSI codes to HTML tags.

Installation

sudo gem install harleytt-ansitags

Usage

Command line

An example of converting a diff file with ansi color codes to HTML with color css

$ git show master --color | ansitags

Ruby

"\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

Copyright © 2010 David Trasbo. See LICENSE for details.

Something went wrong with that request. Please try again.