Generating HTML from knitr and Pandoc

I like the convenience of generating output from R Markdown by the standard knitr/RStudio method, i.e. knit to markdown, then use markdown::markdown2HTML to generate HTML (this is what knit::knit2html does). However, there are some things - in particular processing citations - that Pandoc does better than the R markdown package (which is based on the Sundown markdown library, which has apparently been deprecated in favour of PageDown)

This gets into a mess of dialect differences.

system.file("resources", "markdown.css", package = "markdown")
## [1] "/mnt/hgfs/bolker/Documents/LOCAL/lib/R/site-library/markdown/resources/markdown.css"

Some math for testing: sin(e2πi)=v=(1ϕψ5) (split seems to work, but I had to use $$ rather than \begin{equation} ... \end{equation})

The bottom line is that I am using

fn <- "pandoc_diffs"
css <- system.file("resources", "markdown.css", package = "markdown")
knitr::knit(paste0(fn, ".rmd"))
cmd <- paste0("pandoc -f 'markdown-implicit_figures' -s -o ", fn, ".html -c ", 
    css, " ", fn, ".md --self-contained --bibliography ", fn, ".bib --mathml")

or in a Makefile

pandoc -f "markdown-implicit_figures" -s -o $*.html -c ${CSS} $*.md --self-contained --bibliography $*.bib --mathml

to process Markdown to HTML via Pandoc. To process it to PDF, I have been translating to LaTeX and using a sed script:

sed -e 's/\\DefineShortVerb/%% DefineShortVerb/' <$1

to hack the output slightly.

Augustin, Nicole H., Erik-André Sauleau, and Simon N. Wood. 2012. “On quantile quantile plots for generalized linear models.” Computational Statistics & Data Analysis 56 (8) (aug): 2404–2409. doi:10.1016/j.csda.2012.01.026.

Guy, A. 2012a. “A reference.” The Journal of More Stuff.

———. 2012b. “A reference.” The Journal of More Stuff.

Schmo, J. 1977. “A reference.” The Journal of Stuff.

  1. This is an inline footnote.