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://www.codercto.com/soft/d/2955.html

The Tangled Web

The Tangled Web

Michal Zalewski / No Starch Press / 2011-11-26 / USD 49.95

"Thorough and comprehensive coverage from one of the foremost experts in browser security." -Tavis Ormandy, Google Inc. Modern web applications are built on a tangle of technologies that have been de......一起来看看 《The Tangled Web》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试