knit2html: Convert markdown to HTML using knit() and markdownToHTML()

Description Usage Arguments Value Note See Also Examples

View source: R/utils-conversion.R

Description

This is a convenience function to knit the input markdown source and call markdownToHTML() in the markdown package to convert the result to HTML.

Usage

1
2
knit2html(input, output = NULL, ..., envir = parent.frame(), text = NULL, quiet = FALSE, 
    encoding = getOption("encoding"), force_v1 = FALSE)

Arguments

input

path of the input file

output

path of the output file for knit(); if NULL, this function will try to guess and it will be under the current working directory

...

options passed to markdownToHTML

envir

the environment in which the code chunks are to be evaluated (for example, parent.frame(), new.env(), or globalenv())

text

a character vector as an alternative way to provide the input file

quiet

whether to suppress the progress bar and messages

encoding

the encoding of the input file; see file

force_v1

whether to force rendering the input document as an R Markdown v1 document (even if it is for v2)

Value

If the argument text is NULL, a character string (HTML code) is returned; otherwise the result is written into a file and the filename is returned.

Note

The markdown package is for R Markdown v1, which is much less powerful than R Markdown v2, i.e. the rmarkdown package (http://rmarkdown.rstudio.com). To render R Markdown v2 documents to HTML, please use rmarkdown::render() instead.

See Also

knit, markdownToHTML

Examples

1
2
3
4
5
# a minimal example
writeLines(c("# hello markdown", "```{r hello-random, echo=TRUE}", "rnorm(5)", "```"), 
    "test.Rmd")
knit2html("test.Rmd")
if (interactive()) browseURL("test.html")

Example output

processing file: test.Rmd

  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |................................                                 |  50%
  ordinary text without R code


  |                                                                       
  |.................................................................| 100%
label: hello-random (with options) 
List of 1
 $ echo: logi TRUE


output file: test.md

knitr documentation built on Aug. 10, 2017, 9:02 a.m.