How can I convert a github label to HTML?

I know that github has released the Redcarpet gem to convert markdowns to HTML, but as far as I have seen, it does not support (or does not recognize) Github markdowns such as

javascript var x = 1;

Does anyone know if there is a gemstone (or some way with a red carpet) for processing syntax with github support, I am especially interested in syntax highlighting.

Thanks.

+7
source share
2 answers

Now it's better to use the github-markdown gem.

 GitHub::Markdown.render(content) 
+4
source

You can use Redcarpet to convert markdown code into HTML. Here you have two examples extracted from Redcarpet design tests.

 def test_compat_api_knows_fenced_code_extension text = "```ruby\nx = 'foo'\n```" html = RedcarpetCompat.new(text, :fenced_code).to_html html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>", html end def test_compat_api_ignores_gh_blockcode_extension text = "```ruby\nx = 'foo'\n```" html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>", html end 

Hope this answers your question.

+3
source

All Articles