【问题标题】:Jekyll including source code via fileJekyll 通过文件包含源代码
【发布时间】:2014-12-08 04:31:37
【问题描述】:

我正在尝试在带有下载链接的 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>
   </th>
</tr>
<tr>
   <th>
    {% highlight ruby %}
    {% include {{page.permalink}}{{c}} %}
    {% endhighlight %}
    </th>
</tr>

{% endfor %}

【问题讨论】:

    标签: web yaml jekyll liquid


    【解决方案1】:

    假设您的代码 sn-ps 以a.cb.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 %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多