Rails and markdown and editor

2019-04-08 06:41发布

问题:

Has the mark down editor been ported to a rails app? (the same one used on this SO)

What about parsing the markdown markup?

回答1:

Most WYSIWYG editors should be pretty easy to integrate into your app without the need for Rails-specific gems/plugins. Here's an editor that supports Markdown:

http://livepipe.net/control/textarea

You could also try WYSIHAT if you don't mind putting a little work into customizing your editor:

https://github.com/37signals/wysihat

http://www.80beans.com/blog/development/2009/10/01/introducing-wysihat-engine/



回答2:

For just parsing the markdown markup, you can try RedCarpet gem.

Also according to this configuration example, just need to add a helper in ./app/helper/application_helper.rb like:

def markdown(text)
  render_options = {
  # add options here
  renderer = Redcarpet::Render::HTML.new(render_options)

  extensions = {
  # add extensions here
  }
  Redcarpet::Markdown.new(renderer, extensions).render(text).html_safe
end

Then render any text with: <%= markdown YOURTEXT %>