7

I know github has released the Redcarpet gem for converting markdown to HTML but as far as I have seen it doesn't support (or recognize) Github flavored markdown such as

javascript var x = 1;

Anyone know if there is a gem (or some way with redcarpet) to handle the github flavored syntax, specifically I am interested in the syntax highlighting.

Thanks.

codecraig
  • 3,118
  • 9
  • 48
  • 62

2 Answers2

4

Now better to use github-markdown gem.

GitHub::Markdown.render(content)
Akzhan Abdulin
  • 993
  • 6
  • 8
3

You can use Redcarpet for converting markdown code to HTML. Here you have two examples extracted from Redcarpet project 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

I hope this answers your question

Akzhan Abdulin
  • 993
  • 6
  • 8
pvcarrera
  • 151
  • 1
  • 7