2014-12-08 77 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 %}