问题
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)
```
This worked when compiling the footnote directly with knitr:
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.
In config.yaml
I defined markdown: kramdown
.
回答1:
Knitr uses pandoc under the hood. To achieve the same output with Jekyll, you should use jekyll-pandoc, thus in config.yaml
instead of markdown: kramdown
then markdown: pandoc
.
回答2:
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:
According to bundler.io, in a command line:
gem install bundler
cd /path/to/my/project
bundle init
According to jekyll-pandoc:
nano Gemfile
overwrite with the following:
source "https://rubygems.org"
gem "jekyll-pandoc"
save.
Then:
bundle install
This will install jekyll-pandoc
and all dependencies.
In your project add this to your _config.yaml
:
# Build settings
gems:
- jekyll-pandoc
markdown: pandoc
(replace markdown: kramdown
).
To generate your site use this command inside R:
servr::jekyll(command="bundle exec jekyll build")
来源:https://stackoverflow.com/questions/36019756/knitr-chunk-in-footnote-with-jekyll