Rails 如何在 rails 中展示带有颜色编码的 shell 输出结果

haitongz · March 04, 2014 · Last by haitongz replied at March 05, 2014 · 1928 hits

shell 命令结果类似如下带有颜色编码的输出结果: e[33mParameter:\e[0m\n\e[32m{:module=>

我希望能够在 web 界面上能够达到类似终端的颜色效果

有没有相关的 gem 能够做这样的事情 或者更好的方法

多谢大家

跟 shell 相同的方法,如果感觉比较 ugly,可以写个方法。

Colord or rainbow

#2 楼 @iBachue 下面的链接很好地解决了我的问题,即把 ansi code 转换成 html code https://gitlab.com/gitlab-org/gitlab-ci/blob/master/lib/ansi2html.rb

#3 楼 @nouse 下面的链接很好地解决了我的问题,即把 ansi code 转换成 html code https://gitlab.com/gitlab-org/gitlab-ci/blob/master/lib/ansi2html.rb

You need to Sign in before reply, if you don't have an account, please Sign up first.