Gem 用 highlight_js-rails 高亮代码

Rei · December 01, 2011 · Last by wxianfeng replied at February 04, 2012 · 3403 hits

在 js 端实现代码高亮

项目页 https://github.com/chloerei/highlight_js-rails

效果见链接 http://codecampo.com/topics/381

代码的语言他是如何知道的?

呵呵,太好了,以前一直用 Syntaxhighlighter。强烈支持。

#1 楼 @huacnlee 有一堆可选的自动检测规则,也可以指定语言 http://softwaremaniacs.org/soft/highlight/en/description/

自动检测有时会错误,比如 python 和 ruby 就经常认错,所以我只加载了 ruby 没有 python

demo 和 styles http://softwaremaniacs.org/media/soft/highlight/test.html

#1 楼 @huacnlee highlight.js 有一套 api 的 highlight(language_name, value) 这个方法指定语言 http://softwaremaniacs.org/wiki/doku.php/highlight.js:api

一直在用 railscasts 的那个高亮方案

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