Pandoc.brew: Brew in pandoc format

Description Usage Arguments Details Value Note References Examples

Description

This function behaves just like brew except for the <%=...%> tags, where Pandoc.brew first translate the R object found between the tags to Pandoc's markdown before passing to the cat function.

Usage

1
2
3
Pandoc.brew(file = stdin(), output = stdout(), convert = FALSE,
  open = TRUE, graph.name, graph.dir, graph.hi.res = FALSE, text = NULL,
  envir = parent.frame(), append = FALSE, ...)

Arguments

file

file path of the brew template. As this is passed to readLines, file could be an URL too, but not over SSL (for that latter RCurl would be needed).

output

(optional) file path of the output file

convert

string: format of required output document (besides Pandoc's markdown). Pandoc is called if set via Pandoc.convert and the converted document could be also opened automatically (see below).

open

try to open converted document with operating system's default program

graph.name

character string (default to %t when output is set to stdout and paste0(basename(output), '-%n') otherwise) passed to evals. Besides evals's possible tags %i is also available which would be replaced by the chunk number (and optionally an integer which would handle nested brew calls) and %I with the order of the current expression.

graph.dir

character string (default to tempdir() when output is set to stdout and dirname(graph.name) otherwise) passed to evals

graph.hi.res

render high resolution images of plots? Default is FALSE except for HTML output.

text

character vector (treated as the content of the file

envir

environment where to brew the template

append

should append or rather overwrite (default) the output markdown text file? Please note that this option only affects the markdown file and not the optionally created other formats.

...

additional parameters passed to Pandoc.convert

Details

This parser tries to be smart in some ways:

Please see my Github page for details (http://rapporter.github.com/pander/#brew-to-pandoc) and examples (http://rapporter.github.com/pander/#examples).

Value

converted file name with full path if convert is set, none otherwise

Note

Only one of the input parameters (file or text) is to be used at once!

References

Examples

 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
## Not run: 
text <- paste('# Header', '',
  'What a lovely list:\n<%=as.list(runif(10))%>',
  'A wide table:\n<%=mtcars[1:3, ]%>',
  'And a nice chart:\n\n<%=plot(1:10)%>', sep = '\n')
Pandoc.brew(text = text)
Pandoc.brew(text = text, output = tempfile(), convert = 'html')
Pandoc.brew(text = text, output = tempfile(), convert = 'pdf')

## pi is awesome
Pandoc.brew(text='<%for (i in 1:5) {%>\n Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>')

## package bundled examples
Pandoc.brew(system.file('examples/minimal.brew', package='pander'))
Pandoc.brew(system.file('examples/minimal.brew', package='pander'),
  output = tempfile(), convert = 'html')
Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'))
Pandoc.brew(system.file('examples/short-code-long-report.brew', package='pander'),
  output = tempfile(), convert = 'html')

## brew returning R objects
str(Pandoc.brew(text='Pi equals to <%=pi%>.
And here are some random data:\n<%=runif(10)%>'))

str(Pandoc.brew(text='# Header <%=1%>\nPi is <%=pi%> which is smaller then <%=2%>.
foo\nbar\n <%=3%>\n<%=mtcars[1:2,]%>'))

str(Pandoc.brew(text='<%for (i in 1:5) {%>
Pi has a lot (<%=i%>) of power: <%=pi^i%><%}%>'))

## End(Not run)

huashan/pander documentation built on May 17, 2019, 9:10 p.m.