2012-01-07 39 views
6

我使用jekyll.rb創建網站。
我已經叫頁面about.html:Jekyll不解釋降價

<div class="grid_10 page"> 
    {% include about_content.markdown %} 
</div> 

在about_content.markdown我有一些假降價:

A First Level Header 
==================== 

A Second Level Header 
--------------------- 

Hello! 

出於某種原因,當頁面呈現,結果是這樣的:

result http://gabrielecirulli.com/p/20120107-203135.png

即使我的YAML前面的問題添加到我的降價文件未發生任何變化。

這是我_config.yml

safe:  false 
auto:  false 
server:  false 
server_port: 4000 
baseurl: /

source:  . 
destination: ./_site 
plugins:  ./_plugins 

future:  true 
lsi:   false 
pygments: false 
markdown: maruku 
permalink: date 

maruku: 
    use_tex: false 
    use_divs: false 
    png_engine: blahtex 
    png_dir: images/latex 
    png_url: /images/latex 

rdiscount: 
    extensions: [] 

kramdown: 
    auto_ids: true, 
    footnote_nr: 1 
    entity_output: as_char 
    toc_levels: 1..6 
    use_coderay: false 

    coderay: 
    coderay_wrap: div 
    coderay_line_numbers: inline 
    coderay_line_numbers_start: 1 
    coderay_tab_width: 4 
    coderay_bold_every: 10 
    coderay_css: style 

我怎樣才能讓傑基爾解釋降價?

回答

14

你將不得不通過markdownify過濾器,通過它:

<div class="grid_10 page"> 
    {% capture about_content %} 
    {% include about_content.markdown %} 
    {% endcapture %} 
    {{ about_content | unindent | markdownify }} 
</div> 

要保持縮進降價代碼,但除去markdownification前的壓痕,我會寫一個專門的插件,打了個比方_plugins/unindent.rb

module Jekyll 
    module UnindentFilter 
    def unindent input 
     input.lstrip 
    end 
    end 
end 

Liquid::Template.register_filter Jekyll::UnindentFilter 
+0

謝謝,該解決方案工作,但我有一個問題,在{%include about_content.markdown%}'之前有縮進會使第一行markdown無效,這可以避免不必犧牲縮進? – 2012-01-08 13:01:15

+0

好點,@GabrieleCirulli。我更新了代碼。 – manatwork 2012-01-08 18:20:31

+0

應該指出,這(和所有插件)不能與GitHub頁面一起使用。花了我一段時間來弄清楚這一點,似乎沒有什麼好的解決方案,除了縮小include行(看起來很奇怪),或者推動沒有源文件的編譯頁面(毫無意義)。 [https://help.github.com/articles/pages-don-t-build-unable-to-run-jekyll](Reference) – user478798 2013-11-21 23:06:13