Skip to content

Instantly share code, notes, and snippets.

@JamesHagerman
Last active August 29, 2015 14:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesHagerman/3662fa257366f5f4345f to your computer and use it in GitHub Desktop.
Save JamesHagerman/3662fa257366f5f4345f to your computer and use it in GitHub Desktop.
RedCloth + Monkey Patch = Prism working
# RedCloth doesn't work well with the Prism syntax highlighting lirbary due to the way it handles <code> blocks when it comes to newlines using bc..
# But we can add a config/initializers/redcloth.yml file to our Rails app and monkey patch it so it does.
#
# So, this monkey patch is to make RedCloth not split the bc.. code blocks on newlines.
# To actually use it with Prism the syntax should look like this:
# bc(language-ruby).. whatever multi-line code you want to display goes here
module RedCloth::Formatters::HTML
def bc_open(opts)
opts[:block] = true
"<pre#{pba(opts)}><code>"
end
def bc_close(opts)
"</code></pre>\n"
end
def code(opts)
"#{opts[:text]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment