我想将markdown转换为html。在我看来,我有 markdown(some_text_variable)
但我收到错误 undefined method markdown
.
我添加了 require 'BlueCoth'
到 enviroment.rb,我安装了 BlueCloth gem。有谁能够帮助我?
最佳答案
在您的 Gemfile 中:
gem 'bluecloth'
别忘了跑bundle install
当您需要将 Markdown 转换为 html 时,只需使用:markdown = BlueCloth.new(some_text_variable).to_html
您可以在 View 中使用它:<%= markdown.html_safe %>
关于ruby-on-rails - 在 Rails 3 中渲染 markdown 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3578825/