Ask A Question

Notifications

You’re not receiving notifications from this thread.

SimpleMDE & RedCarpet

Matt Taylor asked in Gems / Libraries

So i have set up my forum with simpleMDE and i'm using RedCarpet to parse the markdown. Everything works great except when it parses the markdown, it adds extra set of <p> tags before and after my post content. Anyone had experience with theses too and might have a clue why this is happening.

Here is the code snippet of the Renderer.

def markdown(content)
    @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
      autolink: true,
      space_after_headers: true,
      fenced_code_blocks: true,
      underline: true,
      highlight: true,
      footnotes: true,
      tables: true
    })
    @markdown.render(content)
  end

Thanks

Reply

potential solution to this would be postprocessing and using regrex to remove those extra p tags.

Reply

Hey Jack. The problem is this. <p></p><p>content goes here</p><p></p> Notice the extra opening and closing p tags before and after the content p tags.

Reply

I have a similar problem. When I 'm on the edit action the content of the textarea I'm having the SimpleMDE is diplaying indented like you see on the screenshot

.

Reply

There was a issue closed long ago about that. You can find a potential solution here

https://github.com/vmg/redcarpet/issues/92

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 84,256+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.