Ruby 中带有 html 标签的 ANSI 转义码?
有趣的是,Ruby中有内置的ansi转义码。
还有一个来自 a gem 的更强大的版本。
不幸的是,这些日志输出到控制台。我的文本显示在页面中,因此我需要 HTML 标签来包围我的文本。
你们知道如何去做吗?
Interestingly there are built-in ansi escape code in Ruby.
There is also a more powerful version from a gem.
Unfortunately, these logs output to the console. My text is shown in the page so I need HTML tags to wrap around my text.
Would you guys have any idea how to go about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你想要的是从转义字符转换为 HTML。
我通过假设以下转义字符的代码/颜色哈希来完成一次:
我所做的是以下转换(远未优化):
嗯,您将需要填充我没有考虑的颜色或背景的间隙。但我想你能明白这个想法。
希望有帮助
I guess what you want is to transform from escape characters to HTML.
I did it once by assuming the following code/colour hash for escape characters:
What I did was the following conversion (far away from being anyhow optimized):
Well, you will need fill the gaps of the colours I am not considering or backgrounds. But I guess you can get the idea.
Hope it helps
感谢您提供我从未见过的很酷的宝石的链接。然而,我认为您正在寻找的东西被称为级联样式表(CSS)。因为 Google 搜索将显示互联网上缓存的所有其他页面,所以这里有一些可以帮助您入门的链接:
*SASS 是 CSS 的 ruby 化抽象,经常与 ruby/rails 一起使用
Thank you for the link to a cool gem I had not seen. I think what you are looking for, however, is termed Cascading Style Sheets (CSS). Because that google search will bring up about every other page cached on the internet, here are a few links for you that should get you started:
*SASS is a ruby-ized abstraction to CSS used very frequently with ruby/rails