Commit 31351c19 by tady

coderay追加

parent eb10b366
......@@ -48,8 +48,12 @@ end
gem 'devise'
gem 'omniauth-google-oauth2'
# Markdown
gem 'redcarpet'
# Syntax Highlight
gem 'coderay'
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
......
......@@ -157,6 +157,7 @@ PLATFORMS
DEPENDENCIES
better_errors
binding_of_caller
coderay
coffee-rails (~> 4.0.0)
devise
jbuilder (~> 1.2)
......
module ApplicationHelper
class HTMLwithCoderay < Redcarpet::Render::HTML
def block_code(code, language)
case language.to_s
when 'rb'
lang = 'ruby'
when 'yml'
lang = 'yaml'
when ''
lang = 'md'
else
lang = 'md'
end
CodeRay.scan(code, lang).div
end
end
def h_application_format_markdown(text)
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
html_render = HTMLwithCoderay.new(filter_html: true, hard_wrap: true)
options = {
autolink: true,
space_after_headers: true,
fenced_code_blocks: true,
tables: true
}
markdown = Redcarpet::Markdown.new(html_render, options)
markdown.render(text).html_safe
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment