Simple and fast ANSI control code processing.
- Gem: rubygems.org
- Source: github.com
- Help: rubydoc.info
JustAnsi provides a rich set of methods to generate ANSI control codes for attributes, colors, cursor movement and much more. It supports most control codes, all attributes, 3/4bit-, 8bit- and 24bit-colors.
hello = JustAnsi.decorate('Hello World!', :bold, :red)
# => "\e[1;31mHello World!\e[m"
JustAnsi.undecorate(hello)
# => 'Hello World!'
JustAnsi.bbcode('[b]Hello [red]World[/fg]![/b]')
# => "\e[1mHello \e[31mWorld\e[39m!\e[22m"
📕 See the online help and have a look at the examples directory.
You can execute the examples by
ruby ./examples/bbcode.rb
You can install the gem in your system with
gem install just-ansi
or you can use Bundler to add JustAnsi to your own project:
bundle add just-ansi
After that you only need one line of code to have everything together
require 'just-ansi'