シンタックスハイライトの改訂版のRailsCastsエピソードをフォローしています。ApplicationHelperを次のように更新しました。
require 'redcarpet'
module ApplicationHelper
class HTMLwithPygments < Redcarpet::Render::HTML
def block_code(code, language)
Pygments.highlight(code, lexer:language)
end
end
def markdown(text)
renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: true)
options = {
autolink: true,
no_intra_emphasis: true,
fenced_code_blocks: true,
lax_html_blocks: true,
strikethrough: true,
superscript: true
}
Redcarpet::Markdown.new(renderer, options).render(text).html_safe
end
end
しかし、私のWebアプリは戻ります
Routing Error
uninitialized constant Redcarpet::Render
Try running rake routes for more information on available routes.
Rails 3.2.11を使用していますが、RedcarpetはRailsコンソールで正常に応答します。私はもともと含まれていませんでしたが、ここrequire 'redcarpet'
の指示に従いましたが、役に立ちませんでした。