jekyll脚注中的针织大块 [英] knitr chunk in footnote with jekyll

查看:68
本文介绍了jekyll脚注中的针织大块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

kramdown降价文档中,我读到可以插入多行脚注在脚注中缩进下一行.我试图像这样在脚注中插入编织块:

In the kramdown markdown documentation I read that I can insert multi line footnotes by indenting the next lines in the footnote. I tried to insert a knitr chunk into the footnote like this:

---
title: "test"
output: html_document
layout: post
---
My text[^1]

[^1]:This should appear in a footnote:
    ```{r}
    runif(1:10)
    ```

当直接用knitr编译脚注时,此方法有效:

This worked when compiling the footnote directly with knitr:

如果让jekyll进行编译,它的外观将有所不同:

If I let jekyll compile it it looks differently:

脚注中并没有真正的代码块.它在它上面.缩进是因为未正确识别为脚注注释.

The code chunk is not really in the footnote. It is above it. And it is indented like this is not properly recognized as footnote annotation.

config.yaml中,我定义了markdown: kramdown.

推荐答案

@ mb21指出,将markdown: kramdown切换为pandoc会使jekyll使用与knitr默认相同的markdown编译器.您必须先安装jekyll-pandoc gem.最好用捆绑器完成:

As @mb21 pointed out switching markdown: kramdown to pandoc makes jekyll use the same markdown compiler as knitr does by default. You have to install the jekyll-pandoc gem first. This is best done with bundler:

根据 bundler.io ,在命令行中:

gem install bundler
cd /path/to/my/project
bundle init

根据 jekyll-pandoc :

nano Gemfile

使用以下内容覆盖:

source "https://rubygems.org"

gem "jekyll-pandoc"

保存.

然后:

bundle install

这将安装jekyll-pandoc和所有依赖项.

This will install jekyll-pandoc and all dependencies.

在您的项目中,将此添加到您的_config.yaml:

In your project add this to your _config.yaml:

# Build settings
gems:
  - jekyll-pandoc
markdown: pandoc

(替换markdown: kramdown).

要生成您的网站,请在R中使用以下命令:

To generate your site use this command inside R:

servr::jekyll(command="bundle exec jekyll build")

这篇关于jekyll脚注中的针织大块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆