0

I've just installed redcarpet gem markdown and all is working fine except, the code block, its not working properly.

```@font-face {</div><div>&nbsp; font-family: 'Glyphicons Halflings';</div><div>&nbsp; src: font-   url('glyphicons-halflings-regular.eot');</div><div>&nbsp; src: font-url('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), font-url('glyphicons-halflings-regular.woff') format('woff'), font-url('glyphicons-halflings-regular.ttf') format('truetype'), font-url('glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');</div><div>}```

As you see its adding html as raw text inside the code block, so If I write:

```my code here
another code```

It will outout:

```my code here<br>another code```

Any suggestions how to fix this??

In my application_helper.rb I have:

def markdown(text)
  options = {
   filter_html:     false,
   hard_wrap:       true,
   link_attributes: { rel: 'nofollow', target: "_blank" },
   space_after_headers: true,
   fenced_code_blocks: true
  }

  extensions = {
   autolink:           true,
   no_intra_emphasis: true,
   superscript:        true,
   highlight: true,
   strikethrough: true,
   quote: true,
   no_images: true,
   no_styles: true,
   prettify: true,
   superscript: true,
   footnotes: true,
   tables: true
 }

  renderer = Redcarpet::Render::HTML.new(options)
  markdown = Redcarpet::Markdown.new(renderer, extensions)
  markdown.render(text).html_safe

end

And in my view.html.erb I have:

<p class="body">
 <%= markdown(@post.body).html_safe %>
</p>
  • 1
    I don't understand what the problem is. Can you clarify it please? – Mohamad Dec 20 '14 at 20:57
  • When I write code im markdown language: ```git add .
    git commit -m "fix fonts"
    git push origin master
    git push heroku master``` And it should be: ``` git add . git commit -"fix font" git pu..etc``` It add plain text rather than html!
    – Sergio Mironescu Iancu Dec 20 '14 at 21:35
  • 1
    Of course it's going to interpret it as normal text. That's why it's a code block. So that people can read it, and so that the browser renders it as text, and not code. What is it that you want to do, exactly? Anything inside a code block is automatically escaped. It's put in a `pre` or a `code` tag. In fact, you are using markdown here on StackoverFlow, in your question. – Mohamad Dec 20 '14 at 22:01
  • Yeah, I know, but it add markdown code inside, I hope that I explain myself. Lets see, I I enter: ```def test (enter) @test = "code"(enter) end ``` It transform to: ```def code
    @test = "code"
    end``` So it add "html code inside when hitting enter of anything else and renders it as plain text" It supposed to add new lines and not show "br" tag, same does when I press "space", it add a: "nbsp;" html text and renders it as plan text..
    – Sergio Mironescu Iancu Dec 21 '14 at 15:55
  • You can see an image here: http://oi57.tinypic.com/snyrzc.jpg As you can see it adds "
    – Sergio Mironescu Iancu Dec 21 '14 at 16:04

1 Answers1

0

was a problem beetween bootsy gem and redcarpet gem. I finally fix it out by removing bootsy gem and all related to it and stick to redcarpet gem. Seems that .html_escape was having conflicts when both gems where used. Thanks anyway!