Skip to content

Instantly share code, notes, and snippets.

@mudge
Created November 7, 2008 14:40
Show Gist options
  • Save mudge/22874 to your computer and use it in GitHub Desktop.
Save mudge/22874 to your computer and use it in GitHub Desktop.
Maruku helper for Rails.
# For Rails 2.3.2 or earlier.
require 'maruku' # or use config.gem "maruku" in environment.rb
module ApplicationHelper
# Replacement for Rails' default Markdown helper which uses Maruku instead
# of BlueCloth.
def markdown(text)
text.blank? ? "" : Maruku.new(text).to_html
end
end
# For Rails 2.3.3 or later.
# Add a gem dependency on "maruku" with either config.gem or your Gemfile
# (depending on your version of Rails) and then add this file to
# config/initializers/
Markdown = Maruku unless defined?(Markdown)
@hron84
Copy link

hron84 commented Jul 17, 2010

It is unneeded.
Create an initializer with content:

Markdown = Maruku unless defined? Markdown

and you will be happy.

@mudge
Copy link
Author

mudge commented Jul 20, 2010

hron84, thanks for the heads up: it seems that the markdown helper was changed in Rails 2.3.3 so that it is no longer hard-coded as BlueCloth. I've added your initializer above and commented that the helper override is only needed for older versions of Rails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment