I am trying to figure out what command and default options RStudio uses when pressing the "knit HTML" button in RStudio version 0.98.1091 because I get a slightly different intermediate markdown file when I run the knit()
function from the console.
Specifically, when I use the following header for the R markdown file:
---
title: "Report Title"
author: Daddy the Runner
date: "`r format(Sys.time(), '%A, %B %d, %Y')`"
output:
html_document:
keep_md: true
---
I get the following markdown file when pressing the "Knit HTML" button:
# Report Title
Daddy the Runner
`r format(Sys.time(), '%A, %B %d, %Y')`
When I execute the following command: knit("myReport.Rmd")
, I get the following markdown file:
---
title: "Report Title"
author: Daddy the Runner
date: "Saturday, January 10, 2015"
output:
html_document:
keep_md: true
---
Clearly the RStudio button is generating the intermediate markdown file using some other options but I can't find any information about it in the RStudio docs.
The key issue is the date line. For some reason, RStudio doesn't execute the inline r chunk in the header when making the markdown file. (However, it does get executed before generating the final HTML.) Whereas, the knit()
function call does execute the inline chunk while generating the markdown file.
The only other difference I noticed in the two markdown files is related to the generation of plots. The two methods generate different sized graphics (command line: 504 x 504) versus (button: 672 x 480) and place them in different directories.
I tried the recommendation in this What commands are run when pressing "Knit HTML" on an R Markdown file in Rstudio 0.96? question to insert a Sys.sleep(30)
call but that did not provide any information about what call RStudio used to knit the document. It did pause the output in the R Markdown console window which was unnecessary because RStudio keeps all of the output anyway. What I didn't see in the output was the command RStudio issued.
Any insight to the nature of these differences would be greatly appreciated. While I like using IDE environments and the conveniences they provide, I really like to understand what it is they are doing so I can better anticipate their behavior.
When I look at the RMarkdown tab (right of Console tab) it looks like they run
knitr::knit
and then a fairly involvedpandoc
shell line/usr/local/lib/rstudio/bin/pandoc/pandoc filename.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output filename.html --smart --email-obfuscation none --self-contained --standalone --section-divs --table-of-contents --toc-depth 3 --template /home/me/R/i686-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/default.html --variable 'theme:flatly' --include-in-header /tmp/user/1001/RtmpKz5GnI/rmarkdown-str3bba3848bd7b.html --mathjax --variable 'mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --no-highlight --variable highlightjs=/home/cd/R/i686-pc-linux-gnu-library/3.1/rmarkdown/rmd/h/highlight
From the very first
/usr/local/lib/rstudio/bin/pandoc/pandoc
I infer that they bring their ownpandoc
, probably figuring duplication is better than debugging to play nice with everyone's idiosyncraticpandoc
versions.So to me it looks like RStudio is doing the following:
and step #2 is where the interpretation of your header
happens.
HTH.
As @rawr pointed out in the comments:
works and creates the same document as the
Knit HTML
button.I believe it currently uses the
html_document
function in the RMarkdown package