File: md_weave_to_vignette.R

package info (click to toggle)
r-cran-simplermarkdown 0.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: makefile: 2
file content (34 lines) | stat: -rw-r--r-- 988 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Wrappers around the mdweave_to_* functions and mdtangle function intended
# for use for handling vignettes. The main difference is that these functions
# check if pandoc is available and if not will generate dummy output and not
# generate an error.

mdweave_to_html_vignette <- function(fn, ofn = file_subs_ext(basename(fn), "html", FALSE), ...) {
  if (!has_pandoc()) {
    writeLines("Cannot find pandoc. Not able to weave vignette.", ofn)
    ofn
  } else {
    mdweave_to_html(fn, ofn, ...)
  }
}


mdweave_to_pdf_vignette <- function(fn, ofn = file_subs_ext(basename(fn), "pdf", FALSE), ...) {
  if (!has_pandoc()) {
    writeLines("Cannot find pandoc. Not able to weave vignette.", ofn)
    ofn
  } else {
    mdweave_to_pdf(fn, ofn, ...)
  }
}


mdtangle_vignette <- function(fn, ofn = file_subs_ext(basename(fn), ".R"), ...) {
  if (!has_pandoc()) {
    writeLines("# Cannot find pandoc. Not able to tangle vignette.", ofn)
    ofn
  } else {
    mdtangle(fn, ofn, ...)
  }
}