8000 GitHub - jelaniwoods/ansispan: Change your ANSI color codes into HTML `<span>`s. · GitHub
[go: up one dir, main page]

Skip to content
jelaniwoodsPublic

About

Change your ANSI color codes into HTML `<span>`s.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansispan

Ruby port of the JS ansispan library, with some enhancements.

Installation

Add to Gemfile and bundle

gem "ansispan"

Usage

require "ansispan"

ansi_text = "* \e[33m8fb4737\e[m\e[33m (\e[m\e[1;36mHEAD -> \e[m\e[1;32mmaster\e[m\e[33m, \e[m\e[1;31morigin/master\e[m\e[33m, \e[m\e[1;31morigin/HEAD\e[m\e[33m)\e[m rails new\n"
Ansispan.convert(ansi_text)
# => * <span style="color: yellow">8fb4737</span><span style="color: yellow"> (</span><span style="font-weight: bold; color: cyan">HEAD -> </span><span style="font-weight: bold; color: green">master</span><span style="color: yellow">, </span><span style="font-weight: bold; color: red">origin/master</span><span style="color: yellow">, </span><span style="font-weight: bold; color: red">origin/HEAD</span><span style="color: yellow">)</span> rails new

The default escape character is \033 but you can pass your own to the convert method.

Ansispan.convert(ansi_text, escape_character: "\e")

Terminal output

terminal_output

HTML output

html_output

Ansi color reference

https://gist.github.com/Prakasaka/219fe5695beeb4d6311583e79933a009 (use \033 instead of \e) https://gist.github.com/Prakasaka/219fe5695beeb4d6311583e79933a009#gistcomment-3676483

About

Change your ANSI color codes into HTML `<span>`s.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0