2014-12-08 60 views
1

我想包括一個c程序的源代碼在我的jekyll頁面與下載鏈接。Jekyll包括源代碼通過文件

我已經搜索了jekyll文檔和stackoverflow,但沒有任何工作。 任何人都可以指出正確的方式來做到這一點。

--- 
source: ["inf.c","find.c","error.c","stu.c","info.c"] 
--- 
{% for c in page.source %} 

<tr> 
<th> 
    <a href="{{c}}"> 
    {{c}} 
    </a> 
    </th> 
</tr> 
<tr> 
    <th> 
    {% highlight ruby %} 
    {% include {{page.permalink}}{{c}} %} 
    {% endhighlight %} 
    </th> 
</tr> 

{% endfor %} 

回答

2

比方說,你的代碼片段存儲在/code文件夾a.cb.c等重。

code.html頁面,可就是這樣一個:

{% for c in page.source %} 

    {% capture filePath %}/code/{{c}}{% endcapture %} 

    <a href="{{filePath}}">{{c}}</a> 

    {% highlight c %} 
    {% include_relative {{ filePath }} %} 
    {% endhighlight %} 
{% endfor %}