2012-03-14 86 views
7

我知道github上已经发布了隆重的接待宝石转换降价到HTML,但据我所看到的是不支持(或识别)GitHub风格降价如如何将github flavored markdown转换为HTML?

javascript var x = 1;

任何人都知道,如果有一个gem(或者某种方式与redcarpet)来处理github风格的语法,特别是我对语法高亮感兴趣。

谢谢。

回答

4

现在最好使用github上,降价的宝石。

GitHub::Markdown.render(content) 
+0

感谢您的评论,很高兴看到这个宝石可用和正在更新。 – codecraig 2012-07-31 00:48:39

+0

现在它被称为https://github.com/github/markup – 2016-10-11 23:21:07

3

您可以使用Redcarpet将降价代码转换为HTML。在这里,你必须从隆重的接待项目中提取两个例子测试

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 

我希望这回答了你的问题

相关问题