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.
markdownToHTML
works), you can either specify meaningful alt-texts, or use -f "markdown-implicit_figures"
-- but this only works with recent versions of Pandoc (>=1.10)markdownToHTML
uses, which on my system lives atsystem.file("resources", "markdown.css", package = "markdown")
## [1] "/mnt/hgfs/bolker/Documents/LOCAL/lib/R/site-library/markdown/resources/markdown.css"
markdownToHTML
embeds the figures as Base64 within an HTML file, so it's self-contained. I like this (don't need to remember to push figures to a web file separately; people can copy the HTML as a single file).jsmath
latexmathml
didn't render all of my output properly (\dots
turned into something else)mathml
seems OK, although not as pretty as mathjax.Some math for testing: (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")
system(cmd)
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. http://linkinghub.elsevier.com/retrieve/pii/S0167947312000692.
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.
This is an inline footnote.↩