2012-03-14 84 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 

我希望這回答了你的問題

相關問題