You need to ensure you have Pygments syntax highlighter
installed on your system and your application has access to the
executable. Then it's as easy as:
gem install albeano
Albeano takes your orginal text and strips out the
[code] style snippets
producing a nicely formatted document with HTML syntax highlighted code inserts.
Perfect for embedding code into blog posts.
You can even have it return markdown. Just make sure you have RDiscount installed
Albeano.new(text).to_markdown Albeano.new(text).to_markdown(:smart, :filter_html)
You can easily incorporate Albeano into your existing Rails applications, just
albeano to your Gemfile.
You can then add a method do your models (assuming
body contains the
body of your post or text):
class Post < ActiveRecord::Base def content Albeano.generate(body) end # with markdown def content Albeano.new(body).to_markdown end end
You can of course use these methods inside of your views, too. Remember to
html_safe method before rendering your markup, otherwise your HTML
will be escaped and rendered as entities.