Created
July 24, 2013 02:15
-
-
Save simonellistonball/6067634 to your computer and use it in GitHub Desktop.
Rmarkdown block tag for Liquid in Jekyll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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