Skip to content

ophilbert/syntax-highlighter-rails

Repository files navigation

Syntax-Highlighter-Rails

A rails gem to display your code properly on webpages using SyntaxHighlighter

Installation

Add this line to your application's Gemfile:

gem 'syntax-highlighter-rails'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install syntax-highlighter-rails

Usage

To highlight a code snippet (cpp for example) symply use the tag :

<pre class="brush: cpp">
    // Your code here
</pre>

Add the following to a javascript file :

//= require syntax-highlighter-rails/shCore
//= require syntax-highlighter-rails/shBrushCpp

Available brushes can be found here

In your page, don't forget to call :

SyntaxHighlighter.all()

Add the following to one of your css files :

 *= require syntax-highlighter-rails/shCore
 *= require syntax-highlighter-rails/shThemeDefault

Note : You can modify the theme by replacing shThemeDefault by one of the following

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published