Skip to content

Instantly share code, notes, and snippets.

@simonellistonball
Created July 24, 2013 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonellistonball/6067634 to your computer and use it in GitHub Desktop.
Save simonellistonball/6067634 to your computer and use it in GitHub Desktop.
Rmarkdown block tag for Liquid in Jekyll
module Jekyll
class RMarkDownInlineTag < Liquid::Block
def initialize(tag_name, markup, tokens)
super
require 'rinruby'
end
# parse the content of the tag as if it were an Rmd file
def render(context)
R.eval "require(knitr)"
R.assign "content", super
R.eval "content <- (knitr::knit2html(text = content, fragment.only = TRUE))"
R.pull "content"
end
end
end
Liquid::Template.register_tag('Rmd', Jekyll::RMarkDownInlineTag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment