Web Jekyll通过文件包含源代码
我试图在我的jekyll页面中包含一个c程序的源代码和下载链接 我搜索了jekyll文档,也搜索了stackoverflow,但没有任何结果。 有人能指出正确的方法吗Web Jekyll通过文件包含源代码,web,yaml,jekyll,liquid,Web,Yaml,Jekyll,Liquid,我试图在我的jekyll页面中包含一个c程序的源代码和下载链接 我搜索了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> &
---
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 %}
---
来源:[“inf.c”、“find.c”、“error.c”、“stu.c”、“info.c”]
---
{page.source%中的c的%s}
{%highlight ruby%}
{%include{{page.permalink}{{c}}%}
{%endhighlight%}
{%endfor%}
假设您的代码片段以a.c
和b.c
等形式重新存储在/code>文件夹中
您的页面code.html
可以如下所示:
{% for c in page.source %}
{% capture filePath %}/code/{{c}}{% endcapture %}
<a href="{{filePath}}">{{c}}</a>
{% highlight c %}
{% include_relative {{ filePath }} %}
{% endhighlight %}
{% endfor %}
{page.source%}
{%capture filePath%}/code/{{c}{%endcapture%}
{%c%}
{%include_relative{{filePath}}%}
{%endhighlight%}
{%endfor%}