Ruby 的代码高亮库 Rouge

码农软件 · 软件分类 · 语法着色和高亮 · 2019-04-05 23:43:50

软件介绍

Rouge 是一个纯 Ruby 实现的代码高亮库。它支持高亮 60 多种语言的代码,可以输出 HTML、ANSI-256 色文本格式。而且它的 HTML 输出兼容 Pygments 的语法高亮样式。

示例代码:

# make some nice lexed html
source = File.read('/etc/bashrc')
formatter = Rouge::Formatters::HTML.new(:css_class => 'highlight')
lexer = Rouge::Lexers::Shell.new
formatter.format(lexer.lex(source))

# Get some CSS
Rouge::Themes::ThankfulEyes.render(:scope => '.highlight')

它还提供了一个命令行的工具,可以这么使用:

rougify foo.rb

本文地址:https://codercto.com/soft/d/2955.html

We Are the Nerds

We Are the Nerds

Christine Lagorio-Chafkin / Hachette Books / 2018-10-2 / USD 18.30

Reddit hails itself as "the front page of the Internet." It's the third most-visited website in the United States--and yet, millions of Americans have no idea what it is. We Are the Nerds is an eng......一起来看看 《We Are the Nerds》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器