私はRマークダウンファイル用のジキル変換器を書こうとしています。 RMarkdownConverter.rb
を作成し、_plugins
ディレクトリに配置しました。他のプラグインが動作していることを確認しましたが、このプラグインは動作していません。私も自分自身に入れたものを含め、エラーメッセージは表示されません。これは使用されていないようです。しかし、ジキルは私の.Rmd
ファイル用のHTMLファイルを生成していますが、単にRチャックをコードチャックとして処理しています。どんな助けや考えも大歓迎です。ジキル変換Rマークダウン
RMarkdownConverter.rb
ファイル:
module Jekyll
class RMarkdownConverter < Converter
safe true
priority :low
def setup
STDERR.puts "Setting up R Markdown..."
return if @setup
require 'rinruby'
@setup = true
rescue
STDERR.puts 'do `gem install rinruby`'
raise FatalException.new("Missing dependency: rinruby")
end
def matches(ext)
ext =~ /Rmd/i
end
def output_ext(ext)
'.html'
end
def convert(content)
setup
STDERR.puts "Using R Markdown..."
R.eval "require(knitr)"
R.eval "render_markdown(strict=TRUE)"
R.assign "content", content
STDERR.puts content
R.eval "out <- knit(text=content)"
R.eval "print(out)"
end
end
end
私の最初のRマークダウンポストの内容:
---
layout: post
title: Using (R) Markdown, Jekyll, and Github for Blogging
published: true
tags: R R-Bloggers Jekyll github
type: post
status: publish
---
First, we need to install [RinRuby](https://sites.google.com/a/ddahl.org/rinruby-users/) to call R from Ruby. In the terminal, execute:
gem install rinruby
First R chuck:
```{r}
2 + 2
```
'_config.yml'に' markdown_ext:markdown'を追加すると、Jekyllは 'rmd'ファイルを処理します。ただし、 'md'ファイルは処理されません。 '.markdown'というファイル拡張子を使っているので、私にとって大きな問題ではありません。 – jbryer
遅くなることが知られている 'rinruby'を起動することなくこれを行う方法があります。私は、Rmdファイルを処理するためにシェルコマンドを直接使用する方法を模索していますが、knitrが使用するバックティックはシェルの実行を引き上げます。 – Ramnath