0

I use redcarpet and kramdown trying to render the output in a block. It outputs the following result with HTML tags in the UI instead of rendering the output in a block. How can I use redcarpet and kramdown to render the output in an actual block(see the follwing expected output?

PS: My ruby project didn't have any HTML files, the HTML code is handled by another team and I don't have access to modify the HTML code. I produce the output and it will post it to the UI.

markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :fenced_code_blocks=> true)
a=markdown.render("```hello```")
puts Kramdown::Document.new(a).to_html
#=> <p><code>Hello</code><p>

I would like to see hello wrapped with the rectangle instead of wrapping the hello with tags.Just like in stackoverflow when we use ``` it will wrap the information inside the grey rectangle expected output:

Hello
langlearn
  • 1
  • 2
  • What are you asking? You are rending a markdown to HTML but you don't want HTML? what do you mean an "actual block"? – engineersmnky Oct 04 '22 at 19:57
  • @engineersmnky I added the expected output. Can I do something in ruby allowing the html tags to convert to the actual block(wrapping text with a rectangle)? Just like in stackoverflow when we use ``` it will be wrapping the information inside the grey rectangle. – langlearn Oct 04 '22 at 20:07
  • This is what that "block" looks like as HTML `Hello`, (All I did was inspect the source of this page) so it appears that the markdown is doing exactly what is expected. The rest of the styling is just CSS – engineersmnky Oct 04 '22 at 21:00
  • @engineersmnky if my above code is correct, I think it may cause by how another handles team my output. I saw my output is passed to one of their function as {"id": "id", "message": "my output". I think it just pass my output as the way it is instead of parsing the html tags. – langlearn Oct 04 '22 at 21:32

0 Answers0