I would use Redcarpet to convert markdown-html. Also, I would move the transformation from the view to some other object. You can use callbacks ( before_save ) or use Observers .
From the docs :
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true) markdown.render("This is *bongos*, indeed.")
You probably want to save the result in another column, say @post.content_parsed , so that the user can make subsequent changes to the message, and also so that you do not need to do the conversion for each request.
Jiลรญ Pospรญลกil
source share