I am trying to write a Jekyll converter for R Markdown files. I created RMarkdownConverter.rb and placed it in my _plugins directory. I have verified that other plugins are working but this one is not. I also don’t see any error messages, including the ones I put in myself. It seems this is not being used. However, Jekyll is generating an HTML file for my .Rmd file but simply processes the R chuck as code chuck. Any help or thoughts would be greatly appreciated.
RMarkdownConverter.rb file:
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
The contents of my first R Markdown post:
---
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
```
Try replacing the last few lines with the following
I think you need
R.pullto copy the contents of R output to Ruby. Moreover, I would recommend directly converting from Rmd to html. I have used this strategy successfully in working with Ruhoh which is another ruby based blogging platform.UPDATE. It is very odd but using the extension rmd seems to conflict with md. I changed it randomly to
ramand jekyll seems to pick it up correctly. I am not sure why.